report_chapter.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package models
  2. import (
  3. "eta/eta_task/global"
  4. "eta/eta_task/utils"
  5. "gorm.io/gorm"
  6. "time"
  7. )
  8. // ReportChapter 报告章节
  9. type ReportChapter struct {
  10. ReportChapterId int `gorm:"column:report_chapter_id;primaryKey;autoIncrement" description:"报告章节ID"`
  11. ReportId int `description:"报告ID"`
  12. ReportType string `description:"报告类型 day-晨报 week-周报"`
  13. ClassifyIdFirst int `description:"一级分类id"`
  14. ClassifyNameFirst string `description:"一级分类名称"`
  15. TypeId int `description:"品种ID"`
  16. TypeName string `description:"品种名称"`
  17. Title string `description:"标题"`
  18. Abstract string `description:"摘要"`
  19. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  20. Author string `description:"作者"`
  21. Content string `description:"内容"`
  22. ContentSub string `description:"内容前两个章节"`
  23. Stage int `description:"期数"`
  24. Trend string `description:"趋势观点"`
  25. Sort int `description:"排序: 数值越小越靠前"`
  26. IsEdit int `description:"是否已编辑 0-待编辑 1-已编辑"`
  27. PublishState int `description:"发布状态 1-待发布,2-已发布"`
  28. PublishTime time.Time `description:"发布时间"`
  29. VideoUrl string `description:"音频文件URL"`
  30. VideoName string `description:"音频文件名称"`
  31. VideoPlaySeconds string `description:"音频播放时长"`
  32. VideoSize string `description:"音频文件大小,单位M"`
  33. VideoKind int `description:"音频生成方式:1,手动上传,2:自动生成"`
  34. CreateTime string `description:"创建时间"`
  35. ModifyTime time.Time `description:"修改时间"`
  36. OriginalVideoUrl string `description:"原始音频文件URL"`
  37. }
  38. func (m *ReportChapter) AfterFind(db *gorm.DB) (err error) {
  39. m.CreateTime = utils.GormDateStrToDateTimeStr(m.CreateTime)
  40. return
  41. }
  42. // GetPublishedChapterListByReportId 根据ReportId获取已发布章节列表
  43. func GetPublishedChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
  44. o := global.DbMap[utils.DbNameReport]
  45. sql := ` SELECT * FROM report_chapter WHERE report_id = ? AND publish_state = 2 ORDER BY sort ASC`
  46. err = o.Raw(sql, reportId).Find(&list).Error
  47. return
  48. }
  49. // GetChapterListByReportId 根据ReportId获取章节列表
  50. func GetChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
  51. o := global.DbMap[utils.DbNameReport]
  52. sql := ` SELECT * FROM report_chapter WHERE report_id = ? ORDER BY sort ASC`
  53. err = o.Raw(sql, reportId).Find(&list).Error
  54. return
  55. }
  56. // UpdateChapter 更新报表章节
  57. func (chapterChapterInfo *ReportChapter) UpdateChapter(cols []string) (err error) {
  58. err = global.DbMap[utils.DbNameReport].Select(cols).Updates(chapterChapterInfo).Error
  59. return
  60. }