houyaf 3 lat temu
rodzic
commit
1d2c006cdf

+ 0 - 1
cache/db_data.go

@@ -1 +0,0 @@
-package cache

+ 0 - 1
datamodels/api.go

@@ -3,7 +3,6 @@ package datamodels
 import "time"
 
 type Api struct {
-    ModuleId        int64     `json:"moduleId"        xorm:"'module_id'     bigint pk  pk comment('Module ID') "`
     ApiId           int64     `json:"apiId"           xorm:"'api_id'        bigint     pk comment('Api ID')    "`
     ApiType         int64     `json:"apiType"         xorm:"'api_type'      bigint        comment('Api Type')  "`
     ApiTitle        string    `json:"apiTitle"        xorm:"'api_title'     varchar(127)  comment('名称')       "`

+ 0 - 22
datamodels/api_module.go

@@ -1,22 +0,0 @@
-package datamodels
-
-import "time"
-
-type ApiModule struct {
-    ModuleId    int64     `json:"moduleId"        xorm:"'module_id'     bigint pk     comment('Module ID')    "`
-    ModuleTitle string    `json:"moduleTitle"     xorm:"'module_title'  varchar(127)  comment('Module Title') "`
-    ModuleCode  string    `json:"moduleCode"      xorm:"'module_code'   varchar(127)  comment('Module Code')  "`
-    ModuleDesc  string    `json:"moduleDesc"      xorm:"'module_desc'   varchar(50)   comment('Module Desc')  "`
-    IsFixed     int64     `json:"isFixed"         xorm:"'is_fixed'      bigint        comment('是否可修改')    "`
-    CreatedBy   int64     `json:"createdBy"       xorm:"'created_by'"`
-    CreatedAt   time.Time `json:"createdAt"       xorm:"'created_at'"`
-    UpdatedBy   int64     `json:"updatedBy"       xorm:"'updated_by'"`
-    UpdatedAt   time.Time `json:"updatedAt"       xorm:"'updated_at'"`
-    DeletedFlag int64     `json:"deletedFlag"     xorm:"'deleted_flag'"`
-    DeletedBy   int64     `json:"deletedBy"       xorm:"'deleted_by'"`
-    DeletedAt   time.Time `json:"deletedAt"       xorm:"'deleted_at'"`
-}
-
-func (t *ApiModule) TableName() string {
-    return "api_module"
-}

+ 1 - 1
datamodels/biz_object_attr.go

@@ -8,7 +8,7 @@ type BizObjectAttr struct {
     AttrId          int64     `json:"attrId"          xorm:"'attr_id'           bigint      pk comment('Attr ID')        "`
     AttrTitle       string    `json:"attrTitle"       xorm:"'attr_title'        varchar(127)   comment('AttrTitle')      "`
     AttrCode        string    `json:"attrCode"        xorm:"'attr_code'         varchar(127)   comment('AttrCode')       "`
-    MappingCode     string    `json:"mappingCode"     xorm:"'mapping_code'      varchar(127)   comment('AttrCode')       "`
+    MappingCode     string    `json:"mappingCode"     xorm:"'mapping_code'      varchar(127)   comment('ModelCode')      "`
     AttrType        int64     `json:"attrType"        xorm:"'attr_type'         bigint         comment('Type')           "`
     AttrLength      int64     `json:"attrLength"      xorm:"'attr_length'       bigint         comment('attrLength')     "`
     AttrDecimals    int64     `json:"attrDecimals"    xorm:"'attr_decimals'     bigint         comment('attrDecimals')   "`

+ 0 - 1
datamodels/model_object_attr.go

@@ -8,7 +8,6 @@ type ModelObjectAttr struct {
 	AttrId       int64     `json:"attrId"          xorm:"'attr_id'          bigint      pk comment('主键ID')         "`
 	AttrTitle    string    `json:"attrTitle"       xorm:"'attr_title'       varchar(127)   comment('AttrTitle')      "`
 	AttrCode     string    `json:"attrCode"        xorm:"'attr_code'        varchar(127)   comment('AttrCode')       "`
-	MappingCode  string    `json:"mappingCode"     xorm:"'mapping_code'     varchar(127)   comment('AttrCode')       "`
 	AttrType     int64     `json:"attrType"        xorm:"'attr_type'        bigint         comment('Type')           "`
 	AttrLength   int64     `json:"attrLength"      xorm:"'attr_length'      bigint         comment('attrLength')     "`
 	AttrDecimals int64     `json:"attrDecimals"    xorm:"'attr_decimals'    bigint         comment('attrDecimals')   "`

+ 0 - 118
repositories/api_module_repo.go

@@ -1,118 +0,0 @@
-package repositories
-
-import (
-    "fmt"
-    "time"
-    "xorm.io/xorm"
-    "xps/datamodels"
-    "xps/viewmodels"
-)
-
-type ApiModuleRepo struct {
-    engine *xorm.Engine
-}
-
-func NewApiModuleRepo(engine *xorm.Engine) *ApiModuleRepo {
-    return &ApiModuleRepo{
-        engine: engine,
-    }
-}
-
-func (d *ApiModuleRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
-    limit     := m["limit"].(int)
-    page      := m["page"].(int)
-    
-    sqlSelect := ` SELECT A.*                `
-    sqlFrom   := ` FROM   api_module   AS A  `
-    sqlWhere  := ` WHERE A.deleted_flag = 0  `
-    
-    if keywords, ok := m["keywords"]; ok {
-        sqlWhere += ` AND A.module_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
-    }
-    
-    sqlCount    := ` SELECT COUNT(*)       `
-    total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(datamodels.ApiModule))
-    if err1 != nil {
-        return nil, err1
-    }
-    sqlOrderBy  := " ORDER BY A.module_id ASC "
-    
-    pageStart   := (page - 1) * limit
-    sqlLimit    := fmt.Sprintf(" LIMIT %d OFFSET %d ", limit, pageStart)
-    
-    datalist := make([]viewmodels.ApiModuleInfo, 0)
-    err2 := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy + sqlLimit).Find(&datalist)
-    if err2 != nil {
-        return nil, err2
-    }
-    
-    pageResult := &viewmodels.PageResult{}
-    pageResult.Data     = datalist
-    pageResult.Total    = total
-    pageResult.PageSize = limit
-    pageResult.Page     = page
-    return pageResult, nil
-}
-
-func (d *ApiModuleRepo) GetList(m map[string]interface{}) ([]viewmodels.ApiModuleInfo, error) {
-    sqlSelect := ` SELECT A.*                 `
-    sqlFrom   := ` FROM  api_module   AS A    `
-    sqlWhere  := ` WHERE A.deleted_flag = 0   `
-    if keywords, ok := m["keywords"]; ok {
-        sqlWhere += ` AND A.module_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
-    }
-    sqlOrderBy := " ORDER BY A.module_id ASC "
-    
-    datalist   := make([]viewmodels.ApiModuleInfo, 0)
-    err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
-    if err != nil {
-        return nil, err
-    } else {
-        return datalist, nil
-    }
-}
-
-func (d *ApiModuleRepo) GetById(moduleId int64) (*viewmodels.ApiModuleInfo, error) {
-    sqlSelect := ` SELECT A.*                 `
-    sqlFrom   := ` FROM  api_module   AS A    `
-    sqlWhere  := ` WHERE A.deleted_flag = 0   `
-    sqlWhere  += fmt.Sprintf(" AND A.module_id = %d", moduleId)
-    
-    data := &viewmodels.ApiModuleInfo{}
-    has, err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere).Get(data)
-    if !has || err != nil {
-        return nil, err
-    } else {
-        return data, nil
-    }
-}
-
-func (d *ApiModuleRepo) Create(data *datamodels.ApiModule) error {
-    data.CreatedAt = time.Now()
-    _, err := d.engine.Insert(data)
-    return err
-}
-
-func (d *ApiModuleRepo) Update(data *datamodels.ApiModule) error {
-    moduleId := data.ModuleId
-    
-    data.UpdatedAt = time.Now()
-    _, err := d.engine.
-        Where("module_id = ?", moduleId).
-        Update(data)
-    return err
-}
-
-func (d *ApiModuleRepo) Delete(m map[string]interface{}) error {
-    moduleId  := m["moduleId"].(int64)
-    deletedBy := m["deletedBy"].(int64)
-    
-    data := &datamodels.ApiModule{}
-    data.DeletedFlag = 1
-    data.DeletedBy = deletedBy
-    data.DeletedAt = time.Now()
-    _, err := d.engine.
-        Where("module_id = ?", moduleId).
-        Update(data)
-    return err
-}

+ 62 - 61
repositories/api_repo.go

@@ -23,7 +23,6 @@ func (d *ApiRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, err
     page  := m["page"].(int)
     
     sqlSelect := ` SELECT    A.*,
-                             B.module_title,
                              C.biz_title,
                              D.object_title,
                              D.object_code,
@@ -36,7 +35,6 @@ func (d *ApiRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, err
                              E.sql_count,
                              E.oam_desc `
     sqlFrom   := ` FROM      api            AS A
-                   LEFT JOIN api_module     AS B ON (A.module_id = B.module_id)
                    LEFT JOIN biz            AS C ON (A.biz_id = C.biz_id)
                    LEFT JOIN biz_object     AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id)
                    LEFT JOIN biz_object_oam AS E ON (A.biz_id = E.biz_id AND A.object_id = E.object_id AND A.oam_id = E.oam_id)`
@@ -45,6 +43,14 @@ func (d *ApiRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, err
         sqlWhere += ` AND A.api_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
     }
     
+    if bizId, ok := m["bizId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.biz_id = %d ", bizId)
+    }
+    
+    if objectId, ok := m["objectId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.object_id = %d ", objectId)
+    }
+    
     sqlCount := ` SELECT COUNT(*) `
     total, err1 := d.engine.SQL(sqlCount + sqlFrom + sqlWhere).Count(new(viewmodels.ApiInfo))
     if err1 != nil {
@@ -70,33 +76,37 @@ func (d *ApiRepo) GetPage(m map[string]interface{}) (*viewmodels.PageResult, err
 }
 
 func (d *ApiRepo) GetList(m map[string]interface{}) ([]viewmodels.ApiInfo, error) {
-    moduleId  := m["moduleId"].(int64)
-    
     sqlSelect := ` SELECT    A.*,
-                             B.module_title,
-                             C.biz_title,
-                             D.object_title,
-                             D.object_code,
-                             D.object_type,
-                             E.oam_title,
-                             E.oam_type,
-                             E.oam_code,
-                             E.sql_type,
-                             E.sql_statement,
-                             E.sql_count,
-                             E.oam_desc `
+                             B.biz_title,
+                             C.object_title,
+                             C.object_code,
+                             C.object_type,
+                             D.oam_title,
+                             D.oam_type,
+                             D.oam_code,
+                             D.sql_type,
+                             D.sql_statement,
+                             D.sql_count,
+                             D.oam_desc `
     sqlFrom   := ` FROM      api            AS A
-                   LEFT JOIN api_module     AS B ON (A.module_id = B.module_id)
-                   LEFT JOIN biz            AS C ON (A.biz_id = C.biz_id)
-                   LEFT JOIN biz_object     AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id)
-                   LEFT JOIN biz_object_oam AS E ON (A.biz_id = E.biz_id AND A.object_id = E.object_id AND A.oam_id = E.oam_id)`
+                   LEFT JOIN biz            AS B ON (A.biz_id = B.biz_id)
+                   LEFT JOIN biz_object     AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id)
+                   LEFT JOIN biz_object_oam AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id AND A.oam_id = D.oam_id)`
     sqlWhere  := ` WHERE  A.deleted_flag = 0  `
-    sqlWhere  += fmt.Sprintf(" AND A.module_id = %d", moduleId)
     
     if keywords, ok := m["keywords"]; ok {
         sqlWhere += ` AND A.api_title like ` + "'%" + fmt.Sprintf("%s", keywords) + "%'"
     }
-    sqlOrderBy := " ORDER BY A.module_id, A.api_id ASC "
+    
+    if bizId, ok := m["bizId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.biz_id = %d ", bizId)
+    }
+    
+    if objectId, ok := m["objectId"]; ok {
+        sqlWhere += fmt.Sprintf(" AND A.object_id = %d ", objectId)
+    }
+    
+    sqlOrderBy := " ORDER BY A.biz_id, A.object_id, A.api_id ASC"
     
     datalist := make([]viewmodels.ApiInfo, 0)
     err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
@@ -109,25 +119,23 @@ func (d *ApiRepo) GetList(m map[string]interface{}) ([]viewmodels.ApiInfo, error
 
 func (d *ApiRepo) GetAll() ([]viewmodels.ApiInfo, error) {
     sqlSelect := `    SELECT  A.*,
-                              B.module_title,
-                              C.biz_title,
-                              D.object_title,
-                              D.object_code,
-                              D.object_type,
-                              E.oam_title,
-                              E.oam_type,
-                              E.oam_code,
-                              E.sql_type,
-                              E.sql_statement,
-                              E.sql_count,
-                              E.oam_desc `
+                              B.biz_title,
+                              C.object_title,
+                              C.object_code,
+                              C.object_type,
+                              D.oam_title,
+                              D.oam_type,
+                              D.oam_code,
+                              D.sql_type,
+                              D.sql_statement,
+                              D.sql_count,
+                              D.oam_desc `
     sqlFrom    := ` FROM      api            AS A
-                    LEFT JOIN api_module     AS B ON (A.module_id = B.module_id)
-                    LEFT JOIN biz            AS C ON (A.biz_id = C.biz_id)
-                    LEFT JOIN biz_object     AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id)
-                    LEFT JOIN biz_object_oam AS E ON (A.biz_id = E.biz_id AND A.object_id = E.object_id AND A.oam_id = E.oam_id)`
+                    LEFT JOIN biz            AS B ON (A.biz_id = B.biz_id)
+                    LEFT JOIN biz_object     AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id)
+                    LEFT JOIN biz_object_oam AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id AND A.oam_id = D.oam_id)`
     sqlWhere   := ` WHERE  A.deleted_flag = 0  `
-    sqlOrderBy := " ORDER BY A.module_id, A.api_id ASC "
+    sqlOrderBy := " ORDER BY A.biz_id, A.object_id, A.api_id ASC"
     datalist := make([]viewmodels.ApiInfo, 0)
     err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
     if err != nil {
@@ -137,27 +145,24 @@ func (d *ApiRepo) GetAll() ([]viewmodels.ApiInfo, error) {
     }
 }
 
-func (d *ApiRepo) GetById(moduleId, apiId int64) (*viewmodels.ApiInfo, error) {
+func (d *ApiRepo) GetById(apiId int64) (*viewmodels.ApiInfo, error) {
     sqlSelect := `    SELECT  A.*,
