2026-03-12 08:38:14 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ScheduleCourse 用户课表课程
|
|
|
|
|
type ScheduleCourse struct {
|
|
|
|
|
ID string `json:"id" gorm:"type:varchar(36);primaryKey"`
|
|
|
|
|
UserID string `json:"user_id" gorm:"type:varchar(36);index;not null"`
|
|
|
|
|
Name string `json:"name" gorm:"type:varchar(120);not null"`
|
|
|
|
|
Teacher string `json:"teacher" gorm:"type:varchar(80)"`
|
|
|
|
|
Location string `json:"location" gorm:"type:varchar(120)"`
|
|
|
|
|
DayOfWeek int `json:"day_of_week" gorm:"index;not null"` // 0=周一, 6=周日
|
|
|
|
|
StartSection int `json:"start_section" gorm:"not null"`
|
|
|
|
|
EndSection int `json:"end_section" gorm:"not null"`
|
|
|
|
|
Weeks string `json:"weeks" gorm:"type:text;not null"` // JSON 数组字符串
|
|
|
|
|
Color string `json:"color" gorm:"type:varchar(20)"`
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
|
UpdatedAt time.Time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *ScheduleCourse) BeforeCreate(tx *gorm.DB) error {
|
2026-05-04 13:07:03 +08:00
|
|
|
SetUUIDIfEmpty(&s.ID)
|
2026-03-12 08:38:14 +08:00
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (ScheduleCourse) TableName() string {
|
|
|
|
|
return "schedule_courses"
|
|
|
|
|
}
|