Explorar o código

1. 查询菜单权限增加类型参数

zou.yingbin %!s(int64=4) %!d(string=hai) anos
pai
achega
5b22926c73
Modificáronse 5 ficheiros con 67 adicións e 20 borrados
  1. 7 3
      controllers/ermcp/qryAccMgr.go
  2. 12 0
      docs/docs.go
  3. 12 0
      docs/swagger.json
  4. 8 0
      docs/swagger.yaml
  5. 28 17
      models/ermcpAccMgr.go

+ 7 - 3
controllers/ermcp/qryAccMgr.go

@@ -102,8 +102,9 @@ func QueryAccMgrRole(c *gin.Context) {
 
 // QryRoleMenuReq
 type QryRoleMenuReq struct {
-	UserId int64  `form:"userid" binding:"required"` // 用户id
-	RoleId string `form:"roleid"`                    // 角色id(可多个,逗号隔开)
+	UserId   int64  `form:"userid" binding:"required"` // 用户id
+	RoleId   string `form:"roleid"`                    // 角色id(可多个,逗号隔开)
+	MENUTYPE int32  `form:"menutype"`                  // 菜单类型
 }
 
 // QueryAccMgrRoleMenu
@@ -112,6 +113,7 @@ type QryRoleMenuReq struct {
 // @Security ApiKeyAuth
 // @Param userid query int true "用户ID"
 // @Param roleid query string false "角色id(可多个,逗号隔开)"
+// @Param menutype query int false "菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易 ps:新加的参数,为了兼容以前,不传则默认查3"
 // @Success 200 {array} models.ErmcpRoleMenuEx
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryAccMgrRoleMenu [get]
@@ -120,7 +122,8 @@ func QueryAccMgrRoleMenu(c *gin.Context) {
 	a := app.GinUtils{Gin: app.Gin{C: c}}
 	req := QryRoleMenuReq{}
 	a.DoBindReq(&req)
-	m := models.ErmcpRoleMenu{USERID: mtpcache.GetAreaUserId(req.UserId, 0), FilterRoleId: req.RoleId}
+	m := models.ErmcpRoleMenu{USERID: mtpcache.GetAreaUserId(req.UserId, 0),
+		FilterRoleId: req.RoleId, MENUTYPE: req.MENUTYPE}
 	a.DoGetDataI(&m)
 }
 
@@ -129,6 +132,7 @@ func QueryAccMgrRoleMenu(c *gin.Context) {
 // @Produce json
 // @Security ApiKeyAuth
 // @Param loginid query int true "登录ID"
+// @Param menutype query int false "菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易"
 // @Success 200 {array} models.RoleMenu
 // @Failure 500 {object} app.Response
 // @Router /Ermcp/QueryRoleMenu [get]

+ 12 - 0
docs/docs.go

@@ -1218,6 +1218,12 @@ var doc = `{
                         "description": "角色id(可多个,逗号隔开)",
                         "name": "roleid",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易 ps:新加的参数,为了兼容以前,不传则默认查3",
+                        "name": "menutype",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2818,6 +2824,12 @@ var doc = `{
                         "name": "loginid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易",
+                        "name": "menutype",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 12 - 0
docs/swagger.json

@@ -1202,6 +1202,12 @@
                         "description": "角色id(可多个,逗号隔开)",
                         "name": "roleid",
                         "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易 ps:新加的参数,为了兼容以前,不传则默认查3",
+                        "name": "menutype",
+                        "in": "query"
                     }
                 ],
                 "responses": {
@@ -2802,6 +2808,12 @@
                         "name": "loginid",
                         "in": "query",
                         "required": true
+                    },
+                    {
+                        "type": "integer",
+                        "description": "菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易",
+                        "name": "menutype",
+                        "in": "query"
                     }
                 ],
                 "responses": {

+ 8 - 0
docs/swagger.yaml

@@ -16772,6 +16772,10 @@ paths:
         in: query
         name: roleid
         type: string
+      - description: 菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易 ps:新加的参数,为了兼容以前,不传则默认查3
+        in: query
+        name: menutype
+        type: integer
       produces:
       - application/json
       responses:
@@ -17775,6 +17779,10 @@ paths:
         name: loginid
         required: true
         type: integer
+      - description: 菜单类型 1:管理端 2:交易端 3:终端(企业云平台) 4:仓单贸易
+        in: query
+        name: menutype
+        type: integer
       produces:
       - application/json
       responses:

+ 28 - 17
models/ermcpAccMgr.go

@@ -593,7 +593,7 @@ func (r *ErmcpRoleMenu) buildSql() string {
 		"       f.remark" +
 		"  from ermcp_memberfuncmenu t" +
 		" inner join funcmenulist f" +
-		"    on t.resourcecode = f.resourcecode and f.menutype = 3" +
+		"    on t.resourcecode = f.resourcecode and f.menutype = %v" +
 		" where t.isvalid = 1"
 	if r.USERID > 0 {
 		sqlId.And("t.userid", r.USERID)
@@ -601,6 +601,10 @@ func (r *ErmcpRoleMenu) buildSql() string {
 	if len(r.FilterRoleId) > 0 {
 		sqlId.Join(fmt.Sprintf(" and t.roleid in(%v)", r.FilterRoleId))
 	}
+	if r.MENUTYPE == 0 {
+		r.MENUTYPE = 3
+	}
+	sqlId.FormatParam(r.MENUTYPE)
 	sqlId.Join(" order by f.resourcelevel, f.sort")
 
 	return sqlId.String()
@@ -624,12 +628,16 @@ func (r *ErmcpRoleMenu) GetDataEx() (interface{}, error) {
 		"       f.iconame," +
 		"       f.remark" +
 		" from funcmenulist f" +
-		" where f.menutype = 3 and f.resourcelevel <> 0"
+		" where f.resourcelevel <> 0"
+	if r.MENUTYPE == 0 {
+		r.MENUTYPE = 3
+	}
+	sql += fmt.Sprintf(" and f.menutype = %v", r.MENUTYPE)
 	_ = db.GetEngine().SQL(sql).Find(&sData)
 	// 先创建PARENTCODE为空的记录
 	for _, v := range sData {
 		// 特殊处理“铂金宝”菜单,解决4层的问题
-		if v.PARENTCODE == "" || v.PARENTCODE == "client_pc_web_qhj" {
+		if v.PARENTCODE == "" || v.PARENTCODE == "client_pc_web_qhj" || v.RESOURCELEVEL == 1 {
 			sDataEx = append(sDataEx, ErmcpRoleMenuEx{Menu: v, SubMenu: make([]ErmcpRoleMenuEx, 0)})
 		}
 	}
@@ -918,18 +926,18 @@ func (r *ErmcpLoginTaAccount) GetData() ([]ErmcpLoginTaAccount, error) {
 
 // RoleMenu 角色菜单
 type RoleMenu struct {
-	USERID        int64  `json:"userid"  xorm:"'USERID'"`               // 用户id
-	ROLEID        int32  `json:"roleid"  xorm:"'ROLEID'"`               // 角色id
-	RESOURCECODE  string `json:"resourcecode"  xorm:"'RESOURCECODE'"`   // 菜单代码
-	RESOURCENAME  string `json:"resourcename"  xorm:"'RESOURCENAME'"`   // 菜单名称
-	RESOURCELEVEL int32  `json:"resourcelevel"  xorm:"'RESOURCELEVEL'"` // 级别
-	MENUTYPE      int32  `json:"menutype"  xorm:"'MENUTYPE'"`           // 菜单类型 1:管理端 2:交易端 3:终端(企业云平台)
-	PARENTCODE    string `json:"parentcode"  xorm:"'PARENTCODE'"`       // 上级资源代码
-	URL           string `json:"url"  xorm:"'URL'"`                     // URL
-	SORT          int32  `json:"sort"  xorm:"'SORT'"`                   // 排序
-	ICONAME       string `json:"iconame"  xorm:"'ICONAME'"`             // 菜单图标
-	REMARK        string `json:"remark"  xorm:"'REMARK'"`               // 菜单备注
-	HASRIGHT      int32  `json:"hasright"  xorm:"'HASRIGHT'"`           // 是否有权限 0-没有权限 1-有权限
+	USERID        int64  `json:"userid"  xorm:"'USERID'"`                     // 用户id
+	ROLEID        int32  `json:"roleid"  xorm:"'ROLEID'"`                     // 角色id
+	RESOURCECODE  string `json:"resourcecode"  xorm:"'RESOURCECODE'"`         // 菜单代码
+	RESOURCENAME  string `json:"resourcename"  xorm:"'RESOURCENAME'"`         // 菜单名称
+	RESOURCELEVEL int32  `json:"resourcelevel"  xorm:"'RESOURCELEVEL'"`       // 级别
+	MENUTYPE      int32  `json:"menutype"  xorm:"'MENUTYPE'" form:"menutype"` // 菜单类型 1:管理端 2:交易端 3:终端(企业云平台)
+	PARENTCODE    string `json:"parentcode"  xorm:"'PARENTCODE'"`             // 上级资源代码
+	URL           string `json:"url"  xorm:"'URL'"`                           // URL
+	SORT          int32  `json:"sort"  xorm:"'SORT'"`                         // 排序
+	ICONAME       string `json:"iconame"  xorm:"'ICONAME'"`                   // 菜单图标
+	REMARK        string `json:"remark"  xorm:"'REMARK'"`                     // 菜单备注
+	HASRIGHT      int32  `json:"hasright"  xorm:"'HASRIGHT'"`                 // 是否有权限 0-没有权限 1-有权限
 
 	LOGINID int64 `json:"-" form:"loginid" binding:"required"` // 登录id
 
@@ -987,10 +995,13 @@ func (r *RoleMenu) buildSql() string {
 		"          0" +
 		"       end hasRight" +
 		"  from funcmenulist f" +
-		" where f.menutype = 3" +
+		" where f.menutype = %v" +
 		"   and f.resourcelevel <> 0" +
 		" order by f.resourcelevel, f.sort"
-	sqlId.FormatParam(r.LOGINID)
+	if r.MENUTYPE == 0 {
+		r.MENUTYPE = 3 // 不传参数则默认查3
+	}
+	sqlId.FormatParam(r.LOGINID, r.MENUTYPE)
 	return sqlId.String()
 }