feat: 添加种子数据初始化功能,重构多个处理程序以简化错误响应和用户验证
This commit is contained in:
@@ -2,13 +2,19 @@ package model
|
||||
|
||||
import "time"
|
||||
|
||||
// Token Yggdrasil 认证令牌模型
|
||||
type Token struct {
|
||||
AccessToken string `json:"_id"`
|
||||
UserID int64 `json:"user_id"`
|
||||
ClientToken string `json:"client_token"`
|
||||
ProfileId string `json:"profile_id"`
|
||||
Usable bool `json:"usable"`
|
||||
IssueDate time.Time `json:"issue_date"`
|
||||
AccessToken string `gorm:"column:access_token;type:varchar(64);primaryKey" json:"access_token"`
|
||||
UserID int64 `gorm:"column:user_id;not null;index:idx_tokens_user_id" json:"user_id"`
|
||||
ClientToken string `gorm:"column:client_token;type:varchar(64);not null;index:idx_tokens_client_token" json:"client_token"`
|
||||
ProfileId string `gorm:"column:profile_id;type:varchar(36);not null;index:idx_tokens_profile_id" json:"profile_id"`
|
||||
Usable bool `gorm:"column:usable;not null;default:true;index:idx_tokens_usable" json:"usable"`
|
||||
IssueDate time.Time `gorm:"column:issue_date;type:timestamp;not null;default:CURRENT_TIMESTAMP;index:idx_tokens_issue_date,sort:desc" json:"issue_date"`
|
||||
|
||||
// 关联
|
||||
User *User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE" json:"user,omitempty"`
|
||||
Profile *Profile `gorm:"foreignKey:ProfileId;references:UUID;constraint:OnDelete:CASCADE" json:"profile,omitempty"`
|
||||
}
|
||||
|
||||
func (Token) TableName() string { return "token" }
|
||||
// TableName 指定表名
|
||||
func (Token) TableName() string { return "tokens" }
|
||||
|
||||
Reference in New Issue
Block a user