feat: swagger
This commit is contained in:
@@ -14,6 +14,15 @@ import (
|
||||
type UserApi struct {
|
||||
}
|
||||
|
||||
// SaveUser
|
||||
// @tags 用户管理
|
||||
// @Summary 新增用户
|
||||
// @Security ApiKeyAuth
|
||||
// @accept json
|
||||
// @Produce json
|
||||
// @Param data body system.User true "用户信息"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": {}, "msg": "添加成功"}"
|
||||
// @Router /api/user/save [post]
|
||||
func (u *UserApi) SaveUser(c *gin.Context) {
|
||||
var user system.User
|
||||
err := c.ShouldBindJSON(&user)
|
||||
@@ -29,6 +38,15 @@ func (u *UserApi) SaveUser(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateUser
|
||||
// @tags 用户管理
|
||||
// @Summary 更新用户
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body system.User true "用户ID,用户信息"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/user/update [post]
|
||||
func (u *UserApi) UpdateUser(c *gin.Context) {
|
||||
var user system.User
|
||||
err := c.ShouldBindJSON(&user)
|
||||
@@ -44,6 +62,15 @@ func (u *UserApi) UpdateUser(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserList
|
||||
// @tags 用户管理
|
||||
// @Summary 获取用户列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body systemReq.GetUserList true "页码, 每页大小, 搜索条件"
|
||||
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取用户列表,返回包括列表,总数,页码,每页大小"
|
||||
// @Router /api/user/getUserList [post]
|
||||
func (u *UserApi) GetUserList(c *gin.Context) {
|
||||
var pageInfo systemReq.GetUserList
|
||||
err := c.ShouldBindJSON(&pageInfo)
|
||||
@@ -65,6 +92,15 @@ func (u *UserApi) GetUserList(c *gin.Context) {
|
||||
}, c)
|
||||
}
|
||||
|
||||
// Delete
|
||||
// @Tags 用户管理
|
||||
// @Summary 删除用户
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.IdsReq true "批量删除用户"
|
||||
// @Success 200 {object} response.Response{msg=string} "删除用户"
|
||||
// @Router /api/user/delete [post]
|
||||
func (u *UserApi) Delete(c *gin.Context) {
|
||||
var ids request.IdsReq
|
||||
err := c.ShouldBindJSON(&ids)
|
||||
@@ -81,6 +117,14 @@ func (u *UserApi) Delete(c *gin.Context) {
|
||||
response.OkWithMsg("删除用户成功!", c)
|
||||
}
|
||||
|
||||
// Detail
|
||||
// @Tags 用户管理
|
||||
// @Summary 获取用户详情
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Param id query string true "id"
|
||||
// @Success 200 {object} response.Response{data=system.User} "获取用户详情成功"
|
||||
// @Router /api/user/detail [get]
|
||||
func (u *UserApi) Detail(c *gin.Context) {
|
||||
id := c.Query("id")
|
||||
user, err := userService.GetUserById(id)
|
||||
@@ -92,6 +136,16 @@ func (u *UserApi) Detail(c *gin.Context) {
|
||||
response.OkWithData(user, c)
|
||||
}
|
||||
|
||||
// ChangePassword
|
||||
// @Tags 用户管理
|
||||
// @Summary 修改密码
|
||||
// @Security ApiKeyAuth
|
||||
// @Description 修改密码
|
||||
// @accept json
|
||||
// @Produce application/json
|
||||
// @Param data body request.ChangePwd true "用户id"
|
||||
// @Success 200 {object} response.Response{data=system.User} "修改密码成功"
|
||||
// @Router /api/user/changePassword [post]
|
||||
func (u *UserApi) ChangePassword(c *gin.Context) {
|
||||
var changePwd systemReq.ChangePwd
|
||||
err := c.ShouldBindJSON(&changePwd)
|
||||
@@ -108,6 +162,15 @@ func (u *UserApi) ChangePassword(c *gin.Context) {
|
||||
response.OkWithMsg("修改密码成功", c)
|
||||
}
|
||||
|
||||
// GrantRole
|
||||
// @Tags 用户管理
|
||||
// @Summary 给用户分配角色
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body systemReq.GrantRole true "用户ID, 角色ID"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/user/grantRole [post]
|
||||
func (u *UserApi) GrantRole(c *gin.Context) {
|
||||
var grantRole systemReq.GrantRole
|
||||
err := c.ShouldBindJSON(&grantRole)
|
||||
|
||||
Reference in New Issue
Block a user