Files
smartmate/backend/model/schedule.go
LoveLosita 132b7095ac Version:0.1.0.dev.260205
feat: 🆕 完善course模块功能并优化批量导入接口

- 调整 task-class 模型代码并增加注释,使其更简洁易读 ✍️
- 结构调整:将课程相关接口从 schedule 分类移至独立的 course 分类 🚀
  - 修改接口 URL 从 /schedule 更改为 /course 🔄

fix: 🐛 修复批量导入课程接口重复导入相同课程的 bug
- 通过在数据库添加唯一约束解决此问题 🔐
- 这只是初步修复,后续会在 sv 层增加重复/时间冲突检测逻辑 ⚠️
- 引导用户修改课表与任务块时间冲突的机制待实现 

refactor: 🔨 重构 schedule 表单结构
- 将节次管理策略从字符串存储改为原子化存储(如 1-2 节更改为单独两条记录)
- 为后续冲突检查与智能排课做准备 🧠

perf: 🚀 优化批量导入课程接口性能
- 通过数据暂存内存中减少数据插入 MySQL 的次数 
2026-02-05 16:51:15 +08:00

15 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
type Schedule struct {
ID int `gorm:"primaryKey;autoIncrement" json:"id"`
UserID int `gorm:"column:user_id;index" json:"user_id"`
Type string `gorm:"type:enum('course','task');comment:course / task" json:"type"`
RelID int `gorm:"column:rel_id;comment:关联 course_id 或 task_item_id" json:"rel_id"`
EmbeddedTaskID *int `gorm:"column:embedded_task_id;index;comment:若为水课嵌入记录任务ID" json:"embedded_task_id"`
Week int `gorm:"column:week;uniqueIndex:idx_user_slot_atomic,priority:2;comment:周次 (1-25)" json:"week"`
DayOfWeek int `gorm:"column:day_of_week;uniqueIndex:idx_user_slot_atomic,priority:3;comment:星期 (1-7)" json:"day_of_week"`
Section int `gorm:"column:section;uniqueIndex:idx_user_slot_atomic,priority:4;comment:原子化节次 (1-12)" json:"section"`
Status string `gorm:"type:enum('normal','interrupted');default:normal" json:"status"`
CanBeEmbedded bool `gorm:"column:can_be_embedded;not null;comment:是否允许嵌入任务" json:"can_be_embedded"`
}