package models import ( "time" "gorm.io/gorm" ) // ExamShare 试卷分享关联表 type ExamShare struct { ID uint `gorm:"primaryKey" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` ExamID uint `gorm:"not null;uniqueIndex:uk_exam_shared_to" json:"exam_id"` SharedByID int64 `gorm:"not null;index" json:"shared_by_id"` SharedToID int64 `gorm:"not null;uniqueIndex:uk_exam_shared_to" json:"shared_to_id"` SharedAt time.Time `gorm:"not null;default:CURRENT_TIMESTAMP" json:"shared_at"` // 关联关系 Exam *Exam `gorm:"foreignKey:ExamID" json:"exam,omitempty"` SharedBy *User `gorm:"foreignKey:SharedByID;references:ID" json:"shared_by,omitempty"` SharedTo *User `gorm:"foreignKey:SharedToID;references:ID" json:"shared_to,omitempty"` } // TableName 指定表名 func (ExamShare) TableName() string { return "exam_shares" }