eta_chapter.go 1.3 KB

1234567891011121314151617181920212223242526272829
  1. package eta
  2. import "eta/eta_mini_ht_api/models"
  3. const (
  4. columns = "title,content,video_url,video_name,video_play_seconds,video_size"
  5. )
  6. // ReportChapter 表示报告章节的结构体
  7. type ReportChapter struct {
  8. Title string `gorm:"column:title;size:125;not null;default:'';comment:'章节标题'"`
  9. Abstract string `gorm:"column:abstract;size:255;not null;default:'';comment:'摘要'"`
  10. Author string `gorm:"column:author;size:50;not null;default:'';comment:'作者'"`
  11. Content string `gorm:"column:content;type:longtext;comment:'内容'"`
  12. VideoURL string `gorm:"column:video_url;size:255;not null;default:'';comment:'音频文件URL'"`
  13. VideoName string `gorm:"column:video_name;size:255;not null;default:'';comment:'音频文件名称'"`
  14. VideoPlaySeconds string `gorm:"column:video_play_seconds;size:255;not null;default:'';comment:'音频播放时长'"`
  15. VideoSize string `gorm:"column:video_size;size:20;not null;default:'';comment:'音频文件大小,单位M'"`
  16. }
  17. func GetChaptersByReportId(reportId int) (chapters []ReportChapter, err error) {
  18. db := models.ETA()
  19. err = db.Select(columns).Where("report_id = ?", reportId).Where("publish_state = ?", 2).Find(&chapters).Error
  20. return
  21. }
  22. func (ReportChapter) TableName() string {
  23. return "report_chapter"
  24. }