41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// HPChangeLog 记录每次 HP 变动明细,用于:
|
|
// - 首页展示“今日 +x / -x”
|
|
// - 后续趋势图、剧情、监督机制的数据基础
|
|
type HPChangeLog struct {
|
|
ID uint `gorm:"primaryKey;comment:主键" json:"id"`
|
|
CreatedAt time.Time `gorm:"comment:创建时间" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"comment:更新时间" json:"updated_at"`
|
|
DeletedAt gorm.DeletedAt `gorm:"index;comment:删除时间" json:"-"`
|
|
|
|
UID int `gorm:"index;comment:用户ID" json:"-"`
|
|
|
|
// ChangeDate 用于按自然日聚合(例如:统计“今日变动”)。
|
|
ChangeDate time.Time `gorm:"column:change_date;type:date;index;comment:所属自然日" json:"change_date"`
|
|
ChangeAt time.Time `gorm:"column:change_at;comment:变动时间" json:"change_at"`
|
|
|
|
Delta int `gorm:"column:delta;comment:变动值(可正可负)" json:"delta"`
|
|
HPBefore int `gorm:"column:hp_before;comment:变动前HP" json:"hp_before"`
|
|
HPAfter int `gorm:"column:hp_after;comment:变动后HP" json:"hp_after"`
|
|
Reason string `gorm:"column:reason;size:64;index;comment:变动原因(checkin|smoke|relapse|migrate_init...)" json:"reason"`
|
|
|
|
// Source 可选:记录来源(例如 smoke_log / relapse_event 等),便于排查与溯源。
|
|
SourceType string `gorm:"column:source_type;size:32;comment:来源类型" json:"source_type,omitempty"`
|
|
SourceID *uint `gorm:"column:source_id;comment:来源ID" json:"source_id,omitempty"`
|
|
}
|
|
|
|
func (HPChangeLog) TableName() string {
|
|
return "fa_quit_checkin_hp_change_log"
|
|
}
|
|
|
|
func (HPChangeLog) TableComment() string {
|
|
return "V2-无烟打卡-HP变动日志"
|
|
}
|