houyaf 3 ani în urmă
părinte
comite
850bd82122

+ 3 - 3
datamodels/biz_object_rule.go → datamodels/biz_object_oam_rule.go

@@ -1,6 +1,6 @@
 package datamodels
 
-type BizObjectRule struct {
+type BizObjectOAMRule struct {
     
     BizId        int64     `json:"bizId"           xorm:"'biz_id'          bigint      pk comment('BIZ ID')         "`
     ObjectId     int64     `json:"objectId"        xorm:"'object_id'       bigint      pk comment('Object ID')      "`
@@ -11,6 +11,6 @@ type BizObjectRule struct {
     RuleCode     string    `json:"ruleCode"        xorm:"'rule_code'       varchar(1023)  comment('Rule Code')      "`
 }
 
-func (t *BizObjectRule) TableName() string {
-    return "biz_object_rule"
+func (t *BizObjectOAMRule) TableName() string {
+    return "biz_object_oam_rule"
 }

+ 22 - 22
repositories/biz_object_oam_rule_repo.go

@@ -18,17 +18,17 @@ func NewBizObjectOAMRuleRepo(engine *xorm.Engine) *BizObjectOAMRuleRepo {
     }
 }
 
-func (d *BizObjectOAMRuleRepo) GetList(m map[string]interface{}) ([]viewmodels.BizObjectRuleInfo, error) {
+func (d *BizObjectOAMRuleRepo) GetList(m map[string]interface{}) ([]viewmodels.BizObjectOAMRuleInfo, error) {
     sqlSelect  := ` SELECT A.*,
                            B.object_title,
                            B.object_code,
                            B.object_type,
                            C.oam_title,
                            R.rule_title `
-    sqlFrom    := ` FROM      biz_object_rule AS A
-                    LEFT JOIN biz_object      AS B ON (A.biz_id = B.biz_id AND A.object_id = B.object_id)
-                    LEFT JOIN biz_object_oam  AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id AND A.oam_id = C.oam_id)
-                    LEFT JOIN biz_rule        AS R ON (A.rule_id = R.rule_id) `
+    sqlFrom    := ` FROM      biz_object_oam_rule AS A
+                    LEFT JOIN biz_object          AS B ON (A.biz_id = B.biz_id AND A.object_id = B.object_id)
+                    LEFT JOIN biz_object_oam      AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id AND A.oam_id = C.oam_id)
+                    LEFT JOIN biz_rule            AS R ON (A.rule_id = R.rule_id) `
     
     sqlWhere   := ` WHERE 1=1    `
     if bizId, ok := m["bizId"]; ok {
@@ -45,7 +45,7 @@ func (d *BizObjectOAMRuleRepo) GetList(m map[string]interface{}) ([]viewmodels.B
     }
     sqlOrderBy := " ORDER BY A.oam_id ASC "
     
-    datalist   := make([]viewmodels.BizObjectRuleInfo, 0)
+    datalist   := make([]viewmodels.BizObjectOAMRuleInfo, 0)
     err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
     if err != nil {
         return nil, err
@@ -54,17 +54,17 @@ func (d *BizObjectOAMRuleRepo) GetList(m map[string]interface{}) ([]viewmodels.B
     }
 }
 
-func (d *BizObjectOAMRuleRepo) GetById(bizId, objectId, oamId, orId int64) (*viewmodels.BizObjectRuleInfo, error) {
+func (d *BizObjectOAMRuleRepo) GetById(bizId, objectId, oamId, orId int64) (*viewmodels.BizObjectOAMRuleInfo, error) {
     sqlSelect  := ` SELECT A.*,
                            B.object_title,
                            B.object_code,
                            B.object_type,
                            C.oam_title,
                            R.rule_title `
-    sqlFrom    := ` FROM      biz_object_rule AS A
-                    LEFT JOIN biz_object      AS B ON (A.biz_id = B.biz_id AND A.object_id = B.object_id)
-                    LEFT JOIN biz_object_oam  AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id AND A.oam_id = C.oam_id)
-                    LEFT JOIN biz_rule        AS R ON (A.rule_id = R.rule_id) `
+    sqlFrom    := ` FROM      biz_object_oam_rule AS A
+                    LEFT JOIN biz_object          AS B ON (A.biz_id = B.biz_id AND A.object_id = B.object_id)
+                    LEFT JOIN biz_object_oam      AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id AND A.oam_id = C.oam_id)
+                    LEFT JOIN biz_rule            AS R ON (A.rule_id = R.rule_id) `
     
     sqlWhere   := ` WHERE 1=1   `
     sqlWhere   += fmt.Sprintf(" AND A.biz_id    = %d ", bizId)
@@ -72,7 +72,7 @@ func (d *BizObjectOAMRuleRepo) GetById(bizId, objectId, oamId, orId int64) (*vie
     sqlWhere   += fmt.Sprintf(" AND A.oam_id    = %d ", oamId)
     sqlWhere   += fmt.Sprintf(" AND A.or_id     = %d ", orId)
     
-    data    := &viewmodels.BizObjectRuleInfo{}
+    data    := &viewmodels.BizObjectOAMRuleInfo{}
     has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
     if !has || err != nil {
         return nil, err
@@ -81,24 +81,24 @@ func (d *BizObjectOAMRuleRepo) GetById(bizId, objectId, oamId, orId int64) (*vie
     }
 }
 
-func (d *BizObjectOAMRuleRepo) GetListById(bizId, objectId, oamId int64) ([]viewmodels.BizObjectRuleInfo, error) {
+func (d *BizObjectOAMRuleRepo) GetListById(bizId, objectId, oamId int64) ([]viewmodels.BizObjectOAMRuleInfo, error) {
     sqlSelect  := ` SELECT A.*,
                            B.object_title,
                            B.object_code,
                            B.object_type,
                            C.oam_title,
                            R.rule_title `
-    sqlFrom    := ` FROM      biz_object_rule AS A
-                    LEFT JOIN biz_object      AS B ON (A.biz_id = B.biz_id AND A.object_id = B.object_id)
-                    LEFT JOIN biz_object_oam  AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id AND A.oam_id = C.oam_id)
-                    LEFT JOIN biz_rule        AS R ON (A.rule_id = R.rule_id) `
+    sqlFrom    := ` FROM      biz_object_oam_rule AS A
+                    LEFT JOIN biz_object          AS B ON (A.biz_id = B.biz_id AND A.object_id = B.object_id)
+                    LEFT JOIN biz_object_oam      AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id AND A.oam_id = C.oam_id)
+                    LEFT JOIN biz_rule            AS R ON (A.rule_id = R.rule_id) `
     
     sqlWhere   := ` WHERE 1=1    `
     sqlWhere   += fmt.Sprintf(" AND A.biz_id    = %d ", bizId)
     sqlWhere   += fmt.Sprintf(" AND A.object_id = %d ", objectId)
     sqlWhere   += fmt.Sprintf(" AND A.oam_id    = %d ", oamId)
     
-    dataList    := make([]viewmodels.BizObjectRuleInfo, 0)
+    dataList    := make([]viewmodels.BizObjectOAMRuleInfo, 0)
     has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(&dataList)
     if !has || err != nil {
         return nil, err
@@ -108,12 +108,12 @@ func (d *BizObjectOAMRuleRepo) GetListById(bizId, objectId, oamId int64) ([]view
 }
 
 
-func (d *BizObjectOAMRuleRepo) Create(data *datamodels.BizObjectRule) error {
+func (d *BizObjectOAMRuleRepo) Create(data *datamodels.BizObjectOAMRule) error {
     _, err := d.engine.Insert(data)
     return err
 }
 
-func (d *BizObjectOAMRuleRepo) Update(data *datamodels.BizObjectRule) error {
+func (d *BizObjectOAMRuleRepo) Update(data *datamodels.BizObjectOAMRule) error {
     orId     := data.OrId
     _, err := d.engine.
         Where("or_id = ?", orId).
@@ -130,7 +130,7 @@ func (d *BizObjectOAMRuleRepo) Delete(m map[string]interface{}) error {
     if !ok1 || !ok2 || !ok3 || !ok4 {
         return errors.New("数据不完整")
     }
-    data := &datamodels.BizObjectRule{}
+    data := &datamodels.BizObjectOAMRule{}
     _, err := d.engine.
         Where("biz_id = ?", bizId).
         Where("object_id = ?", objectId).
@@ -141,7 +141,7 @@ func (d *BizObjectOAMRuleRepo) Delete(m map[string]interface{}) error {
 }
 
 func (d *BizObjectOAMRuleRepo) DeleteByObjectId(bizId, objectId, oamId int64) error {
-    data := &datamodels.BizObjectRule{}
+    data := &datamodels.BizObjectOAMRule{}
     _, err := d.engine.
         Where("biz_id = ?", bizId).
         Where("object_id = ?", objectId).

+ 5 - 0
service/biz_object_attr_service.go

@@ -11,6 +11,7 @@ type BizObjectAttrService interface {
     GetList(m map[string]interface{}) ([]viewmodels.BizObjectAttrInfo, error)
     GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
     GetById(bizId, objectId, attrId int64) (*viewmodels.BizObjectAttrInfo, error)
+    GetListById(bizId, objectId int64) ([]viewmodels.BizObjectAttrInfo, error)
     Create(d *datamodels.BizObjectAttr) error
     Update(d *datamodels.BizObjectAttr) error
     Delete(m map[string]interface{}) error
@@ -20,6 +21,10 @@ type bizObjectAttrService struct {
     repo *repositories.BizObjectAttrRepo
 }
 
+func (s *bizObjectAttrService) GetListById(bizId, objectId int64) ([]viewmodels.BizObjectAttrInfo, error) {
+    return s.repo.GetListById(bizId, objectId)
+}
+
 func NewBizObjectAttrService() BizObjectAttrService {
     return &bizObjectAttrService{
         repo: repositories.NewBizObjectAttrRepo(datasource.InstanceMaster()),

+ 8 - 8
service/biz_object_oam_rule_service.go

@@ -8,10 +8,10 @@ import (
 )
 
 type BizObjectOAMRuleService interface {
-    GetList(m map[string]interface{}) ([]viewmodels.BizObjectRuleInfo, error)
-    GetById(bizId, objectId, oamId, orId int64) (*viewmodels.BizObjectRuleInfo, error)
-    Create(or *datamodels.BizObjectRule) error
-    Update(or *datamodels.BizObjectRule) error
+    GetList(m map[string]interface{}) ([]viewmodels.BizObjectOAMRuleInfo, error)
+    GetById(bizId, objectId, oamId, orId int64) (*viewmodels.BizObjectOAMRuleInfo, error)
+    Create(or *datamodels.BizObjectOAMRule) error
+    Update(or *datamodels.BizObjectOAMRule) error
     Delete(m map[string]interface{}) error
 }
 
@@ -25,21 +25,21 @@ func NewBizObjectOAMRuleService() BizObjectOAMRuleService {
     }
 }
 
-func (s *bizObjectOAMRuleService) GetList(m map[string]interface{}) ([]viewmodels.BizObjectRuleInfo, error) {
+func (s *bizObjectOAMRuleService) GetList(m map[string]interface{}) ([]viewmodels.BizObjectOAMRuleInfo, error) {
     return s.repo.GetList(m)
 }
 
-func (s *bizObjectOAMRuleService) GetById(bizId, objectId, oamId, orId int64) (*viewmodels.BizObjectRuleInfo, error) {
+func (s *bizObjectOAMRuleService) GetById(bizId, objectId, oamId, orId int64) (*viewmodels.BizObjectOAMRuleInfo, error) {
     return s.repo.GetById(bizId, objectId, oamId, orId)
 }
 
-func (s *bizObjectOAMRuleService) Create(or *datamodels.BizObjectRule) error {
+func (s *bizObjectOAMRuleService) Create(or *datamodels.BizObjectOAMRule) error {
     orId    := NewID()
     or.OrId = orId
     return s.repo.Create(or)
 }
 
-func (s *bizObjectOAMRuleService) Update(or *datamodels.BizObjectRule) error {
+func (s *bizObjectOAMRuleService) Update(or *datamodels.BizObjectOAMRule) error {
     return s.repo.Update(or)
 }
 

+ 3 - 3
viewmodels/biz_object_rule_info.go → viewmodels/biz_object_oam_rule_info.go

@@ -1,6 +1,6 @@
 package viewmodels
 
-type BizObjectRuleInfo struct {
+type BizObjectOAMRuleInfo struct {
     BizId        int64     `json:"bizId"           xorm:"'biz_id'          bigint         comment('BIZ ID')         "`
     ObjectId     int64     `json:"objectId"        xorm:"'object_id'       bigint         comment('Object ID')      "`
     ObjectTitle  string    `json:"objectTitle"     xorm:"'object_title'    varchar(127)   comment('Object Title')   "`
@@ -14,6 +14,6 @@ type BizObjectRuleInfo struct {
     RuleCode     string    `json:"ruleCode"        xorm:"'rule_code'       varchar(1023)  comment('Rule Code')      "`
 }
 
-func (t *BizObjectRuleInfo) TableName() string {
-    return "biz_object_rule"
+func (t *BizObjectOAMRuleInfo) TableName() string {
+    return "biz_object_oam_rule"
 }

+ 16 - 6
web/controllers/biz_object_attr_controller.go

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

+ 2 - 2
web/controllers/biz_object_oam_rule_controller.go

@@ -53,7 +53,7 @@ func (c *BizObjectOAMRuleController) GetById(bizId, objectId, oamId, orId int64)
 }
 
 func (c *BizObjectOAMRuleController) Create() *JsonResult {
-    bor   := datamodels.BizObjectRule{}
+    bor   := datamodels.BizObjectOAMRule{}
     if err := c.Ctx.ReadJSON(&bor); err != nil {
         return ResultErr("读取数据失败", nil)
     }
@@ -66,7 +66,7 @@ func (c *BizObjectOAMRuleController) Create() *JsonResult {
 }
 
 func (c *BizObjectOAMRuleController) Update() *JsonResult {
-    ro    := datamodels.BizObjectRule{}
+    ro    := datamodels.BizObjectOAMRule{}
     if err := c.Ctx.ReadJSON(&ro); err != nil {
         return ResultErr("读取数据失败", nil)
     }

+ 4 - 4
web/router/routes.go

@@ -197,10 +197,10 @@ func Configure(b *bootstrap.Bootstrapper) {
 		bizRuleApp.Register(bizRuleService)
 		bizRuleApp.Handle(new(controllers.BizRuleController))
 		
-		bizObjectRuleService := service.NewBizObjectRuleService()
-		bizObjectRuleApp := mvc.New(bizParty.Party("/object/rule"))
-		bizObjectRuleApp.Register(bizObjectRuleService)
-		bizObjectRuleApp.Handle(new(controllers.BizObjectRuleController))
+		bizObjectOAMRuleService := service.NewBizObjectOAMRuleService()
+		bizObjectOAMRuleApp := mvc.New(bizParty.Party("/object/oam/rule"))
+		bizObjectOAMRuleApp.Register(bizObjectOAMRuleService)
+		bizObjectOAMRuleApp.Handle(new(controllers.BizObjectOAMRuleController))
 	}
 	
 	// database