48 lines
1.8 KiB
Go
48 lines
1.8 KiB
Go
package model
|
||
|
||
import (
|
||
"blazing/cool"
|
||
)
|
||
|
||
// 表名常量(遵循小写+下划线的命名规范)
|
||
const TableNameSignInRecord = "player_sign_in_log"
|
||
|
||
// SignInRecord 玩家签到明细记录表
|
||
// 记录玩家每一次的签到行为,关联签到活动表
|
||
type SignInRecord struct {
|
||
Base
|
||
|
||
// 核心关联字段
|
||
PlayerID uint32 `gorm:"not null;index:idx_player_id;comment:'玩家ID'" json:"player_id"`
|
||
SignInID uint32 `gorm:"not null;index:idx_sign_in_id;comment:'关联的签到活动ID(对应player_sign_in表的SignInID)'" json:"sign_in_id"`
|
||
|
||
IsCompleted bool `gorm:"not null;default:false;comment:'签到是否完成(0-未完成 1-已完成)'" json:"is_completed"`
|
||
ContinuousDays uint32 `gorm:"not null;default:0;comment:'连续签到天数'" json:"continuous_days"`
|
||
TotalDays uint32 `gorm:"not null;default:0;comment:'累计签到天数'" json:"total_days"`
|
||
LastSignDate string `gorm:"type:varchar(10);not null;default:'';comment:'最近一次签到日期(YYYY-MM-DD)'" json:"last_sign_date"`
|
||
// 通过 bitset 记录每日签到状态,位索引从 0 开始,对应签到第 1 天。
|
||
SignInProgress []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'签到进度(状压实现,存储每日签到状态)'" json:"sign_in_progress"`
|
||
}
|
||
|
||
// TableName 指定表名(遵循现有规范)
|
||
func (*SignInRecord) TableName() string {
|
||
return TableNameSignInRecord
|
||
}
|
||
|
||
// GroupName 指定表分组(与现有表保持一致的default分组)
|
||
func (*SignInRecord) GroupName() string {
|
||
return "default"
|
||
}
|
||
|
||
// NewSignInRecord 创建签到明细记录实例(初始化基础Model)
|
||
func NewSignInRecord() *SignInRecord {
|
||
return &SignInRecord{
|
||
Base: *NewBase(),
|
||
}
|
||
}
|
||
|
||
// init 程序启动时自动创建表(与现有SignIn表初始化逻辑一致)
|
||
func init() {
|
||
cool.CreateTable(&SignInRecord{})
|
||
}
|