refactor🎨: 缩减函数名称

This commit is contained in:
wenjianzhang committed 2021-06-07 20:37:01 +08:00
1 parent c96d9c35a7
commit 9a2c0729f6
22 files changed
+111 -126

No files matched your search

+3 -3
View File
@@ -15,7 +15,7 @@ type SysConfig struct {
api.Api
}
// GetList 获取配置管理列表
// GetPage 获取配置管理列表
// @Summary 获取配置管理列表
// @Description 获取配置管理列表
// @Tags 配置管理
@@ -28,7 +28,7 @@ type SysConfig struct {
// @Success 200 {object} response.Response{data=response.Page{list=[]models.SysApi}} "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-config [get]
// @Security Bearer
func (e SysConfig) GetList(c *gin.Context) {
func (e SysConfig) GetPage(c *gin.Context) {
s := service.SysConfig{}
req := dto.SysConfigSearch{}
err := e.MakeContext(c).
@@ -311,4 +311,4 @@ func (e SysConfig) GetSysConfigByKEYForService(c *gin.Context) {
return
}
e.OK(resp, s.Msg)
}
}
+3 -3
View File
@@ -17,7 +17,7 @@ type SysDept struct {
api.Api
}
// GetList
// GetPage
// @Summary 分页部门列表数据
// @Description 分页列表
// @Tags 部门
@@ -27,7 +27,7 @@ type SysDept struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dept [get]
// @Security Bearer
func (e SysDept) GetList(c *gin.Context) {
func (e SysDept) GetPage(c *gin.Context) {
s := service.SysDept{}
req := dto.SysDeptSearch{}
err := e.MakeContext(c).
@@ -235,4 +235,4 @@ func (e SysDept) GetDeptTreeRoleSelect(c *gin.Context) {
"depts": result,
"checkedKeys": menuIds,
}, "")
}
}
+2 -2
View File
@@ -18,7 +18,7 @@ type SysDictData struct {
api.Api
}
// GetList
// GetPage
// @Summary 字典数据列表
// @Description 获取JSON
// @Tags 字典数据
@@ -30,7 +30,7 @@ type SysDictData struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/data [get]
// @Security Bearer
func (e SysDictData) GetList(c *gin.Context) {
func (e SysDictData) GetPage(c *gin.Context) {
s := service.SysDictData{}
req := dto.SysDictDataSearch{}
err := e.MakeContext(c).
+8 -8
View File
@@ -18,7 +18,7 @@ type SysDictType struct {
api.Api
}
// GetSysDictTypeList 字典类型列表数据
// GetPage 字典类型列表数据
// @Summary 字典类型列表数据
// @Description 获取JSON
// @Tags 字典类型
@@ -30,7 +30,7 @@ type SysDictType struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/type [get]
// @Security Bearer
func (e SysDictType) GetList(c *gin.Context) {
func (e SysDictType) GetPage(c *gin.Context) {
s := service.SysDictType{}
req := dto.SysDictTypeSearch{}
err := e.MakeContext(c).
@@ -53,7 +53,7 @@ func (e SysDictType) GetList(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
// GetSysDictType 字典类型通过字典id获取
// Get 字典类型通过字典id获取
// @Summary 字典类型通过字典id获取
// @Description 获取JSON
// @Tags 字典类型
@@ -83,7 +83,7 @@ func (e SysDictType) Get(c *gin.Context) {
e.OK(object, "查看成功")
}
//InsertSysDictType 字典类型创建
//Insert 字典类型创建
// @Summary 添加字典类型
// @Description 获取JSON
// @Tags 字典类型
@@ -117,7 +117,7 @@ func (e SysDictType) Insert(c *gin.Context) {
e.OK(req.GetId(), "创建成功")
}
// UpdateSysDictType
// Update
// @Summary 修改字典类型
// @Description 获取JSON
// @Tags 字典类型
@@ -150,7 +150,7 @@ func (e SysDictType) Update(c *gin.Context) {
e.OK(req.GetId(), "更新成功")
}
// DeleteSysDictType
// Delete
// @Summary 删除字典类型
// @Description 删除数据
// @Tags 字典类型
@@ -180,7 +180,7 @@ func (e SysDictType) Delete(c *gin.Context) {
e.OK(req.GetId(), "删除成功")
}
// GetSysDictTypeAll
// GetAll
// @Summary 字典类型全部数据 代码生成使用接口
// @Description 获取JSON
// @Tags 字典类型
@@ -190,7 +190,7 @@ func (e SysDictType) Delete(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/dict/type-option-select [get]
// @Security Bearer
func (e SysDictType) GetSysDictTypeAll(c *gin.Context) {
func (e SysDictType) GetAll(c *gin.Context) {
s := service.SysDictType{}
req := dto.SysDictTypeSearch{}
err := e.MakeContext(c).
+2 -2
View File
@@ -15,7 +15,7 @@ type SysLoginLog struct {
api.Api
}
// GetSysLoginLogList 登录日志列表
// GetPage 登录日志列表
// @Summary 登录日志列表
// @Description 获取JSON
// @Tags 登录日志
@@ -28,7 +28,7 @@ type SysLoginLog struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-login-log [get]
// @Security Bearer
func (e SysLoginLog) GetList(c *gin.Context) {
func (e SysLoginLog) GetPage(c *gin.Context) {
s := service.SysLoginLog{}
req := dto.SysLoginLogSearch {}
err := e.MakeContext(c).
+7 -7
View File
@@ -17,7 +17,7 @@ type SysMenu struct {
api.Api
}
// GetSysMenuList Menu列表数据
// GetPage Menu列表数据
// @Summary Menu列表数据
// @Description 获取JSON
// @Tags 菜单
@@ -26,7 +26,7 @@ type SysMenu struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/menu [get]
// @Security Bearer
func (e SysMenu) GetList(c *gin.Context) {
func (e SysMenu) GetPage(c *gin.Context) {
s := service.SysMenu{}
req := dto.SysMenuSearch{}
err := e.MakeContext(c).
@@ -48,7 +48,7 @@ func (e SysMenu) GetList(c *gin.Context) {
e.OK(list, "查询成功")
}
// GetSysMenu 获取菜单详情
// Get 获取菜单详情
// @Summary Menu详情数据
// @Description 获取JSON
// @Tags 菜单
@@ -79,7 +79,7 @@ func (e SysMenu) Get(c *gin.Context) {
e.OK(object, "查看成功")
}
// InsertSysMenu 创建菜单
// Insert 创建菜单
// @Summary 创建菜单
// @Description 获取JSON
// @Tags 菜单
@@ -112,7 +112,7 @@ func (e SysMenu) Insert(c *gin.Context) {
e.OK(req.GetId(), "创建成功")
}
// UpdateSysMenu 修改菜单
// Update 修改菜单
// @Summary 修改菜单
// @Description 获取JSON
// @Tags 菜单
@@ -146,7 +146,7 @@ func (e SysMenu) Update(c *gin.Context) {
e.OK(req.GetId(), "更新成功")
}
// DeleteSysMenu 删除菜单
// Delete 删除菜单
// @Summary 删除菜单
// @Description 删除数据
// @Tags 菜单
@@ -279,4 +279,4 @@ func (e SysMenu) GetMenuTreeSelect(c *gin.Context) {
"menus": result,
"checkedKeys": menuIds,
}, "获取成功")
}
}
+2 -2
View File
@@ -86,7 +86,7 @@ func (e SysOperaLog) Get(c *gin.Context) {
e.OK(object, "查看成功")
}
// Remove 操作日志删除
// Delete 操作日志删除
// DeleteSysMenu 操作日志删除
// @Summary 删除操作日志
// @Description 删除数据
@@ -94,7 +94,7 @@ func (e SysOperaLog) Get(c *gin.Context) {
// @Param data body dto.SysOperaLogById true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @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)
req := new(dto.SysOperaLogById)
err := e.MakeContext(c).
+13 -19
View File
@@ -18,7 +18,7 @@ type SysPost struct {
api.Api
}
// GetSysPostList
// GetPage
// @Summary 岗位列表数据
// @Description 获取JSON
// @Tags 岗位
@@ -29,7 +29,7 @@ type SysPost struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post [get]
// @Security Bearer
func (e SysPost) GetSysPostList(c *gin.Context) {
func (e SysPost) GetPage(c *gin.Context) {
s := service.SysPost{}
req := dto.SysPostSearch{}
err := e.MakeContext(c).
@@ -55,7 +55,7 @@ func (e SysPost) GetSysPostList(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
// GetSysPost
// Get
// @Summary 获取岗位信息
// @Description 获取JSON
// @Tags 岗位
@@ -63,7 +63,7 @@ func (e SysPost) GetSysPostList(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/post/{postId} [get]
// @Security Bearer
func (e SysPost) GetSysPost(c *gin.Context) {
func (e SysPost) Get(c *gin.Context) {
s := service.SysPost{}
req := dto.SysPostById{}
err := e.MakeContext(c).
@@ -80,14 +80,14 @@ func (e SysPost) GetSysPost(c *gin.Context) {
err = s.GetSysPost(&req, &object)
if err != nil {
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
e.Error(500, err, "查询失败")
return
}
e.OK(object, "查看成功")
}
// InsertSysPost
// Insert
// @Summary 添加岗位
// @Description 获取JSON
// @Tags 岗位
@@ -98,7 +98,7 @@ func (e SysPost) GetSysPost(c *gin.Context) {
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/post [post]
// @Security Bearer
func (e SysPost) InsertSysPost(c *gin.Context) {
func (e SysPost) Insert(c *gin.Context) {
s := service.SysPost{}
req := dto.SysPostControl{}
err := e.MakeContext(c).
@@ -111,21 +111,16 @@ func (e SysPost) InsertSysPost(c *gin.Context) {
e.Error(500, err, err.Error())
return
}
// 设置创建人
req.SetCreateBy(user.GetUserId(c))
err = s.InsertSysPost(&req)
if err != nil {
e.Logger.Error(err)
e.Error(http.StatusInternalServerError, err, "创建失败")
e.Error(500, err, "创建失败")
return
}
e.OK(req.GetId(), "创建成功")
}
// UpdateSysPost
// Update
// @Summary 修改岗位
// @Description 获取JSON
// @Tags 岗位
@@ -136,7 +131,7 @@ func (e SysPost) InsertSysPost(c *gin.Context) {
// @Success 200 {string} string "{"code": -1, "message": "添加失败"}"
// @Router /api/v1/post/ [put]
// @Security Bearer
func (e SysPost) UpdateSysPost(c *gin.Context) {
func (e SysPost) Update(c *gin.Context) {
s := service.SysPost{}
req := dto.SysPostControl{}
err := e.MakeContext(c).
@@ -160,7 +155,7 @@ func (e SysPost) UpdateSysPost(c *gin.Context) {
e.OK(req.GetId(), "更新成功")
}
// DeleteSysPost
// Delete
// @Summary 删除岗位
// @Description 删除数据
// @Tags 岗位
@@ -168,7 +163,7 @@ func (e SysPost) UpdateSysPost(c *gin.Context) {
// @Success 200 {string} string "{"code": 200, "message": "删除成功"}"
// @Success 500 {string} string "{"code": 500, "message": "删除失败"}"
// @Router /api/v1/post/{postId} [delete]
func (e SysPost) DeleteSysPost(c *gin.Context) {
func (e SysPost) Delete(c *gin.Context) {
s := service.SysPost{}
req := dto.SysPostById{}
err := e.MakeContext(c).
@@ -182,11 +177,10 @@ func (e SysPost) DeleteSysPost(c *gin.Context) {
return
}
req.SetUpdateBy(user.GetUserId(c))
err = s.RemoveSysPost(&req)
if err != nil {
e.Logger.Error(err)
return
}
e.OK(req.GetId(), "删除成功")
}
}
+6 -6
View File
@@ -20,7 +20,7 @@ type SysRole struct {
api.Api
}
// GetList
// GetPage
// @Summary 角色列表数据
// @Description Get JSON
// @Tags 角色/Role
@@ -32,7 +32,7 @@ type SysRole struct {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/role [get]
// @Security Bearer
func (e SysRole) GetList(c *gin.Context) {
func (e SysRole) GetPage(c *gin.Context) {
s := service.SysRole{}
req := dto.SysRoleSearch{}
err := e.MakeContext(c).
@@ -122,8 +122,8 @@ func (e SysRole) Insert(c *gin.Context) {
if req.Status == "" {
req.Status = "2"
}
err = s.Insert(&req)
cb := sdk.Runtime.GetCasbinKey(c.Request.Host)
err = s.Insert(&req, cb)
if err != nil {
e.Logger.Error(err)
e.Error(500, err, "创建失败")
@@ -148,7 +148,7 @@ func (e SysRole) Insert(c *gin.Context) {
// @Success 200 {string} string "{"code": -1, "message": "修改失败"}"
// @Router /api/v1/role/{id} [put]
// @Security Bearer
func (e SysRole) Update (c *gin.Context) {
func (e SysRole) Update(c *gin.Context) {
s := service.SysRole{}
req := dto.SysRoleControl{}
err := e.MakeContext(c).
@@ -241,4 +241,4 @@ func (e SysRole) Update2DataScope(c *gin.Context) {
return
}
e.OK(nil, "操作成功")
}
}
+23 -32
View File
@@ -20,7 +20,7 @@ type SysUser struct {
api.Api
}
// GetSysUserList
// GetPage
// @Summary 列表用户信息数据
// @Description 获取JSON
// @Tags 用户
@@ -28,7 +28,7 @@ type SysUser struct {
// @Success 200 {string} {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-user [get]
// @Security Bearer
func (e SysUser) GetSysUserList(c *gin.Context) {
func (e SysUser) GetPage(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserSearch{}
err := e.MakeContext(c).
@@ -57,7 +57,7 @@ func (e SysUser) GetSysUserList(c *gin.Context) {
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
}
// GetSysUser
// Get
// @Summary 获取用户
// @Description 获取JSON
// @Tags 用户
@@ -65,7 +65,7 @@ func (e SysUser) GetSysUserList(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysUser/{userId} [get]
// @Security Bearer
func (e SysUser) GetSysUser(c *gin.Context) {
func (e SysUser) Get(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserById{}
err := e.MakeContext(c).
@@ -89,7 +89,7 @@ func (e SysUser) GetSysUser(c *gin.Context) {
e.OK(object, "查看成功")
}
// InsertSysUser
// Insert
// @Summary 创建用户
// @Description 获取JSON
// @Tags 用户
@@ -98,7 +98,7 @@ func (e SysUser) GetSysUser(c *gin.Context) {
// @Param data body dto.SysUserControl true "用户数据"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysUser [post]
func (e SysUser) InsertSysUser(c *gin.Context) {
func (e SysUser) Insert(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserControl{}
err := e.MakeContext(c).
@@ -123,7 +123,7 @@ func (e SysUser) InsertSysUser(c *gin.Context) {
e.OK(req.GetId(), "创建成功")
}
// UpdateSysUser
// Update
// @Summary 修改用户数据
// @Description 获取JSON
// @Tags 用户
@@ -132,7 +132,7 @@ func (e SysUser) InsertSysUser(c *gin.Context) {
// @Param data body dto.SysUserControl true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sys-user/{userId} [put]
func (e SysUser) UpdateSysUser(c *gin.Context) {
func (e SysUser) Update(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserControl{}
err := e.MakeContext(c).
@@ -159,14 +159,14 @@ func (e SysUser) UpdateSysUser(c *gin.Context) {
e.OK(req.GetId(), "更新成功")
}
// DeleteSysUser
// Delete
// @Summary 删除用户数据
// @Description 删除数据
// @Tags 用户
// @Param userId path int true "userId"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/sysuser/{userId} [delete]
func (e SysUser) DeleteSysUser(c *gin.Context) {
// @Router /api/v1/sys-user/{userId} [delete]
func (e SysUser) Delete(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserById{}
err := e.MakeContext(c).
@@ -194,15 +194,15 @@ func (e SysUser) DeleteSysUser(c *gin.Context) {
e.OK(req.GetId(), "删除成功")
}
// InsetSysUserAvatar
// InsetAvatar
// @Summary 修改头像
// @Description 获取JSON
// @Tags 用户
// @Tags 个人中心
// @Accept multipart/form-data
// @Param file formData file true "file"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/avatar [post]
func (e SysUser) InsetSysUserAvatar(c *gin.Context) {
func (e SysUser) InsetAvatar(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserControl{}
err := e.MakeContext(c).
@@ -241,7 +241,7 @@ func (e SysUser) InsetSysUserAvatar(c *gin.Context) {
e.OK(filPath, "修改成功")
}
// UpdateSysUserStatus 修改用户状态
// UpdateStatus 修改用户状态
// @Summary 修改用户状态
// @Description 获取JSON
// @Tags 用户
@@ -250,7 +250,7 @@ func (e SysUser) InsetSysUserAvatar(c *gin.Context) {
// @Param data body dto.UpdateSysUserStatusReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/status [put]
func (e SysUser) UpdateSysUserStatus(c *gin.Context) {
func (e SysUser) UpdateStatus(c *gin.Context) {
s := service.SysUser{}
req := dto.UpdateSysUserStatusReq{}
err := e.MakeContext(c).
@@ -277,7 +277,7 @@ func (e SysUser) UpdateSysUserStatus(c *gin.Context) {
e.OK(req.GetId(), "更新成功")
}
// ResetSysUserPwd 重置用户密码
// ResetPwd 重置用户密码
// @Summary 重置用户密码
// @Description 获取JSON
// @Tags 用户
@@ -286,7 +286,7 @@ func (e SysUser) UpdateSysUserStatus(c *gin.Context) {
// @Param data body dto.ResetSysUserPwdReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/pwd/reset [put]
func (e SysUser) ResetSysUserPwd(c *gin.Context) {
func (e SysUser) ResetPwd(c *gin.Context) {
s := service.SysUser{}
req := dto.ResetSysUserPwdReq{}
err := e.MakeContext(c).
@@ -313,7 +313,7 @@ func (e SysUser) ResetSysUserPwd(c *gin.Context) {
e.OK(req.GetId(), "更新成功")
}
// UpdateSysUserPwd
// UpdatePwd
// @Summary 重置密码
// @Description 获取JSON
// @Tags 用户
@@ -323,7 +323,7 @@ func (e SysUser) ResetSysUserPwd(c *gin.Context) {
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/pwd [post]
// @Security Bearer
func (e SysUser) UpdateSysUserPwd(c *gin.Context) {
func (e SysUser) UpdatePwd(c *gin.Context) {
s := service.SysUser{}
req := dto.PassWord{}
err := e.MakeContext(c).
@@ -349,14 +349,14 @@ func (e SysUser) UpdateSysUserPwd(c *gin.Context) {
e.OK(nil, "密码修改成功")
}
// GetSysUserProfile
// GetProfile
// @Summary 获取个人中心用户
// @Description 获取JSON
// @Tags 个人中心
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
// @Router /api/v1/user/profile [get]
// @Security Bearer
func (e SysUser) GetSysUserProfile(c *gin.Context) {
func (e SysUser) GetProfile(c *gin.Context) {
s := service.SysUser{}
req := dto.SysUserById{}
err := e.MakeContext(c).
@@ -409,16 +409,12 @@ func (e SysUser) GetInfo(c *gin.Context) {
p := actions.GetPermissionFromContext(c)
var roles = make([]string, 1)
roles[0] = user.GetRoleName(c)
var permissions = make([]string, 1)
permissions[0] = "*:*:*"
var buttons = make([]string, 1)
buttons[0] = "*:*:*"
RoleMenu := models.RoleMenu{}
RoleMenu.RoleId = user.GetRoleId(c)
var mp = make(map[string]interface{})
mp["roles"] = roles
if user.GetRoleName(c) == "admin" || user.GetRoleName(c) == "系统管理员" {
@@ -429,19 +425,14 @@ func (e SysUser) GetInfo(c *gin.Context) {
mp["permissions"] = list
mp["buttons"] = list
}
sysUser := models.SysUser{}
req.Id = user.GetUserId(c)
err = s.GetSysUser(&req, p, &sysUser)
if err != nil {
e.Error(http.StatusUnauthorized, err, "登录失败")
return
}
mp["introduction"] = " am a super administrator"
mp["avatar"] = "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
if sysUser.Avatar != "" {
mp["avatar"] = sysUser.Avatar
@@ -451,4 +442,4 @@ func (e SysUser) GetInfo(c *gin.Context) {
mp["deptId"] = sysUser.DeptId
mp["name"] = sysUser.NickName
e.OK(mp, "")
}
}