-                              B.module_title,
-                              C.biz_title,
-                              D.object_title,
-                              D.object_code,
-                              D.object_type,
-                              E.oam_title,
-                              E.oam_type,
-                              E.oam_code,
-                              E.sql_type,
-                              E.sql_statement,
-                              E.sql_count,
-                              E.oam_desc `
+                              B.biz_title,
+                              C.object_title,
+                              C.object_code,
+                              C.object_type,
+                              D.oam_title,
+                              D.oam_type,
+                              D.oam_code,
+                              D.sql_type,
+                              D.sql_statement,
+                              D.sql_count,
+                              D.oam_desc `
     sqlFrom    := ` FROM      api            AS A
-                    LEFT JOIN api_module     AS B ON (A.module_id = B.module_id)
-                    LEFT JOIN biz            AS C ON (A.biz_id = C.biz_id)
-                    LEFT JOIN biz_object     AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id)
-                    LEFT JOIN biz_object_oam AS E ON (A.biz_id = E.biz_id AND A.object_id = E.object_id AND A.oam_id = E.oam_id)`
+                    LEFT JOIN biz            AS B ON (A.biz_id = B.biz_id)
+                    LEFT JOIN biz_object     AS C ON (A.biz_id = C.biz_id AND A.object_id = C.object_id)
+                    LEFT JOIN biz_object_oam AS D ON (A.biz_id = D.biz_id AND A.object_id = D.object_id AND A.oam_id = D.oam_id)`
     sqlWhere   := ` WHERE  A.deleted_flag = 0  `
-    sqlWhere  += fmt.Sprintf(" AND A.module_id = %d", moduleId)
     sqlWhere  += fmt.Sprintf(" AND A.api_id = %d", apiId)
     
     data := &viewmodels.ApiInfo{}
@@ -188,19 +193,16 @@ func (d *ApiRepo) Create(data *datamodels.Api) error {
 }
 
 func (d *ApiRepo) Update(data *datamodels.Api) error {
-    moduleId := data.ModuleId
     apiId    := data.ApiId
     
     data.UpdatedAt = time.Now()
     _, err := d.engine.
-        Where("module_id = ?", moduleId).
         Where("api_id = ?", apiId).
         Update(data)
     return err
 }
 
 func (d *ApiRepo) Delete(m map[string]interface{}) error {
-    moduleId  := m["moduleId"].(int64)
     apiId     := m["apiId"].(int64)
     deletedBy := m["deletedBy"].(int64)
     
@@ -209,7 +211,6 @@ func (d *ApiRepo) Delete(m map[string]interface{}) error {
     data.DeletedBy = deletedBy
     data.DeletedAt = time.Now()
     _, err := d.engine.
-        Where("module_id = ?", moduleId).
         Where("api_id = ?", apiId).
         Update(data)
     return err

+ 8 - 8
repositories/biz_object_oam_repo.go

@@ -43,10 +43,10 @@ func (d *BizObjectOAMRepo) GetList(m map[string]interface{}) ([]viewmodels.BizOb
     }
 }
 
-func (d *BizObjectOAMRepo) GetById(modelId, objectId, oamId int64) (*viewmodels.BizObjectOAMInfo, error) {
+func (d *BizObjectOAMRepo) GetById(bizId, objectId, oamId int64) (*viewmodels.BizObjectOAMInfo, error) {
     data    := &viewmodels.BizObjectOAMInfo{}
     ok, err := d.engine.
-        Where("model_id = ?", modelId).
+        Where("biz_id = ?", bizId).
         Where("object_id = ?", objectId).
         Where("oam_id = ?", oamId).
         Get(data)
@@ -64,12 +64,12 @@ func (d *BizObjectOAMRepo) Create(data *datamodels.BizObjectOAM) error {
 }
 
 func (d *BizObjectOAMRepo) Update(data *datamodels.BizObjectOAM) error {
-    modelId   := data.BizId
+    bizId     := data.BizId
     objectId  := data.ObjectId
     oamId     := data.OamId
     data.UpdatedAt = time.Now()
     _, err := d.engine.
-        Where("model_id = ?", modelId).
+        Where("biz_id = ?", bizId).
         Where("object_id = ?", objectId).
         Where("oam_id = ?", oamId).
         AllCols().
@@ -78,7 +78,7 @@ func (d *BizObjectOAMRepo) Update(data *datamodels.BizObjectOAM) error {
 }
 
 func (d *BizObjectOAMRepo) Delete(m map[string]interface{}) error {
-    modelId   := m["modelId"].(int64)
+    bizId     := m["bizId"].(int64)
     objectId  := m["objectId"].(int64)
     oamId     := m["oamId"].(int64)
     deletedBy := m["deletedBy"].(int64)
@@ -88,17 +88,17 @@ func (d *BizObjectOAMRepo) Delete(m map[string]interface{}) error {
     data.DeletedBy   = deletedBy
     data.DeletedAt   = time.Now()
     _, err := d.engine.
-        Where("model_id = ?", modelId).
+        Where("biz_id = ?", bizId).
         Where("object_id = ?", objectId).
         Where("oam_id = ?", oamId).
         Delete(data)
     return err
 }
 
-func (d *BizObjectOAMRepo) DeleteByObjectId(modelId, objectId, oamId int64) error {
+func (d *BizObjectOAMRepo) DeleteByObjectId(bizId, objectId, oamId int64) error {
     data := &datamodels.BizObjectOAM{}
     _, err := d.engine.
-        Where("model_id = ?", modelId).
+        Where("biz_id = ?", bizId).
         Where("object_id = ?", objectId).
         Where("oam_id = ?", oamId).
         Delete(data)

+ 35 - 14
service/api_gateway_service.go

@@ -35,12 +35,13 @@ func (a *apiGatewayService) Get(apiCode string, m map[string]interface{})(map[st
     }
     
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return nil, err2
     }
+    
     sqlStatement := apiDef.SqlStatement
-    return a.dataBus.GetById(sqlStatement, m)
+    return a.dataBus.GetById(sqlStatement, params)
 }
 
 func (a *apiGatewayService) GetList(apiCode string, m map[string]interface{})([]map[string]interface{}, error) {
@@ -50,12 +51,13 @@ func (a *apiGatewayService) GetList(apiCode string, m map[string]interface{})([]
     }
     
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return nil, err2
     }
+    
     sqlStatement := apiDef.SqlStatement
-    return a.dataBus.GetList(sqlStatement, m)
+    return a.dataBus.GetList(sqlStatement, params)
 }
 
 func (a *apiGatewayService) GetPage(apiCode string, m map[string]interface{}) (*viewmodels.PageResult, error) {
@@ -65,14 +67,14 @@ func (a *apiGatewayService) GetPage(apiCode string, m map[string]interface{}) (*
     }
     
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return nil, err2
     }
     
     sqlStatement := apiDef.SqlStatement
     sqlCount     := apiDef.SqlCount
-    return a.dataBus.GetPage(sqlStatement, sqlCount, m)
+    return a.dataBus.GetPage(sqlStatement, sqlCount, params)
 }
 
 func (a *apiGatewayService) Create(apiCode string, m map[string]interface{}) error {
@@ -80,13 +82,14 @@ func (a *apiGatewayService) Create(apiCode string, m map[string]interface{}) err
     if err1 != nil{
         return err1
     }
+    
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return err2
     }
     
-    return a.dataBus.Create(objectCode, m)
+    return a.dataBus.Create(objectCode, params)
 }
 
 func (a *apiGatewayService) Update(apiCode string, m map[string]interface{}) error {
@@ -96,12 +99,12 @@ func (a *apiGatewayService) Update(apiCode string, m map[string]interface{}) err
     }
     
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return err2
     }
     
-    return a.dataBus.Update(objectCode, m)
+    return a.dataBus.Update(objectCode, params)
 }
 
 func (a *apiGatewayService) Patch(apiCode string, m map[string]interface{}) error {
@@ -111,12 +114,12 @@ func (a *apiGatewayService) Patch(apiCode string, m map[string]interface{}) erro
     }
     
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return err2
     }
     
-    return a.dataBus.Patch(objectCode, m)
+    return a.dataBus.Patch(objectCode, params)
 }
 
 func (a *apiGatewayService) Delete(apiCode string, m map[string]interface{}) error {
@@ -126,10 +129,28 @@ func (a *apiGatewayService) Delete(apiCode string, m map[string]interface{}) err
     }
     
     objectCode := apiDef.ObjectCode
-    _, err2 := cache.GetBizObjectData(objectCode)
+    params, err2 := a.Mapping2ModelField(objectCode, m)
     if err2 != nil {
         return err2
     }
     
-    return a.dataBus.Delete(objectCode, m)
+    return a.dataBus.Delete(objectCode, params)
+}
+
+func (a *apiGatewayService) Mapping2ModelField(objectCode string, m map[string]interface{})(map[string]interface{}, error) {
+    bzObject, err := cache.GetBizObjectData(objectCode)
+    if err != nil {
+        return nil, err
+    }
+    
+    bizObjectAttrs := bzObject.Attrs
+    params := make(map[string]interface{}, 0)
+    for _, bzAttr := range bizObjectAttrs {
+        bzAttrCode    := bzAttr.AttrCode
+        bzMappingCode := bzAttr.MappingCode
+        if bzAttrValue, ok := m[bzAttrCode]; ok {
+            params[bzMappingCode] = bzAttrValue
+        }
+    }
+    return params, nil
 }

+ 0 - 52
service/api_module_service.go

@@ -1,52 +0,0 @@
-package service
-
-import (
-    "xps/datamodels"
-    "xps/datasource"
-    "xps/repositories"
-    "xps/viewmodels"
-)
-
-type ApiModuleService interface {
-    GetList(m map[string]interface{}) ([]viewmodels.ApiModuleInfo, error)
-    GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
-    GetById(moduleId int64) (*viewmodels.ApiModuleInfo, error)
-    Create(d *datamodels.ApiModule) error
-    Update(d *datamodels.ApiModule) error
-    Delete(m map[string]interface{}) error
-}
-
-type apiModuleService struct {
-    repo *repositories.ApiModuleRepo
-}
-
-func NewApiModuleService() ApiModuleService {
-    return &apiModuleService{
-        repo: repositories.NewApiModuleRepo(datasource.InstanceMaster()),
-    }
-}
-
-func (s *apiModuleService) GetList(m map[string]interface{}) ([]viewmodels.ApiModuleInfo, error) {
-    return s.repo.GetList(m)
-}
-
-func (s *apiModuleService) GetPage(m map[string]interface{}) (*viewmodels.PageResult, error) {
-    return s.repo.GetPage(m)
-}
-
-func (s *apiModuleService) GetById(moduleId int64) (*viewmodels.ApiModuleInfo, error) {
-    return s.repo.GetById(moduleId)
-}
-
-func (s *apiModuleService) Create(m *datamodels.ApiModule) error {
-    m.ModuleId = NewID()
-    return s.repo.Create(m)
-}
-
-func (s *apiModuleService) Update(m *datamodels.ApiModule) error {
-    return s.repo.Update(m)
-}
-
-func (s *apiModuleService) Delete(m map[string]interface{}) error {
-    return s.repo.Delete(m)
-}

+ 13 - 16
service/api_service.go

@@ -12,12 +12,12 @@ import (
 type ApiService interface {
     GetList(m map[string]interface{}) ([]viewmodels.ApiInfo, error)
     GetPage(m map[string]interface{}) (*viewmodels.PageResult, error)
-    GetById(moduleId, apiId int64) (*viewmodels.ApiInfo, error)
+    GetById(apiId int64) (*viewmodels.ApiInfo, error)
     Create(d *datamodels.Api) error
     Update(d *datamodels.Api) error
-    ChangeStatus(moduleId, apiId, status int64) error
+    ChangeStatus(apiId, status int64) error
     Delete(m map[string]interface{}) error
-    CacheApiData(moduleId, apiId int64) error
+    CacheApiData(apiId int64) error
 }
 
 type apiService struct {
@@ -38,8 +38,8 @@ func (s *apiService) GetPage(m map[string]interface{}) (*viewmodels.PageResult,
     return s.apiRepo.GetPage(m)
 }
 
-func (s *apiService) GetById(moduleId, apiId int64) (*viewmodels.ApiInfo, error) {
-    return s.apiRepo.GetById(moduleId, apiId)
+func (s *apiService) GetById(apiId int64) (*viewmodels.ApiInfo, error) {
+    return s.apiRepo.GetById(apiId)
 }
 
 func (s *apiService) Create(api *datamodels.Api) error {
@@ -49,9 +49,8 @@ func (s *apiService) Create(api *datamodels.Api) error {
         return err
     }
     
-    moduleId := api.ModuleId
-    apiId    := api.ApiId
-    return s.CacheApiData(moduleId, apiId)
+    apiId := api.ApiId
+    return s.CacheApiData(apiId)
 }
 
 func (s *apiService) Update(api *datamodels.Api) error {
@@ -60,14 +59,12 @@ func (s *apiService) Update(api *datamodels.Api) error {
         return err
     }
     
-    moduleId := api.ModuleId
-    apiId    := api.ApiId
-    return s.CacheApiData(moduleId, apiId)
+    apiId := api.ApiId
+    return s.CacheApiData(apiId)
 }
 
-func (s *apiService) ChangeStatus(moduleId, apiId, status int64) error {
+func (s *apiService) ChangeStatus(apiId, status int64) error {
     data := &datamodels.Api{
-        ModuleId: moduleId,
         ApiId: apiId,
         Status: status,
     }
@@ -76,15 +73,15 @@ func (s *apiService) ChangeStatus(moduleId, apiId, status int64) error {
         return err
     }
     
-    return s.CacheApiData(moduleId, apiId)
+    return s.CacheApiData(apiId)
 }
 
 func (s *apiService) Delete(m map[string]interface{}) error {
     return s.apiRepo.Delete(m)
 }
 
-func (s *apiService) CacheApiData(moduleId, apiId int64) error {
-    api, err := s.apiRepo.GetById(moduleId, apiId)
+func (s *apiService) CacheApiData(apiId int64) error {
+    api, err := s.apiRepo.GetById(apiId)
     if err != nil {
         return nil
     }

+ 3 - 1
service/biz_object_service.go

@@ -206,6 +206,7 @@ func (s *bizObjectService) UpdateObjectData(o *viewmodels.BizObjectData) error {
             AttrId:       newId,
             AttrTitle:    a.AttrTitle,
             AttrCode:     a.AttrCode,
+            MappingCode:  a.MappingCode,
             AttrType:     a.AttrType,
             AttrLength:   a.AttrLength,
             AttrDecimals: a.AttrDecimals,
@@ -220,11 +221,12 @@ func (s *bizObjectService) UpdateObjectData(o *viewmodels.BizObjectData) error {
         }
         
         attrCache := viewmodels.BizObjectAttrInfo{
-            BizId:      bizId,
+            BizId:        bizId,
             ObjectId:     objectId,
             AttrId:       newId,
             AttrTitle:    a.AttrTitle,
             AttrCode:     a.AttrCode,
+            MappingCode:  a.MappingCode,
             AttrType:     a.AttrType,
             AttrLength:   a.AttrLength,
             AttrDecimals: a.AttrDecimals,

+ 30 - 8
utils/json_conv.go

@@ -10,12 +10,11 @@ import (
 	"unicode"
 )
 
-/*************************************** 下划线json ***************************************/
 type JsonSnakeCase struct {
 	Value interface{}
 }
 
-func (c JsonSnakeCase) MarshalJSON() ([]byte, error) {
+func (c JsonSnakeCase) MarshalJson() ([]byte, error) {
 	// Regexp definitions
 	keyMatchRegex    := regexp.MustCompile(`\"(\w+)\":`)
 	wordBarrierRegex := regexp.MustCompile(`(\w)([A-Z])`)
