report_chapter.go 3.6 KB

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