houyaf 3 年之前
父節點
當前提交
ee88ab033f

+ 8 - 8
datamodels/api.go

@@ -3,14 +3,14 @@ package datamodels
 import "time"
 
 type Api struct {
-    ApiId           int64     `json:"apiId"           xorm:"'api_id'        bigint     pk comment('Api ID')    "`
-    ApiMethod       int64     `json:"apiMethod"       xorm:"'api_method'    bigint        comment('Api Method')"`
-    ApiType         int64     `json:"apiType"         xorm:"'api_type'      bigint        comment('Api Type')  "`
-    ApiTitle        string    `json:"apiTitle"        xorm:"'api_title'     varchar(127)  comment('名称')       "`
-    ApiCode         string    `json:"apiCode"         xorm:"'api_code'      varchar(127)  comment('编码')       "`
-    ApiParams       string    `json:"apiParams"       xorm:"'api_params'    varchar(127)  comment('Param')     "`
-    Status          int64     `json:"status"          xorm:"'status'        bigint        comment('Status')    "`
-    ApiDesc         string    `json:"apiDesc"         xorm:"'api_desc'      varchar(50)   comment('描述')       "`
+    ApiId           int64     `json:"apiId"           xorm:"'api_id'        bigint     pk comment('Api ID')     "`
+    ApiMethod       int64     `json:"apiMethod"       xorm:"'api_method'    bigint        comment('Api Method') "`
+    ApiType         int64     `json:"apiType"         xorm:"'api_type'      bigint        comment('Api Type')   "`
+    ApiTitle        string    `json:"apiTitle"        xorm:"'api_title'     varchar(127)  comment('名称')        "`
+    ApiCode         string    `json:"apiCode"         xorm:"'api_code'      varchar(127)  comment('编码')        "`
+    ApiParams       string    `json:"apiParams"       xorm:"'api_params'    varchar(127)  comment('Param')      "`
+    Status          int64     `json:"status"          xorm:"'status'        bigint        comment('Status')     "`
+    ApiDesc         string    `json:"apiDesc"         xorm:"'api_desc'      varchar(50)   comment('描述')        "`
     BizId           int64     `json:"bizId"           xorm:"'biz_id'        bigint        comment('Biz Id')     "`
     ObjectId        int64     `json:"objectId"        xorm:"'object_id'     bigint        comment('Object Id')  "`
     OamId           int64     `json:"oamId"           xorm:"'oam_id'        bigint        comment('Oam Id')     "`

+ 5 - 5
repositories/biz_object_attr_repo.go

@@ -25,7 +25,7 @@ func (d *BizObjectAttrRepo) GetPage(m map[string]interface{}) (*viewmodels.PageR
     sqlSelect  := ` SELECT    A.* ,
                               B.object_code `
     sqlFrom    := ` FROM      biz_object_attr AS A
-                    LEFT JOIN biz_object_attr AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
+                    LEFT JOIN biz_object      AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
     sqlWhere   := ` WHERE A.deleted_flag = 0     `
     if keywords, ok := m["keywords"]; ok {
         sqlWhere += ` AND A.attr_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
@@ -59,7 +59,7 @@ func (d *BizObjectAttrRepo) GetList(m map[string]interface{}) ([]viewmodels.BizO
     sqlSelect  := ` SELECT    A.* ,
                               B.object_code `
     sqlFrom    := ` FROM      biz_object_attr AS A
-                    LEFT JOIN biz_object_attr AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
+                    LEFT JOIN biz_object      AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
     sqlWhere   := ` WHERE  A.deleted_flag = 0   `
     if keywords, ok := m["keywords"]; ok {
         sqlWhere += ` AND A.attr_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
@@ -79,7 +79,7 @@ func (d *BizObjectAttrRepo) GetAll() ([]viewmodels.BizObjectAttrInfo, error) {
     sqlSelect  := ` SELECT    A.* ,
                               B.object_code `
     sqlFrom    := ` FROM      biz_object_attr AS A
-                    LEFT JOIN biz_object_attr AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
+                    LEFT JOIN biz_object      AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
     sqlWhere   := ` WHERE  A.deleted_flag = 0   `
     sqlOrderBy := ` ORDER BY A.sort_no          `
     
@@ -96,7 +96,7 @@ func (d *BizObjectAttrRepo) GetListById(bizId, objectId int64) ([]viewmodels.Biz
     sqlSelect  := ` SELECT    A.* ,
                               B.object_code `
     sqlFrom    := ` FROM      biz_object_attr AS A
-                    LEFT JOIN biz_object_attr AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
+                    LEFT JOIN biz_object      AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
     sqlWhere   := ` WHERE A.deleted_flag = 0   `
     sqlWhere   += fmt.Sprintf(" AND A.biz_id  = %d", bizId)
     sqlWhere   += fmt.Sprintf(" AND A.object_id = %d", objectId)
@@ -115,7 +115,7 @@ func (d *BizObjectAttrRepo) GetById(bizId, objectId, attrId int64) (*viewmodels.
     sqlSelect  := ` SELECT A.* ,
                            B.object_code `
     sqlFrom    := ` FROM      biz_object_attr AS A
-                    LEFT JOIN biz_object_attr AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
+                    LEFT JOIN biz_object      AS B ON(A.biz_id = B.biz_id AND A.object_id = B.object_id) `
     sqlWhere   := ` WHERE A.deleted_flag = 0   `
     sqlWhere   += fmt.Sprintf(" AND A.biz_id  = %d", bizId)
     sqlWhere   += fmt.Sprintf(" AND A.object_id = %d", objectId)

+ 6 - 0
service/model_object_attr_service.go

@@ -13,6 +13,7 @@ type ModelObjectAttrService interface {
 	GetList(m map[string]interface{}) ([]viewmodels.ModelObjectAttrInfo, error)
 	GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
 	GetById(modelId, objectId, attrId int64) (*viewmodels.ModelObjectAttrInfo, error)
+	GetListById(modelId, objectId int64) ([]viewmodels.ModelObjectAttrInfo, error)
 	Create(d *datamodels.ModelObjectAttr) error
 	Update(d *datamodels.ModelObjectAttr) error
 	Delete(m map[string]interface{}) error
@@ -40,6 +41,11 @@ func (s *modelObjectAttrService) GetById(modelId, objectId, attrId int64) (*view
 	return s.repo.GetById(modelId, objectId, attrId)
 }
 
+func (s *modelObjectAttrService) GetListById(modelId, objectId int64) ([]viewmodels.ModelObjectAttrInfo, error) {
+	return s.repo.GetListById(modelId, objectId)
+}
+
+
 func (s *modelObjectAttrService) Create(ObjectAttr *datamodels.ModelObjectAttr) error {
 	ObjectAttr.AttrId = NewID()
 	return s.repo.Create(ObjectAttr)

+ 4 - 4
web/controllers/biz_object_controller.go

@@ -21,8 +21,8 @@ func (c *BizObjectController) BeforeActivation(b mvc.BeforeActivation) {
 }
 
 func (c *BizObjectController) GetList() *JsonResult {
-    params  := c.buildParams()
-    bizId := c.Ctx.URLParamInt64Default("bizId", 0)
+    params := c.buildParams()
+    bizId  := c.Ctx.URLParamInt64Default("bizId", 0)
     if bizId <= 0 {
         return ResultErr("参数不完整", nil)
     }
@@ -36,8 +36,8 @@ func (c *BizObjectController) GetList() *JsonResult {
 }
 
 func (c *BizObjectController) GetPage() *JsonResult {
-    params  := c.buildParams()
-    bizId   := c.Ctx.URLParamInt64Default("bizId", 0)
+    params := c.buildParams()
+    bizId  := c.Ctx.URLParamInt64Default("bizId", 0)
     if bizId <= 0 {
         return ResultErr("参数不完整", nil)
     }

+ 16 - 6
web/controllers/model_object_attr_controller.go

@@ -12,12 +12,13 @@ type ModelObjectAttrController struct {
 }
 
 func (c *ModelObjectAttrController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",     "/",                                                "GetList"   )
-	b.Handle("GET",     "/page",                                            "GetPage"   )
-	b.Handle("GET",     "/{modelId:int64}/{objectId:int64}/{attrId:int64}", "GetById"   )
-	b.Handle("POST",    "/add",                                             "Create"    )
-	b.Handle("PUT",     "/update",                                          "Update"    )
-	b.Handle("DELETE",  "/{modelId:int64}/{objectId:int64}/{attrId:int64}", "DeleteByID")
+	b.Handle("GET",     "/",                                                "GetList"       )
+	b.Handle("GET",     "/page",                                            "GetPage"       )
+	b.Handle("GET",     "/{modelId:int64}/{objectId:int64}/{attrId:int64}", "GetById"       )
+	b.Handle("GET",     "/{modelId:int64}/{objectId:int64}",                "GetListById"   )
+	b.Handle("POST",    "/add",                                             "Create"        )
+	b.Handle("PUT",     "/update",                                          "Update"        )
+	b.Handle("DELETE",  "/{modelId:int64}/{objectId:int64}/{attrId:int64}", "DeleteByID"    )
 }
 
 func (c *ModelObjectAttrController) GetList() *JsonResult {
@@ -49,6 +50,15 @@ func (c *ModelObjectAttrController) GetById(modelId, objectId, attrId int64) *Js
 	}
 }
 
+func (c *ModelObjectAttrController) GetListById(modelId, objectId int64) *JsonResult {
+	data, err := c.Service.GetListById(modelId, objectId)
+	if err != nil {
+		return ResultErr(err.Error(), nil)
+	} else {
+		return ResultOk("获取成功", data)
+	}
+}
+
 func (c *ModelObjectAttrController) Create() *JsonResult {
 	userId := c.GetCurUserId()