feat(1.0):新增是否为管理员
This commit is contained in:
parent
133af38c19
commit
59a91064a2
@ -1008,6 +1008,10 @@ const docTemplate = `{
|
||||
"admin.loginResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"is_super": {
|
||||
"description": "是否是超级管理员(1:是 0:否)",
|
||||
"type": "integer"
|
||||
},
|
||||
"token": {
|
||||
"description": "登录成功后颁发的 Token",
|
||||
"type": "string"
|
||||
|
||||
@ -1000,6 +1000,10 @@
|
||||
"admin.loginResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"is_super": {
|
||||
"description": "是否是超级管理员(1:是 0:否)",
|
||||
"type": "integer"
|
||||
},
|
||||
"token": {
|
||||
"description": "登录成功后颁发的 Token",
|
||||
"type": "string"
|
||||
|
||||
@ -14,6 +14,9 @@ definitions:
|
||||
type: object
|
||||
admin.loginResponse:
|
||||
properties:
|
||||
is_super:
|
||||
description: 是否是超级管理员(1:是 0:否)
|
||||
type: integer
|
||||
token:
|
||||
description: 登录成功后颁发的 Token
|
||||
type: string
|
||||
|
||||
@ -22,7 +22,8 @@ type loginRequest struct {
|
||||
}
|
||||
|
||||
type loginResponse struct {
|
||||
Token string `json:"token"` // 登录成功后颁发的 Token
|
||||
Token string `json:"token"` // 登录成功后颁发的 Token
|
||||
IsSuper int32 `json:"is_super"` // 是否是超级管理员(1:是 0:否)
|
||||
}
|
||||
|
||||
// Login 管理员登录
|
||||
@ -93,6 +94,7 @@ func (h *handler) Login() core.HandlerFunc {
|
||||
Id: info.ID,
|
||||
UserName: info.Username,
|
||||
NickName: info.Nickname,
|
||||
IsSuper: info.IsSuper,
|
||||
Platform: "管理端",
|
||||
}
|
||||
|
||||
@ -120,6 +122,7 @@ func (h *handler) Login() core.HandlerFunc {
|
||||
}
|
||||
|
||||
res.Token = tokenString
|
||||
res.IsSuper = info.IsSuper
|
||||
ctx.Payload(res)
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ type SessionUserInfo struct {
|
||||
Id int32 `json:"id"` // ID
|
||||
UserName string `json:"username"` // 用户名
|
||||
NickName string `json:"nickname"` // 昵称
|
||||
IsSuper int32 `json:"is_super"` // 是否是超级管理员(1:是 0:否)
|
||||
Platform string `json:"platform"` // 平台
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@ func newAdmin(db *gorm.DB, opts ...gen.DOOption) admin {
|
||||
_admin.Nickname = field.NewString(tableName, "nickname")
|
||||
_admin.Mobile = field.NewString(tableName, "mobile")
|
||||
_admin.Password = field.NewString(tableName, "password")
|
||||
_admin.IsSuper = field.NewInt32(tableName, "is_super")
|
||||
_admin.LoginStatus = field.NewInt32(tableName, "login_status")
|
||||
_admin.LastLoginTime = field.NewTime(tableName, "last_login_time")
|
||||
_admin.LastLoginIP = field.NewString(tableName, "last_login_ip")
|
||||
@ -56,6 +57,7 @@ type admin struct {
|
||||
Nickname field.String // 昵称
|
||||
Mobile field.String // 手机号
|
||||
Password field.String // 密码
|
||||
IsSuper field.Int32 // 是否为超管(1:是 -1:否)
|
||||
LoginStatus field.Int32 // 登录状态(1:启用 0:禁用)
|
||||
LastLoginTime field.Time // 最后一次登录时间
|
||||
LastLoginIP field.String // 最后一次登录IP
|
||||
@ -85,6 +87,7 @@ func (a *admin) updateTableName(table string) *admin {
|
||||
a.Nickname = field.NewString(table, "nickname")
|
||||
a.Mobile = field.NewString(table, "mobile")
|
||||
a.Password = field.NewString(table, "password")
|
||||
a.IsSuper = field.NewInt32(table, "is_super")
|
||||
a.LoginStatus = field.NewInt32(table, "login_status")
|
||||
a.LastLoginTime = field.NewTime(table, "last_login_time")
|
||||
a.LastLoginIP = field.NewString(table, "last_login_ip")
|
||||
@ -109,12 +112,13 @@ func (a *admin) GetFieldByName(fieldName string) (field.OrderExpr, bool) {
|
||||
}
|
||||
|
||||
func (a *admin) fillFieldMap() {
|
||||
a.fieldMap = make(map[string]field.Expr, 13)
|
||||
a.fieldMap = make(map[string]field.Expr, 14)
|
||||
a.fieldMap["id"] = a.ID
|
||||
a.fieldMap["username"] = a.Username
|
||||
a.fieldMap["nickname"] = a.Nickname
|
||||
a.fieldMap["mobile"] = a.Mobile
|
||||
a.fieldMap["password"] = a.Password
|
||||
a.fieldMap["is_super"] = a.IsSuper
|
||||
a.fieldMap["login_status"] = a.LoginStatus
|
||||
a.fieldMap["last_login_time"] = a.LastLoginTime
|
||||
a.fieldMap["last_login_ip"] = a.LastLoginIP
|
||||
|
||||
@ -17,6 +17,7 @@ type Admin struct {
|
||||
Nickname string `gorm:"column:nickname;not null;comment:昵称" json:"nickname"` // 昵称
|
||||
Mobile string `gorm:"column:mobile;not null;comment:手机号" json:"mobile"` // 手机号
|
||||
Password string `gorm:"column:password;not null;comment:密码" json:"password"` // 密码
|
||||
IsSuper int32 `gorm:"column:is_super;not null;comment:是否为超管(1:是 -1:否)" json:"is_super"` // 是否为超管(1:是 -1:否)
|
||||
LoginStatus int32 `gorm:"column:login_status;not null;default:1;comment:登录状态(1:启用 0:禁用)" json:"login_status"` // 登录状态(1:启用 0:禁用)
|
||||
LastLoginTime time.Time `gorm:"column:last_login_time;not null;default:CURRENT_TIMESTAMP;comment:最后一次登录时间" json:"last_login_time"` // 最后一次登录时间
|
||||
LastLoginIP string `gorm:"column:last_login_ip;not null;comment:最后一次登录IP" json:"last_login_ip"` // 最后一次登录IP
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user