refactor🎨: 缩减函数名称

This commit is contained in:
wenjianzhang
2021-06-07 20:37:01 +08:00
parent c96d9c35a7
commit 9a2c0729f6
22 changed files with 111 additions and 126 deletions
+3 -3
View File
@@ -15,7 +15,7 @@ type SysConfig struct {
api.Api api.Api
} }
// GetList 获取配置管理列表 // GetPage 获取配置管理列表
// @Summary 获取配置管理列表 // @Summary 获取配置管理列表
// @Description 获取配置管理列表 // @Description 获取配置管理列表
// @Tags 配置管理 // @Tags 配置管理
@@ -28,7 +28,7 @@ type SysConfig struct {
// @Success 200 {object} response.Response{data=response.Page{list=[]models.SysApi}} "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response{data=response.Page{list=[]models.SysApi}} "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-config [get] // @Router /api/v1/sys-config [get]
// @Security Bearer // @Security Bearer
func (e SysConfig) GetList(c *gin.Context) { func (e SysConfig) GetPage(c *gin.Context) {
s := service.SysConfig{} s := service.SysConfig{}
req := dto.SysConfigSearch{} req := dto.SysConfigSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -311,4 +311,4 @@ func (e SysConfig) GetSysConfigByKEYForService(c *gin.Context) {
return return
} }
e.OK(resp, s.Msg) e.OK(resp, s.Msg)
} }
+3 -3
View File
@@ -17,7 +17,7 @@ type SysDept struct {
api.Api api.Api
} }
// GetList // GetPage
// @Summary 分页部门列表数据 // @Summary 分页部门列表数据
// @Description 分页列表 // @Description 分页列表
// @Tags 部门 // @Tags 部门
@@ -27,7 +27,7 @@ type SysDept struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dept [get] // @Router /api/v1/dept [get]
// @Security Bearer // @Security Bearer
func (e SysDept) GetList(c *gin.Context) { func (e SysDept) GetPage(c *gin.Context) {
s := service.SysDept{} s := service.SysDept{}
req := dto.SysDeptSearch{} req := dto.SysDeptSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -235,4 +235,4 @@ func (e SysDept) GetDeptTreeRoleSelect(c *gin.Context) {
"depts": result, "depts": result,
"checkedKeys": menuIds, "checkedKeys": menuIds,
}, "") }, "")
} }
+2 -2
View File
@@ -18,7 +18,7 @@ type SysDictData struct {
api.Api api.Api
} }
// GetList // GetPage
// @Summary 字典数据列表 // @Summary 字典数据列表
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典数据 // @Tags 字典数据
@@ -30,7 +30,7 @@ type SysDictData struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/data [get] // @Router /api/v1/dict/data [get]
// @Security Bearer // @Security Bearer
func (e SysDictData) GetList(c *gin.Context) { func (e SysDictData) GetPage(c *gin.Context) {
s := service.SysDictData{} s := service.SysDictData{}
req := dto.SysDictDataSearch{} req := dto.SysDictDataSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
+8 -8
View File
@@ -18,7 +18,7 @@ type SysDictType struct {
api.Api api.Api
} }
// GetSysDictTypeList 字典类型列表数据 // GetPage 字典类型列表数据
// @Summary 字典类型列表数据 // @Summary 字典类型列表数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典类型 // @Tags 字典类型
@@ -30,7 +30,7 @@ type SysDictType struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/type [get] // @Router /api/v1/dict/type [get]
// @Security Bearer // @Security Bearer
func (e SysDictType) GetList(c *gin.Context) { func (e SysDictType) GetPage(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req := dto.SysDictTypeSearch{} req := dto.SysDictTypeSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -53,7 +53,7 @@ func (e SysDictType) GetList(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
} }
// GetSysDictType 字典类型通过字典id获取 // Get 字典类型通过字典id获取
// @Summary 字典类型通过字典id获取 // @Summary 字典类型通过字典id获取
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典类型 // @Tags 字典类型
@@ -83,7 +83,7 @@ func (e SysDictType) Get(c *gin.Context) {
e.OK(object, "查看成功") e.OK(object, "查看成功")
} }
//InsertSysDictType 字典类型创建 //Insert 字典类型创建
// @Summary 添加字典类型 // @Summary 添加字典类型
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典类型 // @Tags 字典类型
@@ -117,7 +117,7 @@ func (e SysDictType) Insert(c *gin.Context) {
e.OK(req.GetId(), "创建成功") e.OK(req.GetId(), "创建成功")
} }
// UpdateSysDictType // Update
// @Summary 修改字典类型 // @Summary 修改字典类型
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典类型 // @Tags 字典类型
@@ -150,7 +150,7 @@ func (e SysDictType) Update(c *gin.Context) {
e.OK(req.GetId(), "更新成功") e.OK(req.GetId(), "更新成功")
} }
// DeleteSysDictType // Delete
// @Summary 删除字典类型 // @Summary 删除字典类型
// @Description 删除数据 // @Description 删除数据
// @Tags 字典类型 // @Tags 字典类型
@@ -180,7 +180,7 @@ func (e SysDictType) Delete(c *gin.Context) {
e.OK(req.GetId(), "删除成功") e.OK(req.GetId(), "删除成功")
} }
// GetSysDictTypeAll // GetAll
// @Summary 字典类型全部数据 代码生成使用接口 // @Summary 字典类型全部数据 代码生成使用接口
// @Description 获取JSON // @Description 获取JSON
// @Tags 字典类型 // @Tags 字典类型
@@ -190,7 +190,7 @@ func (e SysDictType) Delete(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/type-option-select [get] // @Router /api/v1/dict/type-option-select [get]
// @Security Bearer // @Security Bearer
func (e SysDictType) GetSysDictTypeAll(c *gin.Context) { func (e SysDictType) GetAll(c *gin.Context) {
s := service.SysDictType{} s := service.SysDictType{}
req := dto.SysDictTypeSearch{} req := dto.SysDictTypeSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
+2 -2
View File
@@ -15,7 +15,7 @@ type SysLoginLog struct {
api.Api api.Api
} }
// GetSysLoginLogList 登录日志列表 // GetPage 登录日志列表
// @Summary 登录日志列表 // @Summary 登录日志列表
// @Description 获取JSON // @Description 获取JSON
// @Tags 登录日志 // @Tags 登录日志
@@ -28,7 +28,7 @@ type SysLoginLog struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-login-log [get] // @Router /api/v1/sys-login-log [get]
// @Security Bearer // @Security Bearer
func (e SysLoginLog) GetList(c *gin.Context) { func (e SysLoginLog) GetPage(c *gin.Context) {
s := service.SysLoginLog{} s := service.SysLoginLog{}
req := dto.SysLoginLogSearch {} req := dto.SysLoginLogSearch {}
err := e.MakeContext(c). err := e.MakeContext(c).
+7 -7
View File
@@ -17,7 +17,7 @@ type SysMenu struct {
api.Api api.Api
} }
// GetSysMenuList Menu列表数据 // GetPage Menu列表数据
// @Summary Menu列表数据 // @Summary Menu列表数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 菜单 // @Tags 菜单
@@ -26,7 +26,7 @@ type SysMenu struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/menu [get] // @Router /api/v1/menu [get]
// @Security Bearer // @Security Bearer
func (e SysMenu) GetList(c *gin.Context) { func (e SysMenu) GetPage(c *gin.Context) {
s := service.SysMenu{} s := service.SysMenu{}
req := dto.SysMenuSearch{} req := dto.SysMenuSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -48,7 +48,7 @@ func (e SysMenu) GetList(c *gin.Context) {
e.OK(list, "查询成功") e.OK(list, "查询成功")
} }
// GetSysMenu 获取菜单详情 // Get 获取菜单详情
// @Summary Menu详情数据 // @Summary Menu详情数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 菜单 // @Tags 菜单
@@ -79,7 +79,7 @@ func (e SysMenu) Get(c *gin.Context) {
e.OK(object, "查看成功") e.OK(object, "查看成功")
} }
// InsertSysMenu 创建菜单 // Insert 创建菜单
// @Summary 创建菜单 // @Summary 创建菜单
// @Description 获取JSON // @Description 获取JSON
// @Tags 菜单 // @Tags 菜单
@@ -112,7 +112,7 @@ func (e SysMenu) Insert(c *gin.Context) {
e.OK(req.GetId(), "创建成功") e.OK(req.GetId(), "创建成功")
} }
// UpdateSysMenu 修改菜单 // Update 修改菜单
// @Summary 修改菜单 // @Summary 修改菜单
// @Description 获取JSON // @Description 获取JSON
// @Tags 菜单 // @Tags 菜单
@@ -146,7 +146,7 @@ func (e SysMenu) Update(c *gin.Context) {
e.OK(req.GetId(), "更新成功") e.OK(req.GetId(), "更新成功")
} }
// DeleteSysMenu 删除菜单 // Delete 删除菜单
// @Summary 删除菜单 // @Summary 删除菜单
// @Description 删除数据 // @Description 删除数据
// @Tags 菜单 // @Tags 菜单
@@ -279,4 +279,4 @@ func (e SysMenu) GetMenuTreeSelect(c *gin.Context) {
"menus": result, "menus": result,
"checkedKeys": menuIds, "checkedKeys": menuIds,
}, "获取成功") }, "获取成功")
} }
+2 -2
View File
@@ -86,7 +86,7 @@ func (e SysOperaLog) Get(c *gin.Context) {
e.OK(object, "查看成功") e.OK(object, "查看成功")
} }
// Remove 操作日志删除 // Delete 操作日志删除
// DeleteSysMenu 操作日志删除 // DeleteSysMenu 操作日志删除
// @Summary 删除操作日志 // @Summary 删除操作日志
// @Description 删除数据 // @Description 删除数据
@@ -94,7 +94,7 @@ func (e SysOperaLog) Get(c *gin.Context) {
// @Param data body dto.SysOperaLogById true "body" // @Param data body dto.SysOperaLogById true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-opera-log [delete] // @Router /api/v1/sys-opera-log [delete]
func (e SysOperaLog) Remove(c *gin.Context) { func (e SysOperaLog) Delete(c *gin.Context) {
s := new(service.SysOperaLog) s := new(service.SysOperaLog)
req := new(dto.SysOperaLogById) req := new(dto.SysOperaLogById)
err := e.MakeContext(c). err := e.MakeContext(c).
+13 -19
View File
@@ -18,7 +18,7 @@ type SysPost struct {
api.Api api.Api
} }
// GetSysPostList // GetPage
// @Summary 岗位列表数据 // @Summary 岗位列表数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 岗位 // @Tags 岗位
@@ -29,7 +29,7 @@ type SysPost struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post [get] // @Router /api/v1/post [get]
// @Security Bearer // @Security Bearer
func (e SysPost) GetSysPostList(c *gin.Context) { func (e SysPost) GetPage(c *gin.Context) {
s := service.SysPost{} s := service.SysPost{}
req := dto.SysPostSearch{} req := dto.SysPostSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -55,7 +55,7 @@ func (e SysPost) GetSysPostList(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
} }
// GetSysPost // Get
// @Summary 获取岗位信息 // @Summary 获取岗位信息
// @Description 获取JSON // @Description 获取JSON
// @Tags 岗位 // @Tags 岗位
@@ -63,7 +63,7 @@ func (e SysPost) GetSysPostList(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post/{postId} [get] // @Router /api/v1/post/{postId} [get]
// @Security Bearer // @Security Bearer
func (e SysPost) GetSysPost(c *gin.Context) { func (e SysPost) Get(c *gin.Context) {
s := service.SysPost{} s := service.SysPost{}
req := dto.SysPostById{} req := dto.SysPostById{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -80,14 +80,14 @@ func (e SysPost) GetSysPost(c *gin.Context) {
err = s.GetSysPost(&req, &object) err = s.GetSysPost(&req, &object)
if err != nil { if err != nil {
e.Error(http.StatusUnprocessableEntity, err, "查询失败") e.Error(500, err, "查询失败")
return return
} }
e.OK(object, "查看成功") e.OK(object, "查看成功")
} }
// InsertSysPost // Insert
// @Summary 添加岗位 // @Summary 添加岗位
// @Description 获取JSON // @Description 获取JSON
// @Tags 岗位 // @Tags 岗位
@@ -98,7 +98,7 @@ func (e SysPost) GetSysPost(c *gin.Context) {
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/post [post] // @Router /api/v1/post [post]
// @Security Bearer // @Security Bearer
func (e SysPost) InsertSysPost(c *gin.Context) { func (e SysPost) Insert(c *gin.Context) {
s := service.SysPost{} s := service.SysPost{}
req := dto.SysPostControl{} req := dto.SysPostControl{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -111,21 +111,16 @@ func (e SysPost) InsertSysPost(c *gin.Context) {
e.Error(500, err, err.Error()) e.Error(500, err, err.Error())
return return
} }
// 设置创建人
req.SetCreateBy(user.GetUserId(c)) req.SetCreateBy(user.GetUserId(c))
err = s.InsertSysPost(&req) err = s.InsertSysPost(&req)
if err != nil { if err != nil {
e.Logger.Error(err) e.Error(500, err, "创建失败")
e.Error(http.StatusInternalServerError, err, "创建失败")
return return
} }
e.OK(req.GetId(), "创建成功") e.OK(req.GetId(), "创建成功")
} }
// UpdateSysPost // Update
// @Summary 修改岗位 // @Summary 修改岗位
// @Description 获取JSON // @Description 获取JSON
// @Tags 岗位 // @Tags 岗位
@@ -136,7 +131,7 @@ func (e SysPost) InsertSysPost(c *gin.Context) {
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}" // @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/post/ [put] // @Router /api/v1/post/ [put]
// @Security Bearer // @Security Bearer
func (e SysPost) UpdateSysPost(c *gin.Context) { func (e SysPost) Update(c *gin.Context) {
s := service.SysPost{} s := service.SysPost{}
req := dto.SysPostControl{} req := dto.SysPostControl{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -160,7 +155,7 @@ func (e SysPost) UpdateSysPost(c *gin.Context) {
e.OK(req.GetId(), "更新成功") e.OK(req.GetId(), "更新成功")
} }
// DeleteSysPost // Delete
// @Summary 删除岗位 // @Summary 删除岗位
// @Description 删除数据 // @Description 删除数据
// @Tags 岗位 // @Tags 岗位
@@ -168,7 +163,7 @@ func (e SysPost) UpdateSysPost(c *gin.Context) {
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}" // @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}" // @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
// @Router /api/v1/post/{postId} [delete] // @Router /api/v1/post/{postId} [delete]
func (e SysPost) DeleteSysPost(c *gin.Context) { func (e SysPost) Delete(c *gin.Context) {
s := service.SysPost{} s := service.SysPost{}
req := dto.SysPostById{} req := dto.SysPostById{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -182,11 +177,10 @@ func (e SysPost) DeleteSysPost(c *gin.Context) {
return return
} }
req.SetUpdateBy(user.GetUserId(c)) req.SetUpdateBy(user.GetUserId(c))
err = s.RemoveSysPost(&req) err = s.RemoveSysPost(&req)
if err != nil { if err != nil {
e.Logger.Error(err) e.Logger.Error(err)
return return
} }
e.OK(req.GetId(), "删除成功") e.OK(req.GetId(), "删除成功")
} }
+6 -6
View File
@@ -20,7 +20,7 @@ type SysRole struct {
api.Api api.Api
} }
// GetList // GetPage
// @Summary 角色列表数据 // @Summary 角色列表数据
// @Description Get JSON // @Description Get JSON
// @Tags 角色/Role // @Tags 角色/Role
@@ -32,7 +32,7 @@ type SysRole struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/role [get] // @Router /api/v1/role [get]
// @Security Bearer // @Security Bearer
func (e SysRole) GetList(c *gin.Context) { func (e SysRole) GetPage(c *gin.Context) {
s := service.SysRole{} s := service.SysRole{}
req := dto.SysRoleSearch{} req := dto.SysRoleSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -122,8 +122,8 @@ func (e SysRole) Insert(c *gin.Context) {
if req.Status == "" { if req.Status == "" {
req.Status = "2" req.Status = "2"
} }
cb := sdk.Runtime.GetCasbinKey(c.Request.Host)
err = s.Insert(&req) err = s.Insert(&req, cb)
if err != nil { if err != nil {
e.Logger.Error(err) e.Logger.Error(err)
e.Error(500, err, "创建失败") e.Error(500, err, "创建失败")
@@ -148,7 +148,7 @@ func (e SysRole) Insert(c *gin.Context) {
// @Success 200 {string} string "{"code": -1, "message": "修改失败"}" // @Success 200 {string} string "{"code": -1, "message": "修改失败"}"
// @Router /api/v1/role/{id} [put] // @Router /api/v1/role/{id} [put]
// @Security Bearer // @Security Bearer
func (e SysRole) Update (c *gin.Context) { func (e SysRole) Update(c *gin.Context) {
s := service.SysRole{} s := service.SysRole{}
req := dto.SysRoleControl{} req := dto.SysRoleControl{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -241,4 +241,4 @@ func (e SysRole) Update2DataScope(c *gin.Context) {
return return
} }
e.OK(nil, "操作成功") e.OK(nil, "操作成功")
} }
+23 -32
View File
@@ -20,7 +20,7 @@ type SysUser struct {
api.Api api.Api
} }
// GetSysUserList // GetPage
// @Summary 列表用户信息数据 // @Summary 列表用户信息数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -28,7 +28,7 @@ type SysUser struct {
// @Success 200 {string} {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {string} {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-user [get] // @Router /api/v1/sys-user [get]
// @Security Bearer // @Security Bearer
func (e SysUser) GetSysUserList(c *gin.Context) { func (e SysUser) GetPage(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserSearch{} req := dto.SysUserSearch{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -57,7 +57,7 @@ func (e SysUser) GetSysUserList(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功") e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
} }
// GetSysUser // Get
// @Summary 获取用户 // @Summary 获取用户
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -65,7 +65,7 @@ func (e SysUser) GetSysUserList(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysUser/{userId} [get] // @Router /api/v1/sysUser/{userId} [get]
// @Security Bearer // @Security Bearer
func (e SysUser) GetSysUser(c *gin.Context) { func (e SysUser) Get(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserById{} req := dto.SysUserById{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -89,7 +89,7 @@ func (e SysUser) GetSysUser(c *gin.Context) {
e.OK(object, "查看成功") e.OK(object, "查看成功")
} }
// InsertSysUser // Insert
// @Summary 创建用户 // @Summary 创建用户
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -98,7 +98,7 @@ func (e SysUser) GetSysUser(c *gin.Context) {
// @Param data body dto.SysUserControl true "用户数据" // @Param data body dto.SysUserControl true "用户数据"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysUser [post] // @Router /api/v1/sysUser [post]
func (e SysUser) InsertSysUser(c *gin.Context) { func (e SysUser) Insert(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserControl{} req := dto.SysUserControl{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -123,7 +123,7 @@ func (e SysUser) InsertSysUser(c *gin.Context) {
e.OK(req.GetId(), "创建成功") e.OK(req.GetId(), "创建成功")
} }
// UpdateSysUser // Update
// @Summary 修改用户数据 // @Summary 修改用户数据
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -132,7 +132,7 @@ func (e SysUser) InsertSysUser(c *gin.Context) {
// @Param data body dto.SysUserControl true "body" // @Param data body dto.SysUserControl true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-user/{userId} [put] // @Router /api/v1/sys-user/{userId} [put]
func (e SysUser) UpdateSysUser(c *gin.Context) { func (e SysUser) Update(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserControl{} req := dto.SysUserControl{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -159,14 +159,14 @@ func (e SysUser) UpdateSysUser(c *gin.Context) {
e.OK(req.GetId(), "更新成功") e.OK(req.GetId(), "更新成功")
} }
// DeleteSysUser // Delete
// @Summary 删除用户数据 // @Summary 删除用户数据
// @Description 删除数据 // @Description 删除数据
// @Tags 用户 // @Tags 用户
// @Param userId path int true "userId" // @Param userId path int true "userId"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysuser/{userId} [delete] // @Router /api/v1/sys-user/{userId} [delete]
func (e SysUser) DeleteSysUser(c *gin.Context) { func (e SysUser) Delete(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserById{} req := dto.SysUserById{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -194,15 +194,15 @@ func (e SysUser) DeleteSysUser(c *gin.Context) {
e.OK(req.GetId(), "删除成功") e.OK(req.GetId(), "删除成功")
} }
// InsetSysUserAvatar // InsetAvatar
// @Summary 修改头像 // @Summary 修改头像
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 个人中心
// @Accept multipart/form-data // @Accept multipart/form-data
// @Param file formData file true "file" // @Param file formData file true "file"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/avatar [post] // @Router /api/v1/user/avatar [post]
func (e SysUser) InsetSysUserAvatar(c *gin.Context) { func (e SysUser) InsetAvatar(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserControl{} req := dto.SysUserControl{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -241,7 +241,7 @@ func (e SysUser) InsetSysUserAvatar(c *gin.Context) {
e.OK(filPath, "修改成功") e.OK(filPath, "修改成功")
} }
// UpdateSysUserStatus 修改用户状态 // UpdateStatus 修改用户状态
// @Summary 修改用户状态 // @Summary 修改用户状态
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -250,7 +250,7 @@ func (e SysUser) InsetSysUserAvatar(c *gin.Context) {
// @Param data body dto.UpdateSysUserStatusReq true "body" // @Param data body dto.UpdateSysUserStatusReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/status [put] // @Router /api/v1/user/status [put]
func (e SysUser) UpdateSysUserStatus(c *gin.Context) { func (e SysUser) UpdateStatus(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.UpdateSysUserStatusReq{} req := dto.UpdateSysUserStatusReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -277,7 +277,7 @@ func (e SysUser) UpdateSysUserStatus(c *gin.Context) {
e.OK(req.GetId(), "更新成功") e.OK(req.GetId(), "更新成功")
} }
// ResetSysUserPwd 重置用户密码 // ResetPwd 重置用户密码
// @Summary 重置用户密码 // @Summary 重置用户密码
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -286,7 +286,7 @@ func (e SysUser) UpdateSysUserStatus(c *gin.Context) {
// @Param data body dto.ResetSysUserPwdReq true "body" // @Param data body dto.ResetSysUserPwdReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/pwd/reset [put] // @Router /api/v1/user/pwd/reset [put]
func (e SysUser) ResetSysUserPwd(c *gin.Context) { func (e SysUser) ResetPwd(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.ResetSysUserPwdReq{} req := dto.ResetSysUserPwdReq{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -313,7 +313,7 @@ func (e SysUser) ResetSysUserPwd(c *gin.Context) {
e.OK(req.GetId(), "更新成功") e.OK(req.GetId(), "更新成功")
} }
// UpdateSysUserPwd // UpdatePwd
// @Summary 重置密码 // @Summary 重置密码
// @Description 获取JSON // @Description 获取JSON
// @Tags 用户 // @Tags 用户
@@ -323,7 +323,7 @@ func (e SysUser) ResetSysUserPwd(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/pwd [post] // @Router /api/v1/user/pwd [post]
// @Security Bearer // @Security Bearer
func (e SysUser) UpdateSysUserPwd(c *gin.Context) { func (e SysUser) UpdatePwd(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.PassWord{} req := dto.PassWord{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -349,14 +349,14 @@ func (e SysUser) UpdateSysUserPwd(c *gin.Context) {
e.OK(nil, "密码修改成功") e.OK(nil, "密码修改成功")
} }
// GetSysUserProfile // GetProfile
// @Summary 获取个人中心用户 // @Summary 获取个人中心用户
// @Description 获取JSON // @Description 获取JSON
// @Tags 个人中心 // @Tags 个人中心
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}" // @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/profile [get] // @Router /api/v1/user/profile [get]
// @Security Bearer // @Security Bearer
func (e SysUser) GetSysUserProfile(c *gin.Context) { func (e SysUser) GetProfile(c *gin.Context) {
s := service.SysUser{} s := service.SysUser{}
req := dto.SysUserById{} req := dto.SysUserById{}
err := e.MakeContext(c). err := e.MakeContext(c).
@@ -409,16 +409,12 @@ func (e SysUser) GetInfo(c *gin.Context) {
p := actions.GetPermissionFromContext(c) p := actions.GetPermissionFromContext(c)
var roles = make([]string, 1) var roles = make([]string, 1)
roles[0] = user.GetRoleName(c) roles[0] = user.GetRoleName(c)
var permissions = make([]string, 1) var permissions = make([]string, 1)
permissions[0] = "*:*:*" permissions[0] = "*:*:*"
var buttons = make([]string, 1) var buttons = make([]string, 1)
buttons[0] = "*:*:*" buttons[0] = "*:*:*"
RoleMenu := models.RoleMenu{} RoleMenu := models.RoleMenu{}
RoleMenu.RoleId = user.GetRoleId(c) RoleMenu.RoleId = user.GetRoleId(c)
var mp = make(map[string]interface{}) var mp = make(map[string]interface{})
mp["roles"] = roles mp["roles"] = roles
if user.GetRoleName(c) == "admin" || user.GetRoleName(c) == "系统管理员" { if user.GetRoleName(c) == "admin" || user.GetRoleName(c) == "系统管理员" {
@@ -429,19 +425,14 @@ func (e SysUser) GetInfo(c *gin.Context) {
mp["permissions"] = list mp["permissions"] = list
mp["buttons"] = list mp["buttons"] = list
} }
sysUser := models.SysUser{} sysUser := models.SysUser{}
req.Id = user.GetUserId(c) req.Id = user.GetUserId(c)
err = s.GetSysUser(&req, p, &sysUser) err = s.GetSysUser(&req, p, &sysUser)
if err != nil { if err != nil {
e.Error(http.StatusUnauthorized, err, "登录失败") e.Error(http.StatusUnauthorized, err, "登录失败")
return return
} }
mp["introduction"] = " am a super administrator" mp["introduction"] = " am a super administrator"
mp["avatar"] = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif" mp["avatar"] = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
if sysUser.Avatar != "" { if sysUser.Avatar != "" {
mp["avatar"] = sysUser.Avatar mp["avatar"] = sysUser.Avatar
@@ -451,4 +442,4 @@ func (e SysUser) GetInfo(c *gin.Context) {
mp["deptId"] = sysUser.DeptId mp["deptId"] = sysUser.DeptId
mp["name"] = sysUser.NickName mp["name"] = sysUser.NickName
e.OK(mp, "") e.OK(mp, "")
} }
+1 -1
View File
@@ -31,4 +31,4 @@ func (e *SysRole) Generate() models.ActiveRecord {
func (e *SysRole) GetId() interface{} { func (e *SysRole) GetId() interface{} {
return e.RoleId return e.RoleId
} }
+1 -1
View File
@@ -16,7 +16,7 @@ func registerSysConfigRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMidd
api := apis.SysConfig{} api := apis.SysConfig{}
r := v1.Group("/config").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r := v1.Group("/config").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
r.GET("", api.GetList) r.GET("", api.GetPage)
r.GET("/:id", api.Get) r.GET("/:id", api.Get)
r.POST("", api.Insert) r.POST("", api.Insert)
r.PUT("/:id", api.Update) r.PUT("/:id", api.Update)
+2 -2
View File
@@ -17,7 +17,7 @@ func registerSysDeptRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
r := v1.Group("/dept").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r := v1.Group("/dept").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
r.GET("", api.GetList) r.GET("", api.GetPage)
r.GET("/:id", api.Get) r.GET("/:id", api.Get)
r.POST("", api.Insert) r.POST("", api.Insert)
r.PUT("/:id", api.Update) r.PUT("/:id", api.Update)
@@ -29,4 +29,4 @@ func registerSysDeptRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
r1.GET("/deptTree", api.Get2Tree) r1.GET("/deptTree", api.Get2Tree)
} }
} }
+4 -4
View File
@@ -17,18 +17,18 @@ func registerDictRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlewar
dicts := v1.Group("/dict").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) dicts := v1.Group("/dict").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
dicts.GET("/data", dataApi.GetList) dicts.GET("/data", dataApi.GetPage)
dicts.GET("/data/:dictCode", dataApi.Get) dicts.GET("/data/:dictCode", dataApi.Get)
dicts.POST("/data", dataApi.Insert) dicts.POST("/data", dataApi.Insert)
dicts.PUT("/data/:dictCode", dataApi.Update) dicts.PUT("/data/:dictCode", dataApi.Update)
dicts.DELETE("/data", dataApi.Delete) dicts.DELETE("/data", dataApi.Delete)
dicts.GET("/type-option-select", dictApi.GetSysDictTypeAll) dicts.GET("/type-option-select", dictApi.GetAll)
dicts.GET("/type", dictApi.GetList) dicts.GET("/type", dictApi.GetPage)
dicts.GET("/type/:id", dictApi.Get) dicts.GET("/type/:id", dictApi.Get)
dicts.POST("/type", dictApi.Insert) dicts.POST("/type", dictApi.Insert)
dicts.PUT("/type/:id", dictApi.Update) dicts.PUT("/type/:id", dictApi.Update)
dicts.DELETE("/type", dictApi.Delete) dicts.DELETE("/type", dictApi.Delete)
} }
v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc()).GET("/option-select", dataApi.GetSysDictDataAll) v1.Group("/dict-data").Use(authMiddleware.MiddlewareFunc()).GET("/option-select", dataApi.GetSysDictDataAll)
} }
+2 -2
View File
@@ -17,8 +17,8 @@ func registerSysLoginLogRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMi
r := v1.Group("/sys-login-log").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r := v1.Group("/sys-login-log").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
r.GET("", api.GetList) r.GET("", api.GetPage)
r.GET("/:id", api.Get) r.GET("/:id", api.Get)
r.DELETE("", api.Delete) r.DELETE("", api.Delete)
} }
} }
+2 -2
View File
@@ -17,7 +17,7 @@ func registerSysMenuRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
r := v1.Group("/menu").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r := v1.Group("/menu").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
r.GET("", api.GetList) r.GET("", api.GetPage)
r.GET("/:id", api.Get) r.GET("/:id", api.Get)
r.POST("", api.Insert) r.POST("", api.Insert)
r.PUT("/:id", api.Update) r.PUT("/:id", api.Update)
@@ -30,4 +30,4 @@ func registerSysMenuRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
//r1.GET("/menuids", api.GetMenuIDS) //r1.GET("/menuids", api.GetMenuIDS)
} }
} }
+2 -2
View File
@@ -18,6 +18,6 @@ func registerSysOperaLogRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMi
{ {
r.GET("", api.GetPage) r.GET("", api.GetPage)
r.GET("/:id", api.Get) r.GET("/:id", api.Get)
r.DELETE("", api.Remove) r.DELETE("", api.Delete)
} }
} }
+6 -6
View File
@@ -16,10 +16,10 @@ func registerSyPostRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddlew
api := apis.SysPost{} api := apis.SysPost{}
r := v1.Group("/post").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r := v1.Group("/post").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
r.GET("", api.GetSysPostList) r.GET("", api.GetPage)
r.GET("/:id", api.GetSysPost) r.GET("/:id", api.Get)
r.POST("", api.InsertSysPost) r.POST("", api.Insert)
r.PUT("/:id", api.UpdateSysPost) r.PUT("/:id", api.Update)
r.DELETE("/:id", api.DeleteSysPost) r.DELETE("/:id", api.Delete)
} }
} }
+2 -2
View File
@@ -17,11 +17,11 @@ func registerSysRoleRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
api := apis.SysRole{} api := apis.SysRole{}
r := v1.Group("/role").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()) r := v1.Group("/role").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
{ {
r.GET("", api.GetList) r.GET("", api.GetPage)
r.GET("/:id", api.Get) r.GET("/:id", api.Get)
r.POST("", api.Insert) r.POST("", api.Insert)
r.PUT("/:id", api.Update) r.PUT("/:id", api.Update)
r.DELETE("", api.Delete) r.DELETE("", api.Delete)
} }
v1.PUT("/roledatascope", api.Update2DataScope) v1.PUT("/roledatascope", api.Update2DataScope)
} }
+11 -11
View File
@@ -17,23 +17,23 @@ func registerSysUserRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddle
api := apis.SysUser{} api := apis.SysUser{}
r := v1.Group("/sys-user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction()) r := v1.Group("/sys-user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction())
{ {
r.GET("", api.GetSysUserList) r.GET("", api.GetPage)
r.GET("/:id", api.GetSysUser) r.GET("/:id", api.Get)
r.POST("", api.InsertSysUser) r.POST("", api.Insert)
r.PUT("", api.UpdateSysUser) r.PUT("", api.Update)
r.DELETE("", api.DeleteSysUser) r.DELETE("", api.Delete)
} }
user := v1.Group("/user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction()) user := v1.Group("/user").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction())
{ {
user.GET("/profile", api.GetSysUserProfile) user.GET("/profile", api.GetProfile)
user.POST("/avatar", api.InsetSysUserAvatar) user.POST("/avatar", api.InsetAvatar)
user.PUT("/pwd", api.UpdateSysUserPwd) user.PUT("/pwd", api.UpdatePwd)
user.PUT("/pwd/reset", api.ResetSysUserPwd) user.PUT("/pwd/reset", api.ResetPwd)
user.PUT("/status", api.UpdateSysUserStatus) user.PUT("/status", api.UpdateStatus)
} }
v1auth := v1.Group("").Use(authMiddleware.MiddlewareFunc()) v1auth := v1.Group("").Use(authMiddleware.MiddlewareFunc())
{ {
v1auth.GET("/getinfo", api.GetInfo) v1auth.GET("/getinfo", api.GetInfo)
} }
} }
+6 -6
View File
@@ -10,8 +10,8 @@ import (
// SysMenuSearch 列表或者搜索使用结构体 // SysMenuSearch 列表或者搜索使用结构体
type SysMenuSearch struct { type SysMenuSearch struct {
dto.Pagination `search:"-"` dto.Pagination `search:"-"`
Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称 Title string `form:"title" search:"type:contains;column:title;table:sys_menu" comment:"菜单名称"` // 菜单名称
Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu" comment:"显示状态"` // 显示状态 Visible int `form:"visible" search:"type:exact;column:visible;table:sys_menu" comment:"显示状态"` // 显示状态
} }
func (m *SysMenuSearch) GetNeedSearch() interface{} { func (m *SysMenuSearch) GetNeedSearch() interface{} {
@@ -108,9 +108,9 @@ func (s *SysMenuById) GenerateM() (*models.SysMenu, error) {
} }
type MenuLabel struct { type MenuLabel struct {
Id int `json:"id" gorm:"-"` Id int `json:"id,omitempty" gorm:"-"`
Label string `json:"label" gorm:"-"` Label string `json:"label,omitempty" gorm:"-"`
Children []MenuLabel `json:"children" gorm:"-"` Children []MenuLabel `json:"children,omitempty" gorm:"-"`
} }
type MenuRole struct { type MenuRole struct {
@@ -120,4 +120,4 @@ type MenuRole struct {
type SelectRole struct { type SelectRole struct {
RoleId int `uri:"roleId"` RoleId int `uri:"roleId"`
} }
+3 -3
View File
@@ -150,7 +150,7 @@ func (e *SysMenu) Remove(d *dto.SysMenuById) *SysMenu {
return e return e
} }
// GetSysMenuList 获取菜单数据 // GetList 获取菜单数据
func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error { func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error {
var err error var err error
var data models.SysMenu var data models.SysMenu
@@ -167,7 +167,7 @@ func (e *SysMenu) GetList(c *dto.SysMenuSearch, list *[]models.SysMenu) error {
return nil return nil
} }
// SetSysMenuLabel 设置菜单数据 // SetLabel 修改角色中 设置菜单基础数据
func (e *SysMenu) SetLabel() (m []dto.MenuLabel, err error) { func (e *SysMenu) SetLabel() (m []dto.MenuLabel, err error) {
var list []models.SysMenu var list []models.SysMenu
err = e.GetList(&dto.SysMenuSearch{}, &list) err = e.GetList(&dto.SysMenuSearch{}, &list)
@@ -322,4 +322,4 @@ func (e *SysMenu) getByRoleName(roleName string) ([]models.SysMenu, error) {
e.Log.Errorf("db error:%s", err) e.Log.Errorf("db error:%s", err)
} }
return MenuList, err return MenuList, err
} }