Преглед на файлове

增加新的“获取终端菜单”接口

zhou.xiaoning преди 3 години
родител
ревизия
4cd18217a0
променени са 6 файла, в които са добавени 197 реда и са изтрити 8 реда
  1. 39 1
      controllers/common/menu.go
  2. 56 1
      docs/docs.go
  3. 56 1
      docs/swagger.json
  4. 36 1
      docs/swagger.yaml
  5. 9 4
      models/common.go
  6. 1 0
      routers/router.go

+ 39 - 1
controllers/common/menu.go

@@ -383,7 +383,8 @@ func toString(v interface{}) string {
 // @Param resourcecode query string false "资源代码"
 // @Param parentcode query string false "上级资源代码"
 // @Param resourcename query string false "资源名(Title), 模糊查询"
-// @Success 200 {object} app.Response
+// @Param menutype query string false "菜单类型(格式:1,2,3) - 1:管理端 2:PC(C#) 3:移动(云平台) 4:终端(交易所) 5:PC(云平台)"
+// @Success 200 {array} models.NewFuncmenulist
 // @Failure 500 {object} app.Response
 // @Router /Common/FindNewFuncmenu [get]
 // @Tags 通用服务
@@ -513,3 +514,40 @@ func DeleteNewFuncmenu(c *gin.Context) {
 	logger.GetLogger().Debugln("DeleteNewFuncmenu successed")
 	appG.Response(http.StatusOK, e.SUCCESS, struct{}{})
 }
+
+type GetClientNewFuncmenuReq struct {
+	LoginID int `form:"loginid" binding:"required"`
+}
+
+// FindNewFuncmenu 获取终端菜单
+// @Summary 获取终端菜单
+// @Produce json
+// @Security ApiKeyAuth
+// @Param loginid query int true "登录账号"
+// @Success 200 {array} models.NewFuncmenulist
+// @Failure 500 {object} app.Response
+// @Router /Common/GetClientNewFuncmenu [get]
+// @Tags 通用服务
+func GetClientNewFuncmenu(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req GetClientNewFuncmenuReq
+	if err := appG.C.ShouldBindQuery(&req); err != nil {
+		logger.GetLogger().Errorf("GetClientNewFuncmenu failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	rst, err := models.GetErmcpRoleFuncMenuLists(req.LoginID, "")
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("GetClientNewFuncmenu failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 查询成功
+	logger.GetLogger().Debugln("GetClientNewFuncmenu successed")
+	appG.Response(http.StatusOK, e.SUCCESS, rst)
+}

+ 56 - 1
docs/docs.go

@@ -444,13 +444,22 @@ var doc = `{
                         "description": "资源名(Title), 模糊查询",
                         "name": "resourcename",
                         "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "菜单类型(格式:1,2,3) - 1:管理端 2:PC(C#) 3:移动(云平台) 4:终端(交易所) 5:PC(云平台)",
+                        "name": "menutype",
+                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/app.Response"
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.NewFuncmenulist"
+                            }
                         }
                     },
                     "500": {
@@ -550,6 +559,48 @@ var doc = `{
                 }
             }
         },
+        "/Common/GetClientNewFuncmenu": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "获取终端菜单",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "登录账号",
+                        "name": "loginid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.NewFuncmenulist"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/GetDivisions": {
             "get": {
                 "produces": [
@@ -31822,6 +31873,10 @@ var doc = `{
                     "description": "权限类型 - 1:菜单 2:组件 3:按钮",
                     "type": "integer"
                 },
+                "buttonname": {
+                    "description": "按钮名称",
+                    "type": "string"
+                },
                 "buttontype": {
                     "description": "按钮类型 - 存按钮样式",
                     "type": "string"

+ 56 - 1
docs/swagger.json

@@ -428,13 +428,22 @@
                         "description": "资源名(Title), 模糊查询",
                         "name": "resourcename",
                         "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "菜单类型(格式:1,2,3) - 1:管理端 2:PC(C#) 3:移动(云平台) 4:终端(交易所) 5:PC(云平台)",
+                        "name": "menutype",
+                        "in": "query"
                     }
                 ],
                 "responses": {
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/app.Response"
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.NewFuncmenulist"
+                            }
                         }
                     },
                     "500": {
@@ -534,6 +543,48 @@
                 }
             }
         },
+        "/Common/GetClientNewFuncmenu": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "通用服务"
+                ],
+                "summary": "获取终端菜单",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "登录账号",
+                        "name": "loginid",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/models.NewFuncmenulist"
+                            }
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/Common/GetDivisions": {
             "get": {
                 "produces": [
@@ -31806,6 +31857,10 @@
                     "description": "权限类型 - 1:菜单 2:组件 3:按钮",
                     "type": "integer"
                 },
+                "buttonname": {
+                    "description": "按钮名称",
+                    "type": "string"
+                },
                 "buttontype": {
                     "description": "按钮类型 - 存按钮样式",
                     "type": "string"

+ 36 - 1
docs/swagger.yaml

@@ -11819,6 +11819,9 @@ definitions:
       authtype:
         description: 权限类型 - 1:菜单 2:组件 3:按钮
         type: integer
+      buttonname:
+        description: 按钮名称
+        type: string
       buttontype:
         description: 按钮类型 - 存按钮样式
         type: string
@@ -22118,13 +22121,19 @@ paths:
         in: query
         name: resourcename
         type: string
+      - description: 菜单类型(格式:1,2,3) - 1:管理端 2:PC(C#) 3:移动(云平台) 4:终端(交易所) 5:PC(云平台)
+        in: query
+        name: menutype
+        type: string
       produces:
       - application/json
       responses:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/app.Response'
+            items:
+              $ref: '#/definitions/models.NewFuncmenulist'
+            type: array
         "500":
           description: Internal Server Error
           schema:
@@ -22190,6 +22199,32 @@ paths:
       summary: 获取交易端菜单
       tags:
       - 通用服务
+  /Common/GetClientNewFuncmenu:
+    get:
+      parameters:
+      - description: 登录账号
+        in: query
+        name: loginid
+        required: true
+        type: integer
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            items:
+              $ref: '#/definitions/models.NewFuncmenulist'
+            type: array
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 获取终端菜单
+      tags:
+      - 通用服务
   /Common/GetDivisions:
     get:
       produces:

+ 9 - 4
models/common.go

@@ -813,8 +813,8 @@ func GetRoleFuncMenuLists(loginID int, resourceCode string) ([]Funcmenulist, err
 }
 
 // GetErmcpRoleFuncMenuLists 获取终端权限(企业风管专用,区分企业和企业成员)
-func GetErmcpRoleFuncMenuLists(loginID int, resourceCode string) ([]Funcmenulist, error) {
-	funcMenuLists := make([]Funcmenulist, 0)
+func GetErmcpRoleFuncMenuLists(loginID int, resourceCode string) ([]NewFuncmenulist, error) {
+	funcMenuLists := make([]NewFuncmenulist, 0)
 
 	// 获取对应的Loginaccount信息
 	var loginAccount Loginaccount
@@ -894,7 +894,7 @@ func GetErmcpRoleFuncMenuLists(loginID int, resourceCode string) ([]Funcmenulist
 			}
 			if len(areaRoles) == 0 {
 				// 无角色,返回空数组s
-				return make([]Funcmenulist, 0), nil
+				return make([]NewFuncmenulist, 0), nil
 			}
 			// 构建RoleID列表
 			roleIDs := ""
@@ -985,12 +985,14 @@ type NewFuncmenulist struct {
 	COMPONENT     *string `json:"component"  xorm:"COMPONENT"`                          // 组件名或组件地址
 	BUTTONTYPE    *string `json:"buttontype"  xorm:"BUTTONTYPE"`                        // 按钮类型 - 存按钮样式
 	HIDDEN        *int32  `json:"hidden"  xorm:"HIDDEN"`                                // 是否隐藏 - 0:显示 1:隐藏
+	BUTTONNAME    *string `json:"buttonname"  xorm:"BUTTONNAME"`                        // 按钮名称
 }
 
 type NewFuncmenulistReq struct {
 	RESOURCECODE string `form:"resourcecode"` // 资源代码
 	PARENTCODE   string `form:"parentcode"`   // 上级资源代码
 	RESOURCENAME string `form:"resourcename"` // 资源名(Title), 模糊查询
+	MENUTYPE     string `form:"menutype"`     // 菜单类型(格式:1,2,3) - 1:管理端 2:PC(C#) 3:移动(云平台) 4:终端(交易所) 5:PC(云平台)
 }
 
 // TableName is FUNCMENULIST
@@ -1000,7 +1002,7 @@ func (r *NewFuncmenulist) TableName() string {
 
 func (r *NewFuncmenulist) Find(req NewFuncmenulistReq) ([]NewFuncmenulist, error) {
 	funcMenuLists := make([]NewFuncmenulist, 0)
-	session := db.GetEngine().Table("FUNCMENULIST T").Where("T.MENUTYPE = 5")
+	session := db.GetEngine().Table("FUNCMENULIST T")
 	if len(req.RESOURCECODE) != 0 {
 		session = session.And("T.RESOURCECODE = ?", req.RESOURCECODE)
 	}
@@ -1010,6 +1012,9 @@ func (r *NewFuncmenulist) Find(req NewFuncmenulistReq) ([]NewFuncmenulist, error
 	if len(req.RESOURCENAME) != 0 {
 		session = session.And("T.RESOURCENAME LIKE ?", "%"+req.RESOURCENAME+"%")
 	}
+	if len(req.MENUTYPE) != 0 {
+		session = session.And(fmt.Sprintf("T.MENUTYPE in (%s)", req.MENUTYPE))
+	}
 	if err := session.Find(&funcMenuLists); err != nil {
 		return nil, err
 	}

+ 1 - 0
routers/router.go

@@ -137,6 +137,7 @@ func InitRouter() *gin.Engine {
 		// 获取PCWeb交易端菜单(V6版本之后使用)
 		commonR.Use(token.Auth()).GET("/GetPCWebMenus", common.GetPCWebMenus)
 
+		// 这四个接口不开放给一般操作人员使用
 		commonR.Use(token.Auth()).GET("/FindNewFuncmenu", common.FindNewFuncmenu)
 		commonR.Use(token.Auth()).POST("/InsertNewFuncmenu", common.InsertNewFuncmenu)
 		commonR.Use(token.Auth()).PUT("/UpdateNewFuncmenu", common.UpdateNewFuncmenu)