Ver código fonte

修改终端权限接口BUG

zhou.xiaoning 4 anos atrás
pai
commit
ded4aec4bf
7 arquivos alterados com 143 adições e 69 exclusões
  1. 4 4
      controllers/ermcp/qryUser.go
  2. 46 19
      docs/docs.go
  3. 46 19
      docs/swagger.json
  4. 34 14
      docs/swagger.yaml
  5. 4 4
      models/common.go
  6. 8 8
      models/ermcpUser.go
  7. 1 1
      routers/router.go

+ 4 - 4
controllers/ermcp/qryUser.go

@@ -62,11 +62,11 @@ type GetErmcpRolefuncMenuReq struct {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param loginID query int true "登录账号"
-// @Success 200 {object} models.Rolefuncmenu
+// @Success 200 {object} models.Funcmenulist
 // @Failure 500 {object} app.Response
-// @Router /Ermcp/GetErmcpRolefuncMenu [get]
+// @Router /Ermcp/GetErmcpRoleFuncMenuLists [get]
 // @Tags 企业风险管理(app)
-func GetErmcpRolefuncMenu(c *gin.Context) {
+func GetErmcpRoleFuncMenuLists(c *gin.Context) {
 	appG := app.Gin{C: c}
 
 	// 获取请求参数
@@ -78,7 +78,7 @@ func GetErmcpRolefuncMenu(c *gin.Context) {
 	}
 
 	// 获取数据
-	rst, err := models.GetErmcpRolefuncMenu(req.LoginID)
+	rst, err := models.GetErmcpRoleFuncMenuLists(req.LoginID)
 	if err != nil {
 		// 查询失败
 		logger.GetLogger().Errorf("GetErmcpRolefuncMenu failed: %s", err.Error())

+ 46 - 19
docs/docs.go

@@ -828,7 +828,7 @@ var doc = `{
                 }
             }
         },
-        "/Ermcp/GetErmcpRolefuncMenu": {
+        "/Ermcp/GetErmcpRoleFuncMenuLists": {
             "get": {
                 "security": [
                     {
@@ -855,7 +855,7 @@ var doc = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.Rolefuncmenu"
+                            "$ref": "#/definitions/models.Funcmenulist"
                         }
                     },
                     "500": {
@@ -12452,6 +12452,50 @@ var doc = `{
                 }
             }
         },
+        "models.Funcmenulist": {
+            "type": "object",
+            "required": [
+                "resourcecode"
+            ],
+            "properties": {
+                "iconame": {
+                    "description": "菜单图标",
+                    "type": "string"
+                },
+                "menutype": {
+                    "description": "菜单类型 1-管理端 2-交易端 3-终端权限",
+                    "type": "integer"
+                },
+                "parentcode": {
+                    "description": "上级资源代码",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "resourcecode": {
+                    "description": "资源代码",
+                    "type": "string"
+                },
+                "resourcelevel": {
+                    "description": "级别 1-一级 2-二级 3-三级 4-四级",
+                    "type": "integer"
+                },
+                "resourcename": {
+                    "description": "资源名",
+                    "type": "string"
+                },
+                "sort": {
+                    "description": "排序 - 一级时,是所有一级菜单的排序顺序;二级时是所属同一个一级菜单下的排序、三级时是同一个二级菜单下的排序",
+                    "type": "integer"
+                },
+                "url": {
+                    "description": "URL",
+                    "type": "string"
+                }
+            }
+        },
         "models.Goods": {
             "type": "object",
             "required": [
@@ -15323,23 +15367,6 @@ var doc = `{
                 }
             }
         },
-        "models.Rolefuncmenu": {
-            "type": "object",
-            "required": [
-                "resourcecode",
-                "roleid"
-            ],
-            "properties": {
-                "resourcecode": {
-                    "description": "菜单代码",
-                    "type": "string"
-                },
-                "roleid": {
-                    "description": "角色权限ID",
-                    "type": "integer"
-                }
-            }
-        },
         "models.SearchGoods": {
             "type": "object",
             "required": [

+ 46 - 19
docs/swagger.json

@@ -812,7 +812,7 @@
                 }
             }
         },
-        "/Ermcp/GetErmcpRolefuncMenu": {
+        "/Ermcp/GetErmcpRoleFuncMenuLists": {
             "get": {
                 "security": [
                     {
@@ -839,7 +839,7 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/models.Rolefuncmenu"
+                            "$ref": "#/definitions/models.Funcmenulist"
                         }
                     },
                     "500": {
@@ -12436,6 +12436,50 @@
                 }
             }
         },
+        "models.Funcmenulist": {
+            "type": "object",
+            "required": [
+                "resourcecode"
+            ],
+            "properties": {
+                "iconame": {
+                    "description": "菜单图标",
+                    "type": "string"
+                },
+                "menutype": {
+                    "description": "菜单类型 1-管理端 2-交易端 3-终端权限",
+                    "type": "integer"
+                },
+                "parentcode": {
+                    "description": "上级资源代码",
+                    "type": "string"
+                },
+                "remark": {
+                    "description": "备注",
+                    "type": "string"
+                },
+                "resourcecode": {
+                    "description": "资源代码",
+                    "type": "string"
+                },
+                "resourcelevel": {
+                    "description": "级别 1-一级 2-二级 3-三级 4-四级",
+                    "type": "integer"
+                },
+                "resourcename": {
+                    "description": "资源名",
+                    "type": "string"
+                },
+                "sort": {
+                    "description": "排序 - 一级时,是所有一级菜单的排序顺序;二级时是所属同一个一级菜单下的排序、三级时是同一个二级菜单下的排序",
+                    "type": "integer"
+                },
+                "url": {
+                    "description": "URL",
+                    "type": "string"
+                }
+            }
+        },
         "models.Goods": {
             "type": "object",
             "required": [
@@ -15307,23 +15351,6 @@
                 }
             }
         },
-        "models.Rolefuncmenu": {
-            "type": "object",
-            "required": [
-                "resourcecode",
-                "roleid"
-            ],
-            "properties": {
-                "resourcecode": {
-                    "description": "菜单代码",
-                    "type": "string"
-                },
-                "roleid": {
-                    "description": "角色权限ID",
-                    "type": "integer"
-                }
-            }
-        },
         "models.SearchGoods": {
             "type": "object",
             "required": [

+ 34 - 14
docs/swagger.yaml

@@ -4451,6 +4451,38 @@ definitions:
     required:
     - autoid
     type: object
+  models.Funcmenulist:
+    properties:
+      iconame:
+        description: 菜单图标
+        type: string
+      menutype:
+        description: 菜单类型 1-管理端 2-交易端 3-终端权限
+        type: integer
+      parentcode:
+        description: 上级资源代码
+        type: string
+      remark:
+        description: 备注
+        type: string
+      resourcecode:
+        description: 资源代码
+        type: string
+      resourcelevel:
+        description: 级别 1-一级 2-二级 3-三级 4-四级
+        type: integer
+      resourcename:
+        description: 资源名
+        type: string
+      sort:
+        description: 排序 - 一级时,是所有一级菜单的排序顺序;二级时是所属同一个一级菜单下的排序、三级时是同一个二级菜单下的排序
+        type: integer
+      url:
+        description: URL
+        type: string
+    required:
+    - resourcecode
+    type: object
   models.Goods:
     properties:
       agreeunit:
@@ -6625,18 +6657,6 @@ definitions:
         description: 商品名称
         type: string
     type: object
-  models.Rolefuncmenu:
-    properties:
-      resourcecode:
-        description: 菜单代码
-        type: string
-      roleid:
-        description: 角色权限ID
-        type: integer
-    required:
-    - resourcecode
-    - roleid
-    type: object
   models.SearchGoods:
     properties:
       goodscode:
@@ -9748,7 +9768,7 @@ paths:
       summary: 查询企业风管期货商品信息
       tags:
       - 企业风险管理(app)
-  /Ermcp/GetErmcpRolefuncMenu:
+  /Ermcp/GetErmcpRoleFuncMenuLists:
     get:
       parameters:
       - description: 登录账号
@@ -9762,7 +9782,7 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/models.Rolefuncmenu'
+            $ref: '#/definitions/models.Funcmenulist'
         "500":
           description: Internal Server Error
           schema:

+ 4 - 4
models/common.go

@@ -11,15 +11,15 @@ import (
 
 // Funcmenulist 功能菜单表
 type Funcmenulist struct {
-	Resourcecode  string `json:"resourcecode"  xorm:"'RESOURCECODE'" binding:"required"` // 资源代码 - M001 一级菜单编码   0001 二级菜单编码   0001 三级菜单M00100000000  系统管理M00100010000  参数管理M00100010001  参数管理--修改M00100010002  参数管理--删除M00100020000  区域管理
+	Resourcecode  string `json:"resourcecode"  xorm:"'RESOURCECODE'" binding:"required"` // 资源代码
 	Resourcename  string `json:"resourcename"  xorm:"'RESOURCENAME'"`                    // 资源名
-	Resourcelevel uint32 `json:"resourcelevel"  xorm:"'RESOURCELEVEL'"`                  // 级别1-一级 2-二级 3-三级4-四级
-	Menutype      uint32 `json:"menutype"  xorm:"'MENUTYPE'"`                            // 1- 管理端   2-  交易端 3 - 已失效
+	Resourcelevel uint32 `json:"resourcelevel"  xorm:"'RESOURCELEVEL'"`                  // 级别 1-一级 2-二级 3-三级 4-四级
+	Menutype      uint32 `json:"menutype"  xorm:"'MENUTYPE'"`                            // 菜单类型 1-管理端 2-交易端 3-终端权限
 	Parentcode    string `json:"parentcode"  xorm:"'PARENTCODE'"`                        // 上级资源代码
 	URL           string `json:"url"  xorm:"'URL'"`                                      // URL
 	Sort          uint32 `json:"sort"  xorm:"'SORT'"`                                    // 排序 - 一级时,是所有一级菜单的排序顺序;二级时是所属同一个一级菜单下的排序、三级时是同一个二级菜单下的排序
 	Iconame       string `json:"iconame"  xorm:"'ICONAME'"`                              // 菜单图标
-	Remark        string `json:"remark"  xorm:"'REMARK'"`                                // Remark
+	Remark        string `json:"remark"  xorm:"'REMARK'"`                                // 备注
 }
 
 // TableName is FUNCMENULIST

+ 8 - 8
models/ermcpUser.go

@@ -179,15 +179,15 @@ func (r *ErmcpUserModel) GetData(queryType int32) ([]ErmcpUserModel, error) {
 	return sData, nil
 }
 
-// GetErmcpRolefuncMenu 获取企业风管终端权限
-func GetErmcpRolefuncMenu(loginID int) ([]Rolefuncmenu, error) {
-	roleFuncMenus := make([]Rolefuncmenu, 0)
-	if err := db.GetEngine().Table("ROLEFUNCMENU R").
-		Join("INNER", "LOGINACCOUNT L", "L.CLIENTROLEID = R.ROLEID").
-		Where("L.LOGINID = ?", loginID).
-		Find(&roleFuncMenus); err != nil {
+// GetErmcpRoleFuncMenuLists 获取企业风管终端权限
+func GetErmcpRoleFuncMenuLists(loginID int) ([]Funcmenulist, error) {
+	funcMenuLists := make([]Funcmenulist, 0)
+
+	sql := fmt.Sprintf(`select F.* from FUNCMENULIST F where F.MENUTYPE = 3 
+						and F.RESOURCECODE in (select R.RESOURCECODE from ROLEFUNCMENU R inner join LOGINACCOUNT L on L.CLIENTROLEID = R.ROLEID where L.LOGINID = %d)`, loginID)
+	if err := db.GetEngine().SQL(sql).Find(&funcMenuLists); err != nil {
 		return nil, err
 	}
 
-	return roleFuncMenus, nil
+	return funcMenuLists, nil
 }

+ 1 - 1
routers/router.go

@@ -378,7 +378,7 @@ func InitRouter() *gin.Engine {
 
 		// 权限相关
 		// 获取企业风管终端权限
-		ermcpR.GET("/GetErmcpRolefuncMenu", ermcp.GetErmcpRolefuncMenu)
+		ermcpR.GET("/GetErmcpRoleFuncMenuLists", ermcp.GetErmcpRoleFuncMenuLists)
 	}
 
 	return r