feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
This commit is contained in:
31
internal/domain/login_log.go
Normal file
31
internal/domain/login_log.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
// LoginType 登录方式
|
||||
type LoginType int
|
||||
|
||||
const (
|
||||
LoginTypePassword LoginType = 1 // 用户名/邮箱/手机 + 密码
|
||||
LoginTypeEmailCode LoginType = 2 // 邮箱验证码
|
||||
LoginTypeSMSCode LoginType = 3 // 手机验证码
|
||||
LoginTypeOAuth LoginType = 4 // 第三方 OAuth
|
||||
)
|
||||
|
||||
// LoginLog 登录日志
|
||||
type LoginLog struct {
|
||||
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
UserID *int64 `gorm:"index" json:"user_id,omitempty"`
|
||||
LoginType int `gorm:"not null" json:"login_type"` // 1-密码, 2-邮箱验证码, 3-手机验证码, 4-OAuth
|
||||
DeviceID string `gorm:"type:varchar(100)" json:"device_id"`
|
||||
IP string `gorm:"type:varchar(50)" json:"ip"`
|
||||
Location string `gorm:"type:varchar(100)" json:"location"`
|
||||
Status int `gorm:"not null" json:"status"` // 0-失败, 1-成功
|
||||
FailReason string `gorm:"type:varchar(255)" json:"fail_reason,omitempty"`
|
||||
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
func (LoginLog) TableName() string {
|
||||
return "login_logs"
|
||||
}
|
||||
Reference in New Issue
Block a user