Browse Source

添加用户角色管理

2023
chenyifan01 2 years ago
parent
commit
ab0968bef9
1 changed files with 3 additions and 3 deletions
  1. +3
    -3
      routers/api/v1/admin/role.go

+ 3
- 3
routers/api/v1/admin/role.go View File

@@ -11,13 +11,13 @@ import (
func AddRole(ctx *context.APIContext, form models.AddRoleReq) { func AddRole(ctx *context.APIContext, form models.AddRoleReq) {
user, err := models.GetUserByName(form.UserName) user, err := models.GetUserByName(form.UserName)
if err != nil { if err != nil {
ctx.JSON(http.StatusOK, response.ServerError("User not exists"))
ctx.JSON(http.StatusOK, response.OuterServerError("User not exists"))
return return
} }
err = role.AddUserRole(user.ID, form.RoleType) err = role.AddUserRole(user.ID, form.RoleType)
if err != nil { if err != nil {
ctx.JSON(http.StatusOK, response.ResponseError(err))
ctx.JSON(http.StatusOK, response.OuterResponseError(err))
return return
} }
ctx.JSON(http.StatusOK, response.Success())
ctx.JSON(http.StatusOK, response.OuterSuccess())
} }

Loading…
Cancel
Save