Files
platform/web/models/logs_login.go

40 lines
1.6 KiB
Go

package models
import (
"platform/web/globals/orm"
"time"
)
// LogsLogin 登录日志表
type LogsLogin struct {
ID int32 `json:"id" gorm:"column:id"` // 登录日志ID
IP orm.Inet `json:"ip" gorm:"column:ip;not null"` // IP地址
UA string `json:"ua" gorm:"column:ua"` // 用户代理
GrantType GrantType `json:"grant_type" gorm:"column:grant_type"` // 授权类型
PasswordType PasswordType `json:"password_type" gorm:"column:password_type"` // 密码模式子授权类型
Success bool `json:"success" gorm:"column:success"` // 登录是否成功
UserID *int32 `json:"user_id,omitempty" gorm:"column:user_id"` // 用户ID
Time time.Time `json:"time" gorm:"column:time"` // 登录时间
User *User `json:"user,omitempty" gorm:"foreignKey:UserID"`
}
// GrantType 授权类型枚举
type GrantType string
const (
GrantTypeAuthorizationCode GrantType = "authorization_code" // 授权码模式
GrantTypeClientCredentials GrantType = "client_credentials" // 客户端凭证模式
GrantTypeRefreshToken GrantType = "refresh_token" // 刷新令牌模式
GrantTypePassword GrantType = "password" // 密码模式
)
// PasswordType 密码模式子授权类型枚举
type PasswordType string
const (
PasswordTypePassword PasswordType = "password" // 账号密码
PasswordTypePhoneCode PasswordType = "phone_code" // 手机验证码
PasswordTypeEmailCode PasswordType = "email_code" // 邮箱验证码
)