Files
Go-Web-Template/server/model/app/app_invite_code.go
2026-04-23 15:29:07 +08:00

31 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package app
import "time"
type InviteCodeStatus string
const (
InviteCodeStatusUnused InviteCodeStatus = "unused"
InviteCodeStatusUsed InviteCodeStatus = "used"
InviteCodeStatusRevoked InviteCodeStatus = "revoked"
InviteCodeStatusExpired InviteCodeStatus = "expired"
)
// AppInviteCode 玩家邀请码(明文不落库,仅保存 hash
type AppInviteCode struct {
ID uint `json:"id" gorm:"primaryKey"`
CreatedByUserID uint `json:"createdByUserId" gorm:"index;not null"`
CodeHash string `json:"-" gorm:"uniqueIndex;size:64;not null"`
CodeLast4 string `json:"codeLast4" gorm:"size:8"`
Status InviteCodeStatus `json:"status" gorm:"type:varchar(16);index;not null"`
ExpiresAt *time.Time `json:"expiresAt" gorm:"index"`
UsedByUserID *uint `json:"usedByUserId" gorm:"index"`
UsedAt *time.Time `json:"usedAt"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (AppInviteCode) TableName() string {
return "app_invite_codes"
}