report_chapter.go 3.2 KB

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