package models import ( "time" "gorm.io/gorm" ) // StudyPlan 学习计划模型 type StudyPlan struct { ID int64 `json:"id" gorm:"type:bigint;primaryKey;autoIncrement;comment:计划ID"` UserID int64 `json:"user_id" gorm:"type:bigint;not null;index;comment:用户ID"` BookID *string `json:"book_id" gorm:"type:varchar(36);index;comment:词汇书ID(可选)"` PlanName string `json:"plan_name" gorm:"type:varchar(200);not null;comment:计划名称"` Description *string `json:"description" gorm:"type:text;comment:计划描述"` DailyGoal int `json:"daily_goal" gorm:"type:int;not null;default:20;comment:每日目标单词数"` TotalWords int `json:"total_words" gorm:"type:int;default:0;comment:计划总单词数"` LearnedWords int `json:"learned_words" gorm:"type:int;default:0;comment:已学单词数"` StartDate time.Time `json:"start_date" gorm:"type:date;not null;comment:开始日期"` EndDate *time.Time `json:"end_date" gorm:"type:date;comment:结束日期"` Status string `json:"status" gorm:"type:enum('active','paused','completed','cancelled');default:'active';comment:计划状态"` RemindTime *string `json:"remind_time" gorm:"type:varchar(10);comment:提醒时间(HH:mm格式)"` RemindDays *string `json:"remind_days" gorm:"type:varchar(20);comment:提醒日期(1,2,3..7表示周一到周日)"` IsRemindEnabled bool `json:"is_remind_enabled" gorm:"type:boolean;default:false;comment:是否启用提醒"` LastStudyDate *time.Time `json:"last_study_date" gorm:"type:date;comment:最后学习日期"` StreakDays int `json:"streak_days" gorm:"type:int;default:0;comment:连续学习天数"` CompletedAt *time.Time `json:"completed_at" gorm:"type:timestamp;comment:完成时间"` CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;comment:创建时间"` UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index;comment:删除时间"` // 关联关系 User User `json:"-" gorm:"foreignKey:UserID"` Book *VocabularyBook `json:"book,omitempty" gorm:"-"` } func (StudyPlan) TableName() string { return "ai_study_plans" } // StudyPlanRecord 学习计划完成记录 type StudyPlanRecord struct { ID int64 `json:"id" gorm:"type:bigint;primaryKey;autoIncrement;comment:记录ID"` PlanID int64 `json:"plan_id" gorm:"type:bigint;not null;index;comment:计划ID"` UserID int64 `json:"user_id" gorm:"type:bigint;not null;index;comment:用户ID"` StudyDate time.Time `json:"study_date" gorm:"type:date;not null;index;comment:学习日期"` WordsStudied int `json:"words_studied" gorm:"type:int;default:0;comment:学习单词数"` GoalCompleted bool `json:"goal_completed" gorm:"type:boolean;default:false;comment:是否完成目标"` StudyDuration int `json:"study_duration" gorm:"type:int;default:0;comment:学习时长(分钟)"` CreatedAt time.Time `json:"created_at" gorm:"type:timestamp;default:CURRENT_TIMESTAMP;comment:创建时间"` // 关联关系 Plan StudyPlan `json:"-" gorm:"foreignKey:PlanID"` User User `json:"-" gorm:"foreignKey:UserID"` } func (StudyPlanRecord) TableName() string { return "ai_study_plan_records" }