feat:完善项目
This commit is contained in:
105
app/api/user.go
105
app/api/user.go
@ -215,7 +215,7 @@ func (*User) Delete(c *gin.Context) {
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Json} data 数据信息
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
@ -253,7 +253,7 @@ func (*User) PasswordQuick(c *gin.Context) {
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Json} data 数据信息
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
@ -291,7 +291,7 @@ func (*User) PasswordTradition(c *gin.Context) {
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Json} data 数据信息
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
@ -313,9 +313,9 @@ func (*User) Activate(c *gin.Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/password/frozen( 用户账号冻结
|
||||
* @api {get} /api/v1/user/password/frozen 用户账号冻结
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserPasswordFrozen(
|
||||
* @apiName UserPasswordFrozen
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
@ -324,7 +324,7 @@ func (*User) Activate(c *gin.Context) {
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Json} data 数据信息
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
@ -344,3 +344,96 @@ func (*User) Frozen(c *gin.Context) {
|
||||
err := user.NewInstance()(getSession()(c).(*service.Session)).Status(form.Convert(), model2.SysUserStatusForDisable)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/role 用户角色信息
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserRole
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
* @apiSuccess (200) {String} data.id 角色ID
|
||||
* @apiSuccess (200) {String} data.name 角色名称
|
||||
* @apiSuccess (200) {String} data.parent_id 角色父集ID
|
||||
* @apiSuccess (200) {Object} data.children 子集
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": [
|
||||
* {
|
||||
* "id": "EgmJ4Ga7LQ",
|
||||
* "name": "分管领导",
|
||||
* "parent_id": "0",
|
||||
* "checked": true,
|
||||
* "children": [
|
||||
* {
|
||||
* "id": "7K1Jx6VYod",
|
||||
* "name": "区域支队",
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
func (a *User) Role(c *gin.Context) {
|
||||
form := new(IDStringForm)
|
||||
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
data, err := user.NewRole()(getSession()(c).(*service.Session)).List(form.Convert())
|
||||
APIResponse(err, data)(c)
|
||||
}
|
||||
|
||||
/**
|
||||
* @api {get} /api/v1/user/role/bind 用户角色绑定
|
||||
* @apiVersion 1.0.0
|
||||
* @apiName UserRoleBind
|
||||
* @apiGroup User
|
||||
*
|
||||
* @apiHeader {string} x-token token
|
||||
*
|
||||
* @apiParam {String} id ID
|
||||
* @apiParam {Array.string} role_ids 角色IDs
|
||||
*
|
||||
* @apiSuccess (200) {Number} code 成功响应状态码!
|
||||
* @apiSuccess (200) {String} msg 成功提示
|
||||
* @apiSuccess (200) {Object} data 数据信息
|
||||
*
|
||||
* @apiSuccessExample {json} Success response:
|
||||
* HTTPS 200 OK
|
||||
* {
|
||||
* "code": 200
|
||||
* "msg": "ok"
|
||||
* "data": null
|
||||
* }
|
||||
*/
|
||||
func (a *User) RoleBind(c *gin.Context) {
|
||||
form := &struct {
|
||||
IDStringForm
|
||||
RoleIDs []string `json:"role_ids" form:"role_ids" binding:"required"`
|
||||
}{}
|
||||
if err := bind(form)(c); err != nil {
|
||||
APIFailure(err.(error))(c)
|
||||
return
|
||||
}
|
||||
obj := new(IDStringForm)
|
||||
roleIDs := make([]uint64, 0)
|
||||
|
||||
for _, v := range form.RoleIDs {
|
||||
obj.ID = v
|
||||
roleIDs = append(roleIDs, obj.Convert())
|
||||
}
|
||||
err := user.NewRole()(getSession()(c).(*service.Session)).Bind(form.Convert(), roleIDs)
|
||||
APIResponse(err)(c)
|
||||
}
|
||||
|
Reference in New Issue
Block a user