From 30fc5ea20883fdbe7c60a614ad20d5a4005e2282 Mon Sep 17 00:00:00 2001 From: Ryan Su Date: Tue, 13 Sep 2022 09:22:24 +0800 Subject: [PATCH] refactor: menu properties fix: bug in mysql group --- api/api_desc/menu.api | 11 +++++++--- .../menu/getmenuparamlistbymenuidhandler.go | 7 ++++++- .../menu/createorupdatemenuparamlogic.go | 2 +- .../menu/getmenuparamlistbymenuidlogic.go | 2 +- api/internal/types/types.go | 4 ++-- core.yml | 20 ++++++++++++------- docs/simple-admin/en/docs/swagger.md | 2 +- docs/simple-admin/zh-cn/docs/swagger.md | 2 +- rpc/internal/logic/getapilistlogic.go | 2 +- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/api/api_desc/menu.api b/api/api_desc/menu.api index cb0051a7..66c3e8f3 100644 --- a/api/api_desc/menu.api +++ b/api/api_desc/menu.api @@ -131,7 +131,7 @@ type ( // ID ID uint32 `json:"id"` // Menu ID | 菜单ID - MenuID uint32 `json:"menuID"` + MenuId uint32 `json:"menuId"` // Data Type | 数据类型 DataType string `json:"dataType"` // Key | 键 @@ -146,7 +146,7 @@ type ( // in: body BaseInfo // Menu ID | 菜单ID - MenuID uint32 `json:"menuID"` + MenuId uint32 `json:"menuId"` // Data Type | 数据类型 DataType string `json:"dataType"` // Key | 键 @@ -233,8 +233,13 @@ service core { @handler createOrUpdateMenuParam post /menu/param (CreateOrUpdateMenuParamReq) returns (SimpleMsg) - // swagger:route GET /menu/param/list menu getMenuParamListByMenuId + // swagger:route POST /menu/param/list menu getMenuParamListByMenuId // Get menu extra parameters by menu ID | 获取某个菜单的额外参数列表 + // Parameters: + // + name: body + // require: true + // in: body + // type: IDReq // Responses: // 200: MenuParamListByMenuIdResp // 401: SimpleMsg diff --git a/api/internal/handler/menu/getmenuparamlistbymenuidhandler.go b/api/internal/handler/menu/getmenuparamlistbymenuidhandler.go index eac24b3f..f34757d3 100644 --- a/api/internal/handler/menu/getmenuparamlistbymenuidhandler.go +++ b/api/internal/handler/menu/getmenuparamlistbymenuidhandler.go @@ -9,8 +9,13 @@ import ( "github.com/zeromicro/go-zero/rest/httpx" ) -// swagger:route GET /menu/param/list menu getMenuParamListByMenuId +// swagger:route POST /menu/param/list menu getMenuParamListByMenuId // Get menu extra parameters by menu ID | 获取某个菜单的额外参数列表 +// Parameters: +// + name: body +// require: true +// in: body +// type: IDReq // Responses: // 200: MenuParamListByMenuIdResp // 401: SimpleMsg diff --git a/api/internal/logic/menu/createorupdatemenuparamlogic.go b/api/internal/logic/menu/createorupdatemenuparamlogic.go index 3ee67b48..aee0596a 100644 --- a/api/internal/logic/menu/createorupdatemenuparamlogic.go +++ b/api/internal/logic/menu/createorupdatemenuparamlogic.go @@ -27,7 +27,7 @@ func NewCreateOrUpdateMenuParamLogic(ctx context.Context, svcCtx *svc.ServiceCon func (l *CreateOrUpdateMenuParamLogic) CreateOrUpdateMenuParam(req *types.CreateOrUpdateMenuParamReq) (resp *types.SimpleMsg, err error) { result, err := l.svcCtx.CoreRpc.CreateOrUpdateMenuParam(l.ctx, &core.CreateOrUpdateMenuParamReq{ Id: uint64(req.ID), - MenuId: uint64(req.MenuID), + MenuId: uint64(req.MenuId), Type: req.DataType, Key: req.Key, Value: req.Value, diff --git a/api/internal/logic/menu/getmenuparamlistbymenuidlogic.go b/api/internal/logic/menu/getmenuparamlistbymenuidlogic.go index 21823183..db3de494 100644 --- a/api/internal/logic/menu/getmenuparamlistbymenuidlogic.go +++ b/api/internal/logic/menu/getmenuparamlistbymenuidlogic.go @@ -35,7 +35,7 @@ func (l *GetMenuParamListByMenuIdLogic) GetMenuParamListByMenuId(req *types.IDRe for _, v := range result.Data { resp.Data = append(resp.Data, types.MenuParamResp{ BaseInfo: types.BaseInfo{ID: uint(v.Id), CreatedAt: v.CreateAt, UpdatedAt: v.UpdateAt}, - MenuID: uint32(v.MenuId), + MenuId: uint32(v.MenuId), DataType: v.Type, Key: v.Key, Value: v.Value, diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 0d3149e8..e98f7c99 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -479,7 +479,7 @@ type CreateOrUpdateMenuParamReq struct { // ID ID uint32 `json:"id"` // Menu ID | 菜单ID - MenuID uint32 `json:"menuID"` + MenuId uint32 `json:"menuId"` // Data Type | 数据类型 DataType string `json:"dataType"` // Key | 键 @@ -493,7 +493,7 @@ type CreateOrUpdateMenuParamReq struct { type MenuParamResp struct { BaseInfo // Menu ID | 菜单ID - MenuID uint32 `json:"menuID"` + MenuId uint32 `json:"menuId"` // Data Type | 数据类型 DataType string `json:"dataType"` // Key | 键 diff --git a/core.yml b/core.yml index 7ca6a8e3..a971dcaf 100644 --- a/core.yml +++ b/core.yml @@ -173,11 +173,11 @@ definitions: description: Key | 键 type: string x-go-name: Key - menuID: + menuId: description: Menu ID | 菜单ID format: uint32 type: integer - x-go-name: MenuID + x-go-name: MenuId value: description: Value | 值 type: string @@ -397,7 +397,7 @@ definitions: description: User's role ID | 用户的角色Id format: uint64 type: integer - x-go-name: RoleID + x-go-name: RoleId username: description: User Name | 用户名 type: string @@ -610,11 +610,11 @@ definitions: description: Key | 键 type: string x-go-name: Key - menuID: + menuId: description: Menu ID | 菜单ID format: uint32 type: integer - x-go-name: MenuID + x-go-name: MenuId updatedAt: description: Update date | 更新日期 format: int64 @@ -1162,9 +1162,15 @@ paths: tags: - menu /menu/param/list: - get: + post: description: Get menu extra parameters by menu ID | 获取某个菜单的额外参数列表 operationId: getMenuParamListByMenuId + parameters: + - in: body + name: body + schema: + $ref: '#/definitions/IDReq' + type: object responses: "200": $ref: '#/responses/MenuParamListByMenuIdResp' @@ -1745,7 +1751,7 @@ responses: key: description: Key | 键 type: string - menuID: + menuId: description: Menu ID | 菜单ID format: uint32 type: integer diff --git a/docs/simple-admin/en/docs/swagger.md b/docs/simple-admin/en/docs/swagger.md index 988e6611..e73205a8 100644 --- a/docs/simple-admin/en/docs/swagger.md +++ b/docs/simple-admin/en/docs/swagger.md @@ -8,7 +8,7 @@ simple-admin-core/ ```shell -swagger generate spec --output=./core.yml +swagger generate spec --output=./core.yml --scan-models swagger serve --no-open -F=swagger --port 36666 core.yaml ``` diff --git a/docs/simple-admin/zh-cn/docs/swagger.md b/docs/simple-admin/zh-cn/docs/swagger.md index a8c1d859..3e54be17 100644 --- a/docs/simple-admin/zh-cn/docs/swagger.md +++ b/docs/simple-admin/zh-cn/docs/swagger.md @@ -8,7 +8,7 @@ simple-admin-core/ ```shell -swagger generate spec --output=./core.yml +swagger generate spec --output=./core.yml --scan-models swagger serve --no-open -F=swagger --port 36666 core.yaml ``` diff --git a/rpc/internal/logic/getapilistlogic.go b/rpc/internal/logic/getapilistlogic.go index 56fa8c23..6745fa95 100644 --- a/rpc/internal/logic/getapilistlogic.go +++ b/rpc/internal/logic/getapilistlogic.go @@ -44,7 +44,7 @@ func (l *GetApiListLogic) GetApiList(in *core.ApiPageReq) (*core.ApiListResp, er } if in.Group != "" { - db = db.Where("group = ?", in.Group) + db = db.Where("api_group = ?", in.Group) } result := db.Limit(int(in.Page.PageSize)).Offset(int((in.Page.Page - 1) * in.Page.PageSize)).