✨ 新增几大中心功能
This commit is contained in:
32
server/model/system/invite_code.go
Normal file
32
server/model/system/invite_code.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type InviteCodeStatus string
|
||||
|
||||
const (
|
||||
InviteCodeStatusUnused InviteCodeStatus = "unused"
|
||||
InviteCodeStatusUsed InviteCodeStatus = "used"
|
||||
InviteCodeStatusRevoked InviteCodeStatus = "revoked"
|
||||
InviteCodeStatusExpired InviteCodeStatus = "expired"
|
||||
)
|
||||
|
||||
// InviteCode 邀请码(明文不落库,仅保存 hash)
|
||||
type InviteCode struct {
|
||||
ID uint `json:"id" gorm:"primaryKey"`
|
||||
CreatedByUserID uint `json:"createdByUserId" gorm:"index;not null;comment:邀请码生成者用户ID"`
|
||||
CodeHash string `json:"-" gorm:"uniqueIndex;size:64;not null;comment:邀请码hash(sha256 hex)"`
|
||||
CodeLast4 string `json:"codeLast4" gorm:"size:8;comment:邀请码末尾4位(展示)"`
|
||||
Status InviteCodeStatus `json:"status" gorm:"type:varchar(16);index;not null;comment:状态"`
|
||||
ExpiresAt *time.Time `json:"expiresAt" gorm:"index;comment:过期时间"`
|
||||
UsedByUserID *uint `json:"usedByUserId" gorm:"index;comment:使用者用户ID"`
|
||||
UsedAt *time.Time `json:"usedAt" gorm:"comment:使用时间"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
func (InviteCode) TableName() string {
|
||||
return "invite_codes"
|
||||
}
|
||||
Reference in New Issue
Block a user