@@ -32,13 +31,13 @@ func (c JsonSnakeCase) MarshalJSON() ([]byte, error) {
 	return converted, err
 }
 
-/*************************************** 驼峰json ***************************************/
+// JsonCamelCase 驼峰json
 type JsonCamelCase struct {
 	Value interface{}
 }
 
 func (c JsonCamelCase) MarshalJSON() ([]byte, error) {
-	keyMatchRegex := regexp.MustCompile(`\"(\w+)\":`)
+	keyMatchRegex   := regexp.MustCompile(`\"(\w+)\":`)
 	marshalled, err := json.Marshal(c.Value)
 	converted := keyMatchRegex.ReplaceAllFunc(
 		marshalled,
@@ -52,8 +51,7 @@ func (c JsonCamelCase) MarshalJSON() ([]byte, error) {
 	return converted, err
 }
 
-/*************************************** 其他方法 ***************************************/
-// 驼峰式写法转为下划线写法
+// Camel2Case 驼峰式写法转为下划线写法
 func Camel2Case(name string) string {
 	buffer := NewBuffer()
 	for i, r := range name {
@@ -76,7 +74,31 @@ func Case2Camel(name string) string {
 	return strings.Replace(name, " ", "", -1)
 }
 
-// Ucfirst first 首字母大写
+func AttrCode2StructField(name string) string {
+	arr := strings.Split(name, "_")
+	sb  := strings.Builder{}
+	for _, v := range arr {
+		s := Ucfirst(v)
+		sb.WriteString(s)
+	}
+	return sb.String()
+}
+
+func AttrCode2JsonField(name string) string{
+	arr := strings.Split(name, "_")
+	sb  := strings.Builder{}
+	for idx, v := range arr {
+		if idx == 0 {
+			sb.WriteString(v)
+		} else {
+			s := Ucfirst(v)
+			sb.WriteString(s)
+		}
+	}
+	return sb.String()
+}
+
+// Ucfirst 首字母大写
 func Ucfirst(str string) string {
 	for i, v := range str {
 		return string(unicode.ToUpper(v)) + str[i+1:]
@@ -129,4 +151,4 @@ func (b *Buffer) append(s string) *Buffer {
 	}()
 	b.WriteString(s)
 	return b
-}
+}

+ 2 - 0
utils/struct_conv.go

@@ -0,0 +1,2 @@
+package utils
+

+ 4 - 4
viewmodels/access_token.go

@@ -1,8 +1,8 @@
 package viewmodels
 
 type AccessToken struct {
-	AccessToken  string      `json:"accessToken"     `
-	User         interface{} `json:"user"            `
-	ExpiresIn    int64       `json:"expiresIn"       `
-	LeaseTime    int64       `json:"leaseTime"       `
+	AccessToken  string         `json:"accessToken"     `
+	User         interface{}    `json:"user"            `
+	ExpiresIn    int64          `json:"expiresIn"       `
+	LeaseTime    int64          `json:"leaseTime"       `
 }

+ 3 - 5
viewmodels/api_info.go

@@ -3,17 +3,15 @@ package viewmodels
 import "encoding/json"
 
 type ApiInfo struct {
-    ModuleId        int64     `json:"moduleId"      xorm:"'module_id'       bigint pk      comment('Module ID')    "`
-    ModuleTitle     string    `json:"moduleTitle"   xorm:"'module_title'    varchar(127)   comment('Module Title') "`
+    BizId           int64     `json:"bizId"         xorm:"'biz_id'          bigint         comment('Biz Id')       "`
+    BizTitle        string    `json:"bizTitle"      xorm:"'biz_title'       varchar(127)   comment('Biz Title')    "`
     ApiId           int64     `json:"apiId"         xorm:"'api_id'          bigint     pk  comment('Api ID')       "`
-    ApiType         int64     `json:"apiType"       xorm:"'api_type'        bigint     pk  comment('Api Type')     "`
+    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')       "`
-    BizTitle        string    `json:"bizTitle"      xorm:"'biz_title'       varchar(127)   comment('Biz Title')    "`
     ObjectId        int64     `json:"objectId"      xorm:"'object_id'       bigint         comment('Object Id')    "`
     ObjectTitle     string    `json:"objectTitle"   xorm:"'object_title'    varchar(127)   comment('Object Title') "`
     ObjectType      int64     `json:"objectType"    xorm:"'object_type'     bigint         comment('Object Type')  "`

+ 0 - 13
viewmodels/api_module_info.go

@@ -1,13 +0,0 @@
-package viewmodels
-
-type ApiModuleInfo struct {
-    ModuleId    int64  `json:"moduleId"      xorm:"'module_id'     bigint      pk comment('主键ID')        "`
-    ModuleTitle string `json:"moduleTitle"   xorm:"'module_title'  varchar(50)    comment('群组类型名称')   "`
-    ModuleCode  string `json:"moduleCode"    xorm:"'module_code'   varchar(127)   comment('Module Code')  "`
-    ModuleDesc  string `json:"moduleDesc"    xorm:"'module_desc'   varchar(50)    comment('描述')          "`
-    IsFixed     int64  `json:"isFixed"       xorm:"'is_fixed'      bigint         comment('是否可修改')     "`
-}
-
-func (t *ApiModuleInfo) TableName() string {
-    return "api_module"
-}

+ 14 - 15
viewmodels/biz_object_attr_info.go

@@ -2,22 +2,21 @@ package viewmodels
 
 
 type BizObjectAttrInfo 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')      "`
-    AttrId          int64     `json:"attrId"          xorm:"'attr_id'           bigint      pk comment('Attr ID')        "`
-    AttrTitle       string    `json:"attrTitle"       xorm:"'attr_title'        varchar(127)   comment('AttrTitle')      "`
-    AttrCode        string    `json:"attrCode"        xorm:"'attr_code'         varchar(127)   comment('AttrCode')       "`
-    MappingCode     string    `json:"mappingCode"     xorm:"'mapping_code'      varchar(127)   comment('AttrCode')       "`
-    AttrType        int64     `json:"attrType"        xorm:"'attr_type'         bigint         comment('Type')           "`
-    AttrLength      int64     `json:"attrLength"      xorm:"'attr_length'       bigint         comment('attrLength')     "`
-    AttrDecimals    int64     `json:"attrDecimals"    xorm:"'attr_decimals'     bigint         comment('attrDecimals')   "`
-    Comment         string    `json:"comment"         xorm:"'comment'           varchar(255)   comment('描述')           "`
-    AttrMappingCode string    `json:"attrMappingCode" xorm:"'attr_mapping_code' varchar(127)   comment('AttrMappingCode')"`
-    IsNotNull       int64     `json:"isNotNull"       xorm:"'is_not_null'       int            comment('是否可修改')      "`
-    SortNo          int64     `json:"sortNo"          xorm:"'sort_no'           int            comment('是否可修改')      "`
-    RuleId          int64     `json:"ruleId"          xorm:"'rule_id'           int            comment('Rule ID')        "`
+    BizId           int64     `json:"bizId"           xorm:"'biz_id'            bigint      pk comment('Biz ID')        "`
+    ObjectId        int64     `json:"objectId"        xorm:"'object_id'         bigint      pk comment('Object ID')     "`
+    AttrId          int64     `json:"attrId"          xorm:"'attr_id'           bigint      pk comment('Attr ID')       "`
+    AttrType        int64     `json:"attrType"        xorm:"'attr_type'         bigint         comment('Type')          "`
+    AttrTitle       string    `json:"attrTitle"       xorm:"'attr_title'        varchar(127)   comment('AttrTitle')     "`
+    AttrCode        string    `json:"attrCode"        xorm:"'attr_code'         varchar(127)   comment('AttrCode')      "`
+    MappingCode     string    `json:"mappingCode"     xorm:"'mapping_code'      varchar(127)   comment('MappingCode')   "`
+    AttrLength      int64     `json:"attrLength"      xorm:"'attr_length'       bigint         comment('AttrLength')    "`
+    AttrDecimals    int64     `json:"attrDecimals"    xorm:"'attr_decimals'     bigint         comment('AttrDecimals')  "`
+    Comment         string    `json:"comment"         xorm:"'comment'           varchar(255)   comment('描述')          "`
+    IsNotNull       int64     `json:"isNotNull"       xorm:"'is_not_null'       int            comment('是否可修改')     "`
+    SortNo          int64     `json:"sortNo"          xorm:"'sort_no'           int            comment('是否可修改')     "`
+    RuleId          int64     `json:"ruleId"          xorm:"'rule_id'           int            comment('Rule ID')       "`
 }
 
 func (t *BizObjectAttrInfo) TableName() string {
-    return "ds_object_attr"
+    return "biz_object_attr"
 }

+ 1 - 0
viewmodels/biz_object_oam_info.go

@@ -11,6 +11,7 @@ type BizObjectOAMInfo struct {
     SqlSelect    string    `json:"sqlSelect"       xorm:"'sql_select'      varchar(1023)  comment('Statement')      "`
     SqlFrom      string    `json:"sqlFrom"         xorm:"'sql_from'        varchar(1023)  comment('Statement')      "`
     SqlWhere     string    `json:"sqlWhere"        xorm:"'sql_where'       varchar(1023)  comment('Statement')      "`
+    SqlCount     string    `json:"sqlCount"        xorm:"'sql_count'       varchar(1023)  comment('Sql Count')      "`
     SqlOrder     string    `json:"sqlOrder"        xorm:"'sql_order'       varchar(1023)  comment('Statement')      "`
     OamDesc      string    `json:"oamDesc"         xorm:"'oam_desc'        varchar(1023)  comment('描述')            "`
 }

+ 15 - 14
viewmodels/model_object_attr_info.go

@@ -1,20 +1,21 @@
 package viewmodels
 
 type ModelObjectAttrInfo struct {
-	ModelId      int64  `json:"modelId"         xorm:"'model_id'        bigint      pk comment('主键ID')        "`
-	ObjectId     int64  `json:"objectId"        xorm:"'object_id'       bigint      pk comment('主键ID')        "`
-	AttrId       int64  `json:"attrId"          xorm:"'attr_id'         bigint      pk comment('主键ID')        "`
-	AttrTitle    string `json:"attrTitle"       xorm:"'attr_title'      varchar(127)   comment('AttrTitle')    "`
-	AttrCode     string `json:"attrCode"        xorm:"'attr_code'       varchar(127)   comment('AttrCode')     "`
-	MappingCode  string `json:"mappingCode"     xorm:"'mapping_code'    varchar(127)   comment('AttrCode')     "`
-	AttrType     int64  `json:"attrType"        xorm:"'attr_type'       bigint         comment('Type')         "`
-	AttrLength   int64  `json:"attrLength"      xorm:"'attr_length'     bigint         comment('attrLength')   "`
-	AttrDecimals int64  `json:"attrDecimals"    xorm:"'attr_decimals'   bigint         comment('attrDecimals') "`
-	Comment      string `json:"comment"         xorm:"'comment'         varchar(255)   comment('描述')          "`
-	IsFixed      int64  `json:"isFixed"         xorm:"'is_fixed'        int            comment('是否可修改')     "`
-	IsNotNull    int64  `json:"isNotNull"       xorm:"'is_not_null'     int            comment('是否可修改')     "`
-	IsPKey       int64  `json:"isPKey"          xorm:"'is_pkey'         int            comment('是否可修改')     "`
-	SortNo       int64  `json:"sortNo"          xorm:"'sort_no'         int            comment('是否可修改')     "`
+	ModelId         int64  `json:"modelId"         xorm:"'model_id'             bigint      pk comment('主键ID')        "`
+	ObjectId        int64  `json:"objectId"        xorm:"'object_id'            bigint      pk comment('主键ID')        "`
+	AttrId          int64  `json:"attrId"          xorm:"'attr_id'              bigint      pk comment('主键ID')        "`
+	AttrTitle       string `json:"attrTitle"       xorm:"'attr_title'           varchar(127)   comment('AttrTitle')    "`
+	AttrCode        string `json:"attrCode"        xorm:"'attr_code'            varchar(127)   comment('AttrCode')     "`
+	JsonCode        string `json:"jsonCode"        xorm:"'json_code'            varchar(127)   comment('JsonCode')     "`
+	StructCode      string `json:"structCode"      xorm:"'struct_code'          varchar(127)   comment('StructCode')   "`
+	AttrType        int64  `json:"attrType"        xorm:"'attr_type'            bigint         comment('Type')         "`
+	AttrLength      int64  `json:"attrLength"      xorm:"'attr_length'          bigint         comment('attrLength')   "`
+	AttrDecimals    int64  `json:"attrDecimals"    xorm:"'attr_decimals'        bigint         comment('attrDecimals') "`
+	Comment         string `json:"comment"         xorm:"'comment'              varchar(255)   comment('描述')         "`
+	IsFixed         int64  `json:"isFixed"         xorm:"'is_fixed'             int            comment('是否可修改')    "`
+	IsNotNull       int64  `json:"isNotNull"       xorm:"'is_not_null'          int            comment('是否可修改')    "`
+	IsPKey          int64  `json:"isPKey"          xorm:"'is_pkey'              int            comment('是否可修改')    "`
+	SortNo          int64  `json:"sortNo"          xorm:"'sort_no'              int            comment('是否可修改')    "`
 }
 
 func (t *ModelObjectAttrInfo) TableName() string {

+ 23 - 20
web/controllers/api_controller.go

@@ -12,22 +12,27 @@ type ApiController struct {
 }
 
 func (c *ApiController) BeforeActivation(b mvc.BeforeActivation) {
-    b.Handle("GET",         "/",                                                           "GetList"       )
-    b.Handle("GET",         "/page",                                                       "GetPage"       )
-    b.Handle("GET",         "/{moduleId:int64}/{apiId:int64}",                             "GetById"       )
-    b.Handle("POST",        "/add",                                                        "Create"        )
-    b.Handle("PUT",         "/update",                                                     "Update"        )
-    b.Handle("PUT",         "/updateStatus/{moduleId:int64}/{apiId:int64}/{status:int64}", "UpdateStatus"  )
-    b.Handle("DELETE",      "/{moduleId:int64}/{apiId:int64}",                             "DeleteByID"    )
+    b.Handle("GET",         "/",                                            "GetList"       )
+    b.Handle("GET",         "/page",                                        "GetPage"       )
+    b.Handle("GET",         "/{apiId:int64}",                               "GetById"       )
+    b.Handle("POST",        "/add",                                         "Create"        )
+    b.Handle("PUT",         "/update",                                      "Update"        )
+    b.Handle("PUT",         "/updateStatus/{apiId:int64}/{status:int64}",   "UpdateStatus"  )
+    b.Handle("DELETE",      "/{apiId:int64}",                               "DeleteByID"    )
 }
 
 func (c *ApiController) GetList() *JsonResult {
     params   := c.buildParams()
-    moduleId := c.Ctx.URLParamInt64Default("moduleId", 0)
-    if moduleId <= 0 {
-        return ResultErr("参数不完整", nil)
+    bizId := c.Ctx.URLParamInt64Default("bizId", 0)
+    if bizId > 0 {
+        params["bizId"] = bizId
+    }
+    
+    objectId := c.Ctx.URLParamInt64Default("objectId", 0)
+    if objectId > 0 {
+        params["objectId"] = objectId
     }
-    params["moduleId"] = moduleId
+    
     data, err := c.Service.GetList(params)
     if err != nil {
         return ResultErr(err.Error(), nil)
@@ -38,12 +43,11 @@ func (c *ApiController) GetList() *JsonResult {
 
 func (c *ApiController) GetPage() *JsonResult {
     params   := c.buildParams()
-    moduleId := c.Ctx.URLParamInt64Default("moduleId", 0)
-    if moduleId <= 0 {
+    bizId := c.Ctx.URLParamInt64Default("bizId", 0)
+    if bizId <= 0 {
         return ResultErr("参数不完整", nil)
     }
     
-    params["moduleId"] = moduleId
     data, err := c.Service.GetPage(params)
     if err != nil {
         return ResultErr(err.Error(), nil)
@@ -52,8 +56,8 @@ func (c *ApiController) GetPage() *JsonResult {
     }
 }
 
-func (c *ApiController) GetById(moduleId, apiId int64) *JsonResult {
-    data, err := c.Service.GetById(moduleId, apiId)
+func (c *ApiController) GetById(apiId int64) *JsonResult {
+    data, err := c.Service.GetById(apiId)
     if err != nil {
         return ResultErr(err.Error(), nil)
     } else {
@@ -91,19 +95,18 @@ func (c *ApiController) Update() *JsonResult {
     }
 }
 
-func (c *ApiController) UpdateStatus(moduleId, apiId, status int64)*JsonResult{
-    if err := c.Service.ChangeStatus(moduleId, apiId, status); err != nil {
+func (c *ApiController) UpdateStatus(apiId, status int64)*JsonResult{
+    if err := c.Service.ChangeStatus(apiId, status); err != nil {
         return ResultErr(err.Error(), nil)
     } else {
         return ResultOk("状态变更成功", nil)
     }
 }
 
-func (c *ApiController) DeleteByID(moduleId, apiId int64) *JsonResult {
+func (c *ApiController) DeleteByID(apiId int64) *JsonResult {
     userId := c.GetCurUserId()
     
     m := make(map[string]interface{})
-    m["moduleId"]  = moduleId
     m["apiId"]     = apiId
     m["deletedBy"] = userId
     if err := c.Service.Delete(m); err != nil {

+ 0 - 96
web/controllers/api_module_controller.go

@@ -1,96 +0,0 @@
-package controllers
-
-import (
-    "github.com/kataras/iris/v12/mvc"
-    "xps/datamodels"
-    "xps/service"
-)
-
-type ApiModuleController struct {
-    Base
-    Service service.ApiModuleService
-}
-
-func (c *ApiModuleController) BeforeActivation(b mvc.BeforeActivation) {
-    b.Handle("GET",         "/",                        "GetList"   )
-    b.Handle("GET",         "/page",                    "GetPage"   )
-    b.Handle("GET",         "/{moduleId:int64}",        "GetById"   )
-    b.Handle("POST",        "/add",                     "Create"    )
-    b.Handle("PUT",         "/update",                  "Update"    )
-    b.Handle("DELETE",      "/{moduleId:int64}",        "DeleteByID")
-}
-
-func (c *ApiModuleController) GetList() *JsonResult {
-    params    := c.buildParams()
-    data, err := c.Service.GetList(params)
-    if err != nil {
-        return ResultErr(err.Error(), nil)
-    } else {
-        return ResultOk("获取成功", data)
-    }
-}
-
-func (c *ApiModuleController) GetPage() *JsonResult {
-    params    := c.buildParams()
-    data, err := c.Service.GetPage(params)
-    if err != nil {
-        return ResultErr(err.Error(), nil)
-    } else {
-        return ResultOk("获取成功", data)
-    }
-}
-
-func (c *ApiModuleController) GetById(moduleId int64) *JsonResult {
-    
-    data, err := c.Service.GetById(moduleId)
-    if err != nil {
-        return ResultErr(err.Error(), nil)
-    } else {
-        return ResultOk("获取成功", data)
-    }
-}
-
-func (c *ApiModuleController) Create() *JsonResult {
-    userId := c.GetCurUserId()
-    
-    module := datamodels.ApiModule{}
-    module.CreatedBy = userId
-    if err := c.Ctx.ReadJSON(&module); err != nil {
-        return ResultErr("读取数据失败", nil)
-    }
-    
-    if err := c.Service.Create(&module); err != nil {
-        return ResultErr(err.Error(), nil)
-    } else {
-        return ResultOk("新增成功", nil)
-    }
-}
-
-func (c *ApiModuleController) Update() *JsonResult {
-    userId := c.GetCurUserId()
-    
-    module := datamodels.ApiModule{}
-    if err := c.Ctx.ReadJSON(&module); err != nil {
-        return ResultErr("读取数据失败", nil)
-    }
-    
-    module.UpdatedBy = userId
-    if err := c.Service.Update(&module); err != nil {
-        return ResultErr(err.Error(), nil)
-    } else {
-        return ResultOk("更新成功", nil)
-    }
-}
-
-func (c *ApiModuleController) DeleteByID(moduleId int64) *JsonResult {
-    userId := c.GetCurUserId()
-    
-    m := make(map[string]interface{})
-    m["moduleId"]  = moduleId
-    m["deletedBy"] = userId
-    if err := c.Service.Delete(m); err != nil {
-        return ResultErr(err.Error(), nil)
-    } else {
-        return ResultOk("删除成功", nil)
-    }
-}

+ 6 - 6
web/controllers/app_controller.go

@@ -12,12 +12,12 @@ type AppController struct {
 }
 
 func (c *AppController) BeforeActivation(b mvc.BeforeActivation) {
-	b.Handle("GET",         "/",                    "GetList"   )
-	b.Handle("GET",         "/page",                "GetPage"   )
-	b.Handle("GET",         "/{appId:int64}",       "GetById"   )
-	b.Handle("POST",        "/add",                 "Create"    )
-	b.Handle("PUT",         "/update",              "Update"    )
-	b.Handle("DELETE",      "/{appId:int64}",       "DeleteByID")
+	b.Handle("GET",         "/",                     "GetList"   )
+	b.Handle("GET",         "/page",                 "GetPage"   )
+	b.Handle("GET",         "/{appId:int64}",        "GetById"   )
+	b.Handle("POST",        "/add",                  "Create"    )
+	b.Handle("PUT",         "/update",               "Update"    )
+	b.Handle("DELETE",      "/{appId:int64}",        "DeleteByID")
 }
 
 func (c *AppController) GetList() *JsonResult {

+ 1 - 1
web/controllers/base_controller.go

@@ -83,7 +83,7 @@ func (b *Base) buildParams() map[string]interface{} {
 	}
 	
 	params := make(map[string]interface{})
-	params["ocId"] = ocId
+	params["ocId"]   = ocId
 	params["userId"] = userId
 	groupId := b.Ctx.URLParamInt64Default("groupId", 0)
 	if groupId > 0 {

+ 0 - 5
web/router/routes.go

@@ -218,11 +218,6 @@ func Configure(b *bootstrap.Bootstrapper) {
 	apiParty := b.Party("/api", crs).AllowMethods(iris.MethodOptions)
 	{
 		apiParty.Use(middleware.AuthToken)
-		apiModuleService := service.NewApiModuleService()
-		apiModuleApp := mvc.New(apiParty.Party("/module"))
-		apiModuleApp.Register(apiModuleService)
-		apiModuleApp.Handle(new(controllers.ApiModuleController))
-		
 		apiService := service.NewApiService()
 		apiApp := mvc.New(apiParty.Party(""))
 		apiApp.Register(apiService)