Files
opencatd-open/team/model/token.go
Sakurasan bc223d6530 team api
2025-02-01 23:52:55 +08:00

21 lines
1.0 KiB
Go

package model
// 用户的token
type Token struct {
ID int64 `gorm:"column:id;primaryKey;autoIncrement"`
UserID int64 `gorm:"column:user_id;not null;index:idx_token_user_id"`
Name string `gorm:"column:name;index:idx_token_name"`
Key string `gorm:"column:key;not null;uniqueIndex:idx_token_key;comment:token key"`
Status int64 `gorm:"column:status;default:1;check:status IN (0,1)"` // enabled 1, disabled 0
Quota int64 `gorm:"column:quota;type:bigint;default:0"` // default 0
UnlimitedQuota bool `gorm:"column:unlimited_quota;default:true"` // set Quota 1 unlimited
UsedQuota int64 `gorm:"column:used_quota;type:bigint;default:0"`
CreatedAt int64 `gorm:"column:created_at;type:bigint;autoCreateTime"`
ExpiredAt int64 `gorm:"column:expired_at;type:bigint;default:-1"` // -1 means never expired
User User `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"user"`
}
func (Token) TableName() string {
return "tokens"
}