首次提交
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
// CheckInCategory 打卡分类
|
||||
type CheckInCategory string
|
||||
|
||||
const (
|
||||
CategoryStudy CheckInCategory = "study"
|
||||
CategoryHealth CheckInCategory = "health"
|
||||
CategoryHabit CheckInCategory = "habit"
|
||||
CategoryHobby CheckInCategory = "hobby"
|
||||
CategoryGoal CheckInCategory = "goal"
|
||||
)
|
||||
|
||||
// CycleType 打卡周期
|
||||
type CycleType string
|
||||
|
||||
const (
|
||||
CycleDaily CycleType = "daily"
|
||||
CycleWeekly CycleType = "weekly"
|
||||
CycleEveryOther CycleType = "every_other_day"
|
||||
CycleCustom CycleType = "custom"
|
||||
)
|
||||
|
||||
// ItemStatus 打卡项状态
|
||||
type ItemStatus string
|
||||
|
||||
const (
|
||||
StatusActive ItemStatus = "active"
|
||||
StatusPaused ItemStatus = "paused"
|
||||
StatusArchived ItemStatus = "archived"
|
||||
StatusDeleted ItemStatus = "deleted"
|
||||
)
|
||||
|
||||
// RecordStatus 打卡记录状态
|
||||
type RecordStatus string
|
||||
|
||||
const (
|
||||
RecordNormal RecordStatus = "normal"
|
||||
RecordMakeup RecordStatus = "makeup"
|
||||
)
|
||||
|
||||
// CheckInItem 打卡项
|
||||
type CheckInItem struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(32)" json:"id"`
|
||||
UserID string `gorm:"column:user_id;type:varchar(32);not null;index" json:"userId"`
|
||||
Name string `gorm:"type:varchar(100);not null" json:"name"`
|
||||
Icon *string `gorm:"type:varchar(50)" json:"icon,omitempty"`
|
||||
Category CheckInCategory `gorm:"type:varchar(20);not null" json:"category"`
|
||||
DailyGoal *string `gorm:"column:daily_goal;type:varchar(200)" json:"dailyGoal,omitempty"`
|
||||
CycleType CycleType `gorm:"column:cycle_type;default:daily;type:varchar(20)" json:"cycleType"`
|
||||
Privacy PrivacyLevel `gorm:"default:2" json:"privacy"`
|
||||
Status ItemStatus `gorm:"default:active;type:varchar(20)" json:"status"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
|
||||
User User `gorm:"foreignKey:UserID" json:"-"`
|
||||
Records []CheckInRecord `gorm:"foreignKey:ItemID" json:"-"`
|
||||
}
|
||||
|
||||
func (CheckInItem) TableName() string { return "checkin_items" }
|
||||
|
||||
// CheckInRecord 打卡记录
|
||||
type CheckInRecord struct {
|
||||
ID string `gorm:"primaryKey;type:varchar(32)" json:"id"`
|
||||
ItemID string `gorm:"column:item_id;type:varchar(32);not null;index" json:"itemId"`
|
||||
UserID string `gorm:"column:user_id;type:varchar(32);not null;index" json:"userId"`
|
||||
CheckDate time.Time `gorm:"column:check_date;not null;index" json:"checkDate"`
|
||||
Status RecordStatus `gorm:"default:normal;type:varchar(20)" json:"status"`
|
||||
Note *string `gorm:"type:varchar(500)" json:"note,omitempty"`
|
||||
Images *string `gorm:"type:text" json:"images,omitempty"`
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||
|
||||
Item CheckInItem `gorm:"foreignKey:ItemID" json:"-"`
|
||||
User User `gorm:"foreignKey:UserID" json:"-"`
|
||||
}
|
||||
|
||||
func (CheckInRecord) TableName() string { return "checkin_records" }
|
||||
Reference in New Issue
Block a user