44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// 每日状态枚举值。
|
|
const (
|
|
DailyStatusPending = "pending"
|
|
DailyStatusCheckedIn = "checked_in"
|
|
DailyStatusRelapsed = "relapsed"
|
|
DailyStatusMissed = "missed"
|
|
)
|
|
|
|
// DailyStatus 表示用户在某一自然日的打卡或复吸状态。
|
|
type DailyStatus 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:"uniqueIndex:idx_quit_checkin_uid_date;comment:用户ID" json:"-"`
|
|
|
|
Date time.Time `gorm:"uniqueIndex:idx_quit_checkin_uid_date;type:date;comment:自然日" json:"date"`
|
|
Status string `gorm:"size:32;index;comment:状态" json:"status"`
|
|
CheckInAt *time.Time `gorm:"column:check_in_at;comment:打卡时间" json:"check_in_at,omitempty"`
|
|
RelapsedAt *time.Time `gorm:"column:relapsed_at;comment:复吸时间" json:"relapsed_at,omitempty"`
|
|
RelapseNum int `gorm:"column:relapse_num;comment:复吸支数" json:"relapse_num"`
|
|
Reason string `gorm:"column:reason;size:64;comment:复吸原因" json:"reason,omitempty"`
|
|
Note string `gorm:"column:note;size:200;comment:备注" json:"note,omitempty"`
|
|
}
|
|
|
|
// TableName 返回每日状态表名。
|
|
func (DailyStatus) TableName() string {
|
|
return "fa_quit_checkin_daily_status"
|
|
}
|
|
|
|
// TableComment 返回每日状态表注释。
|
|
func (DailyStatus) TableComment() string {
|
|
return "V2-无烟打卡-每日状态"
|
|
}
|