修改权限认证状态
This commit is contained in:
parent
3eaeddfd38
commit
79de15f061
@ -140,6 +140,11 @@ func (r *AdminUserDao) GetAdminUserPageSearch(req requests.GetAdminUserPage, pag
|
||||
query = query.Where("is_disabled = ?", req.IsDisabled)
|
||||
}
|
||||
|
||||
// 是否管理员
|
||||
if req.IsAdmin != nil {
|
||||
query = query.Where("is_admin = ?", req.IsAdmin)
|
||||
}
|
||||
|
||||
// 手机号
|
||||
if req.Phone != "" {
|
||||
query = query.Where("phone LIKE ?", "%"+req.Phone+"%")
|
||||
|
||||
@ -4,6 +4,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hepa-calc-admin-api/api/dao"
|
||||
"hepa-calc-admin-api/api/responses"
|
||||
"hepa-calc-admin-api/consts"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Auth Auth认证
|
||||
@ -21,31 +23,51 @@ func Auth() gin.HandlerFunc {
|
||||
adminUserDao := dao.AdminUserDao{}
|
||||
adminUser, err := adminUserDao.GetAdminUserById(adminUserId)
|
||||
if err != nil || adminUser == nil {
|
||||
responses.FailWithMessage("用户数据错误", c)
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "用户数据错误",
|
||||
"code": consts.UserStatusError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if adminUser.Status == 2 {
|
||||
responses.FailWithMessage("用户审核中", c)
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "用户审核中",
|
||||
"code": consts.UserStatusError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if adminUser.Status == 3 {
|
||||
responses.FailWithMessage("用户状态异常", c)
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "用户状态异常",
|
||||
"code": consts.UserStatusError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if adminUser.IsDisabled == 1 {
|
||||
responses.FailWithMessage("用户已被禁用", c)
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "用户已被禁用",
|
||||
"code": consts.UserStatusError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
if adminUser.IsDeleted == 1 {
|
||||
responses.FailWithMessage("用户状态异常", c)
|
||||
c.JSON(http.StatusUnauthorized, gin.H{
|
||||
"message": "用户状态异常",
|
||||
"code": consts.UserStatusError,
|
||||
"data": "",
|
||||
})
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ type AdminUserRequest struct {
|
||||
type GetAdminUserPage struct {
|
||||
Access string `json:"access" form:"access" label:"账号"`
|
||||
NickName string `json:"nick_name" form:"nick_name" label:"昵称"`
|
||||
IsAdmin int `json:"is_admin" form:"is_admin" label:"是否管理员"` // 是否管理员(0:否 1:是)
|
||||
IsAdmin *int `json:"is_admin" form:"is_admin" label:"是否管理员"` // 是否管理员(0:否 1:是)
|
||||
Status *int `json:"status" form:"status" label:"状态"` // 状态(1:正常 2:审核中 3:审核失败)
|
||||
IsDeleted *int `json:"is_deleted" form:"is_deleted" label:"是否被删除"` // 是否被删除(0:否 1:是)
|
||||
IsDisabled *int `json:"is_disabled" form:"is_disabled" label:"是否被禁用"` // 是否被禁用(0:否 1:是)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user