From 5629ad968da75da080ae5a5e342fca1ecfbd29ba Mon Sep 17 00:00:00 2001 From: QM303176530 <303176530@qq.com> Date: Tue, 7 Apr 2020 22:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=87=BAapi=E4=B8=AD=E7=9A=84model?= =?UTF-8?q?=E5=88=B0=E5=8D=95=E7=8B=ACmodel=E5=88=86=E7=BB=84=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9dashboard=20=E6=8B=BC=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/api/v1/exa_customer.go | 8 +-- server/api/v1/exa_file_upload_download.go | 2 +- server/api/v1/sys_api.go | 20 +++---- server/api/v1/sys_authority.go | 6 +- server/api/v1/sys_auto_code.go | 2 +- server/api/v1/sys_casbin.go | 6 +- server/api/v1/sys_menu.go | 37 ++++-------- server/api/v1/sys_system.go | 4 +- server/api/v1/sys_user.go | 25 +++----- server/model/http_request.go | 1 + server/model/http_response.go | 60 +++++++++++++++++++ server/model/sys_common.go | 6 -- web/src/permission.js | 2 +- web/src/store/module/user.js | 2 +- web/src/view/dashboard/index.vue | 2 +- .../layout/aside/historyComponent/history.vue | 8 +-- 16 files changed, 106 insertions(+), 85 deletions(-) create mode 100644 server/model/http_request.go create mode 100644 server/model/http_response.go delete mode 100644 server/model/sys_common.go diff --git a/server/api/v1/exa_customer.go b/server/api/v1/exa_customer.go index b6d60158..17e6fcc5 100644 --- a/server/api/v1/exa_customer.go +++ b/server/api/v1/exa_customer.go @@ -13,7 +13,7 @@ import ( // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body dbModel.ExaCustomer true "创建客户" +// @Param data body model.ExaCustomer true "创建客户" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/createExaCustomer [post] func CreateExaCustomer(c *gin.Context) { @@ -36,7 +36,7 @@ func CreateExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body dbModel.ExaCustomer true "删除客户" +// @Param data body model.ExaCustomer true "删除客户" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/deleteExaCustomer [post] func DeleteExaCustomer(c *gin.Context) { @@ -55,7 +55,7 @@ func DeleteExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body dbModel.ExaCustomer true "创建客户" +// @Param data body model.ExaCustomer true "创建客户" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/updateExaCustomer [post] func UpdateExaCustomer(c *gin.Context) { @@ -74,7 +74,7 @@ func UpdateExaCustomer(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body dbModel.ExaCustomer true "获取单一客户信息" +// @Param data body model.ExaCustomer true "获取单一客户信息" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /customer/getExaCustomer [post] func GetExaCustomer(c *gin.Context) { diff --git a/server/api/v1/exa_file_upload_download.go b/server/api/v1/exa_file_upload_download.go index 05c77664..552195cb 100644 --- a/server/api/v1/exa_file_upload_download.go +++ b/server/api/v1/exa_file_upload_download.go @@ -52,7 +52,7 @@ func UploadFile(c *gin.Context) { // @Summary 删除文件 // @Security ApiKeyAuth // @Produce application/json -// @Param data body dbModel.ExaFileUploadAndDownload true "传入文件里面id即可" +// @Param data body model.ExaFileUploadAndDownload true "传入文件里面id即可" // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /fileUploadAndDownload/deleteFile [post] func DeleteFile(c *gin.Context) { diff --git a/server/api/v1/sys_api.go b/server/api/v1/sys_api.go index e7f63def..fa7cb03b 100644 --- a/server/api/v1/sys_api.go +++ b/server/api/v1/sys_api.go @@ -12,7 +12,7 @@ import ( // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.CreateApiParams true "创建api" +// @Param data body model.SysApi true "创建api" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/createApi [post] func CreateApi(c *gin.Context) { @@ -31,7 +31,7 @@ func CreateApi(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.SysApi true "删除api" +// @Param data body model.SysApi true "删除api" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/deleteApi [post] func DeleteApi(c *gin.Context) { @@ -52,18 +52,12 @@ func DeleteApi(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.PageInfo true "分页获取API列表" +// @Param data body model.SearchApiParams true "分页获取API列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/getApiList [post] func GetApiList(c *gin.Context) { // 此结构体仅本方法使用 - type searchParams struct { - model.SysApi - model.PageInfo - OrderKey string `json:"orderKey"` - Desc bool `json:"desc"` - } - var sp searchParams + var sp model.SearchApiParams _ = c.ShouldBindJSON(&sp) err, list, total := sp.SysApi.GetInfoList(sp.PageInfo, sp.OrderKey, sp.Desc) if err != nil { @@ -83,11 +77,11 @@ func GetApiList(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body model.PageInfo true "分页获取用户列表" +// @Param data body model.GetById true "根据id获取api" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/getApiById [post] func GetApiById(c *gin.Context) { - var idInfo GetById + var idInfo model.GetById _ = c.ShouldBindJSON(&idInfo) err, api := new(model.SysApi).GetApiById(idInfo.Id) if err != nil { @@ -105,7 +99,7 @@ func GetApiById(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.CreateApiParams true "创建api" +// @Param data body model.SysApi true "创建api" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /api/updateApi [post] func UpdateApi(c *gin.Context) { diff --git a/server/api/v1/sys_authority.go b/server/api/v1/sys_authority.go index f934fda8..81d2d09d 100644 --- a/server/api/v1/sys_authority.go +++ b/server/api/v1/sys_authority.go @@ -12,7 +12,7 @@ import ( // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.SysAuthority true "创建角色" +// @Param data body model.SysAuthority true "创建角色" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /authority/createAuthority [post] func CreateAuthority(c *gin.Context) { @@ -33,7 +33,7 @@ func CreateAuthority(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.SysAuthority true "删除角色" +// @Param data body model.SysAuthority true "删除角色" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /authority/deleteAuthority [post] func DeleteAuthority(c *gin.Context) { @@ -77,7 +77,7 @@ func GetAuthorityList(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.SysAuthority true "设置角色资源权限" +// @Param data body model.SysAuthority true "设置角色资源权限" // @Success 200 {string} string "{"success":true,"data":{},"msg":"设置成功"}" // @Router /authority/setDataAuthority [post] func SetDataAuthority(c *gin.Context) { diff --git a/server/api/v1/sys_auto_code.go b/server/api/v1/sys_auto_code.go index 2a59a7ce..155cf348 100644 --- a/server/api/v1/sys_auto_code.go +++ b/server/api/v1/sys_auto_code.go @@ -13,7 +13,7 @@ import ( // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body autoCodeModel.AutoCodeStruct true "创建自动代码" +// @Param data body model.AutoCodeStruct true "创建自动代码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}" // @Router /autoCode/createTemp [post] func CreateTemp(c *gin.Context) { diff --git a/server/api/v1/sys_casbin.go b/server/api/v1/sys_casbin.go index 61bc5a7c..9e77845b 100644 --- a/server/api/v1/sys_casbin.go +++ b/server/api/v1/sys_casbin.go @@ -12,7 +12,7 @@ import ( // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.CasbinInReceive true "更改角色api权限" +// @Param data body model.CasbinInReceive true "更改角色api权限" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/UpdateCasbin [post] func UpdateCasbin(c *gin.Context) { @@ -31,7 +31,7 @@ func UpdateCasbin(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.CasbinInReceive true "获取权限列表" +// @Param data body model.CasbinInReceive true "获取权限列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/getPolicyPathByAuthorityId [post] func GetPolicyPathByAuthorityId(c *gin.Context) { @@ -46,7 +46,7 @@ func GetPolicyPathByAuthorityId(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.CasbinInReceive true "获取权限列表" +// @Param data body model.CasbinInReceive true "获取权限列表" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /casbin/CasbinTest [get] func CasbinTest(c *gin.Context) { diff --git a/server/api/v1/sys_menu.go b/server/api/v1/sys_menu.go index 23011417..22a3ffca 100644 --- a/server/api/v1/sys_menu.go +++ b/server/api/v1/sys_menu.go @@ -55,7 +55,7 @@ func GetMenuList(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.SysBaseMenu true "新增菜单" +// @Param data body model.SysBaseMenu true "新增菜单" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/addBaseMenu [post] func AddBaseMenu(c *gin.Context) { @@ -86,21 +86,16 @@ func GetBaseMenuTree(c *gin.Context) { } } -type AddMenuAuthorityInfo struct { - Menus []model.SysBaseMenu - AuthorityId string -} - // @Tags authorityAndMenu // @Summary 增加menu和角色关联关系 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.AddMenuAuthorityInfo true "增加menu和角色关联关系" +// @Param data body model.AddMenuAuthorityInfo true "增加menu和角色关联关系" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/addMenuAuthority [post] func AddMenuAuthority(c *gin.Context) { - var addMenuAuthorityInfo AddMenuAuthorityInfo + var addMenuAuthorityInfo model.AddMenuAuthorityInfo _ = c.ShouldBindJSON(&addMenuAuthorityInfo) err := new(model.SysMenu).AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId) @@ -111,20 +106,16 @@ func AddMenuAuthority(c *gin.Context) { } } -type AuthorityIdInfo struct { - AuthorityId string -} - // @Tags authorityAndMenu // @Summary 获取指定角色menu // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.AuthorityIdInfo true "增加menu和角色关联关系" +// @Param data body model.AuthorityIdInfo true "增加menu和角色关联关系" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/GetMenuAuthority [post] func GetMenuAuthority(c *gin.Context) { - var authorityIdInfo AuthorityIdInfo + var authorityIdInfo model.AuthorityIdInfo _ = c.ShouldBindJSON(&authorityIdInfo) err, menus := new(model.SysMenu).GetMenuAuthority(authorityIdInfo.AuthorityId) if err != nil { @@ -134,20 +125,16 @@ func GetMenuAuthority(c *gin.Context) { } } -type IdInfo struct { - Id float64 -} - // @Tags menu // @Summary 删除菜单 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.IdInfo true "删除菜单" +// @Param data body model.GetById true "删除菜单" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/deleteBaseMenu [post] func DeleteBaseMenu(c *gin.Context) { - var idInfo IdInfo + var idInfo model.GetById _ = c.ShouldBindJSON(&idInfo) err := new(model.SysBaseMenu).DeleteBaseMenu(idInfo.Id) if err != nil { @@ -163,7 +150,7 @@ func DeleteBaseMenu(c *gin.Context) { // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body sysModel.SysBaseMenu true "更新菜单" +// @Param data body model.SysBaseMenu true "更新菜单" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/updateBaseMenu [post] func UpdateBaseMenu(c *gin.Context) { @@ -177,20 +164,16 @@ func UpdateBaseMenu(c *gin.Context) { } } -type GetById struct { - Id float64 `json:"id"` -} - // @Tags menu // @Summary 根据id获取菜单 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.GetById true "根据id获取菜单" +// @Param data body model.GetById true "根据id获取菜单" // @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}" // @Router /menu/getBaseMenuById [post] func GetBaseMenuById(c *gin.Context) { - var idInfo GetById + var idInfo model.GetById _ = c.ShouldBindJSON(&idInfo) err, menu := new(model.SysBaseMenu).GetBaseMenuById(idInfo.Id) if err != nil { diff --git a/server/api/v1/sys_system.go b/server/api/v1/sys_system.go index 5b448074..c4276bd9 100644 --- a/server/api/v1/sys_system.go +++ b/server/api/v1/sys_system.go @@ -26,7 +26,7 @@ func GetSystemConfig(c *gin.Context) { // @Summary 设置配置文件内容 // @Security ApiKeyAuth // @Produce application/json -// @Param data body sysModel.System true "设置配置文件内容" +// @Param data body model.System true "设置配置文件内容" // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /system/setSystemConfig [post] func SetSystemConfig(c *gin.Context) { @@ -45,7 +45,7 @@ func SetSystemConfig(c *gin.Context) { // @Summary 设置配置文件内容 // @Security ApiKeyAuth // @Produce application/json -// @Param data body sysModel.System true "设置配置文件内容" +// @Param data body model.System true "设置配置文件内容" // @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}" // @Router /system/ReloadSystem [post] func ReloadSystem(c *gin.Context) { diff --git a/server/api/v1/sys_user.go b/server/api/v1/sys_user.go index 978e02b3..2631e356 100644 --- a/server/api/v1/sys_user.go +++ b/server/api/v1/sys_user.go @@ -11,7 +11,6 @@ import ( "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" "github.com/go-redis/redis" - uuid "github.com/satori/go.uuid" "mime/multipart" "time" ) @@ -20,10 +19,11 @@ const ( USER_HEADER_IMG_PATH string = "http://qmplusimg.henrongyi.top" USER_HEADER_BUCKET string = "qm-plus-img" ) + // @Tags Base // @Summary 用户注册账号 // @Produce application/json -// @Param data body sysModel.SysUser true "用户注册接口" +// @Param data body model.SysUser true "用户注册接口" // @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}" // @Router /base/register [post] func Register(c *gin.Context) { @@ -45,7 +45,7 @@ func Register(c *gin.Context) { // @Tags Base // @Summary 用户登录 // @Produce application/json -// @Param data body api.RegisterAndLoginStruct true "用户登录接口" +// @Param data body model.RegisterAndLoginStruct true "用户登录接口" // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /base/login [post] func Login(c *gin.Context) { @@ -118,21 +118,15 @@ func tokenNext(c *gin.Context, user model.SysUser) { } } -type ChangePasswordStutrc struct { - Username string `json:"username"` - Password string `json:"password"` - NewPassword string `json:"newPassword"` -} - // @Tags SysUser // @Summary 用户修改密码 // @Security ApiKeyAuth // @Produce application/json -// @Param data body api.ChangePasswordStutrc true "用户修改密码" +// @Param data body model.ChangePasswordStutrc true "用户修改密码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /user/changePassword [put] func ChangePassword(c *gin.Context) { - var params ChangePasswordStutrc + var params model.ChangePasswordStutrc _ = c.ShouldBindJSON(¶ms) U := &model.SysUser{Username: params.Username, Password: params.Password} if err, _ := U.ChangePassword(params.NewPassword); err != nil { @@ -206,21 +200,16 @@ func GetUserList(c *gin.Context) { } } -type SetUserAuth struct { - UUID uuid.UUID `json:"uuid"` - AuthorityId string `json:"authorityId"` -} - // @Tags SysUser // @Summary 设置用户权限 // @Security ApiKeyAuth // @accept application/json // @Produce application/json -// @Param data body api.SetUserAuth true "设置用户权限" +// @Param data body model.SetUserAuth true "设置用户权限" // @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}" // @Router /user/setUserAuthority [post] func SetUserAuthority(c *gin.Context) { - var sua SetUserAuth + var sua model.SetUserAuth _ = c.ShouldBindJSON(&sua) err := new(model.SysUser).SetUserAuthority(sua.UUID, sua.AuthorityId) if err != nil { diff --git a/server/model/http_request.go b/server/model/http_request.go new file mode 100644 index 00000000..8b537907 --- /dev/null +++ b/server/model/http_request.go @@ -0,0 +1 @@ +package model diff --git a/server/model/http_response.go b/server/model/http_response.go new file mode 100644 index 00000000..f3a6d2ee --- /dev/null +++ b/server/model/http_response.go @@ -0,0 +1,60 @@ +package model + +import uuid "github.com/satori/go.uuid" + +/****************************** common start ****************************************************/ +// 分页公用入参结构体 +type PageInfo struct { + Page int `json:"page"` + PageSize int `json:"pageSize"` +} + +//根据id查询结构体 +type GetById struct { + Id float64 `json:"id"` +} + +/****************************** common end ****************************************************/ + +/****************************** api start ****************************************************/ +//api分页条件查询及排序结构体 +type SearchApiParams struct { + SysApi + PageInfo + OrderKey string `json:"orderKey"` + Desc bool `json:"desc"` +} + +/****************************** api end ****************************************************/ + +/****************************** Authority start ****************************************************/ + +// 添加角色和menu关系 +type AddMenuAuthorityInfo struct { + Menus []SysBaseMenu + AuthorityId string +} + +// 根据角色id获取角色 +type AuthorityIdInfo struct { + AuthorityId string +} + +/****************************** Authority end ****************************************************/ + +/****************************** user start ****************************************************/ + +// 修改密码结构体 +type ChangePasswordStutrc struct { + Username string `json:"username"` + Password string `json:"password"` + NewPassword string `json:"newPassword"` +} + +// 设置用户权限 +type SetUserAuth struct { + UUID uuid.UUID `json:"uuid"` + AuthorityId string `json:"authorityId"` +} + +/****************************** user end ****************************************************/ diff --git a/server/model/sys_common.go b/server/model/sys_common.go deleted file mode 100644 index 8dded357..00000000 --- a/server/model/sys_common.go +++ /dev/null @@ -1,6 +0,0 @@ -package model - -type PageInfo struct { - Page int `json:"page"` - PageSize int `json:"pageSize"` -} diff --git a/web/src/permission.js b/web/src/permission.js index 940a9e57..3f9eefa8 100644 --- a/web/src/permission.js +++ b/web/src/permission.js @@ -18,7 +18,7 @@ router.beforeEach(async(to, from, next) => { // 在白名单中的判断情况 if (whiteList.indexOf(to.name) > -1) { if (token) { - next({ path: '/layout/dashbord' }) + next({ path: '/layout/dashboard' }) } else { next() } diff --git a/web/src/store/module/user.js b/web/src/store/module/user.js index ec5fbe89..3da55ea6 100644 --- a/web/src/store/module/user.js +++ b/web/src/store/module/user.js @@ -51,7 +51,7 @@ export const user = { if (redirect) { router.push({ path: redirect }) } else { - router.push({ path: '/layout/dashbord' }) + router.push({ path: '/layout/dashboard' }) } } }, diff --git a/web/src/view/dashboard/index.vue b/web/src/view/dashboard/index.vue index 91b09b93..b6b02927 100644 --- a/web/src/view/dashboard/index.vue +++ b/web/src/view/dashboard/index.vue @@ -29,7 +29,7 @@ import { mapGetters } from 'vuex' import Animition from '@/view/dashboard/component/animition.vue' export default { - name: 'Dashbord', + name: 'Dashboard', data() { return { drawer: false diff --git a/web/src/view/layout/aside/historyComponent/history.vue b/web/src/view/layout/aside/historyComponent/history.vue index 0f800944..014443c7 100644 --- a/web/src/view/layout/aside/historyComponent/history.vue +++ b/web/src/view/layout/aside/historyComponent/history.vue @@ -1,6 +1,6 @@