report_chapter.go 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package models
  2. import (
  3. "eta/eta_hub/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. ContentStruct string `description:"内容组件"`
  37. LastModifyAdminId int `description:"最后更新人ID"`
  38. LastModifyAdminName string `description:"最后更新人姓名"`
  39. ContentModifyTime time.Time `description:"内容更新时间"`
  40. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  41. ReportCreateTime time.Time `description:"报告时间创建时间"`
  42. }
  43. // GetChapterListByReportId 根据ReportId获取章节列表
  44. func GetChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
  45. o := orm.NewOrmUsingDB("rddp")
  46. sql := ` SELECT * FROM report_chapter WHERE report_id = ? ORDER BY sort ASC`
  47. _, err = o.Raw(sql, reportId).QueryRows(&list)
  48. return
  49. }
  50. type ReportChapterItem struct {
  51. ReportChapterId int `orm:"column(report_chapter_id);pk" description:"报告章节ID"`
  52. ReportId int `description:"报告ID"`
  53. ReportType string `json:"-" description:"报告类型 day-晨报 week-周报"`
  54. ClassifyIdFirst int `description:"一级分类id"`
  55. ClassifyNameFirst string `description:"一级分类名称"`
  56. TypeId int `description:"品种ID"`
  57. TypeName string `description:"品种名称"`
  58. Title string `description:"标题"`
  59. Abstract string `description:"摘要"`
  60. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  61. Author string `description:"作者"`
  62. Content string `description:"内容"`
  63. ContentSub string `json:"-" description:"内容前两个章节"`
  64. Stage int `description:"期数"`
  65. Trend string `description:"趋势观点"`
  66. Sort int `description:"排序: 数值越小越靠前"`
  67. IsEdit int `description:"是否已编辑 0-待编辑 1-已编辑"`
  68. PublishState int `description:"发布状态 1-待发布,2-已发布"`
  69. PublishTime string `description:"发布时间"`
  70. VideoUrl string `description:"音频文件URL"`
  71. VideoName string `description:"音频文件名称"`
  72. VideoPlaySeconds string `description:"音频播放时长"`
  73. VideoSize string `description:"音频文件大小,单位M"`
  74. VideoKind int `description:"音频生成方式:1,手动上传,2:自动生成"`
  75. CreateTime string `description:"创建时间"`
  76. //ModifyTime string `description:"修改时间"`
  77. OriginalVideoUrl string `json:"-" description:"原始音频文件URL"`
  78. //ContentStruct string `description:"内容组件"`
  79. LastModifyAdminId int `json:"-" description:"最后更新人ID"`
  80. LastModifyAdminName string `json:"-" description:"最后更新人姓名"`
  81. ContentModifyTime string `description:"内容更新时间"`
  82. ReportLayout int8 `description:"报告布局,1:常规布局,2:智能布局。默认:1"`
  83. ReportCreateTime string `description:"报告时间创建时间"`
  84. }
  85. func FormatReportChapterItem(origin *ReportChapter) (item *ReportChapterItem) {
  86. if origin == nil {
  87. return
  88. }
  89. item = &ReportChapterItem{
  90. ReportChapterId: origin.ReportChapterId,
  91. ReportId: origin.ReportId,
  92. ReportType: origin.ReportType,
  93. ClassifyIdFirst: origin.ClassifyIdFirst,
  94. ClassifyNameFirst: origin.ClassifyNameFirst,
  95. TypeId: origin.TypeId,
  96. TypeName: origin.TypeName,
  97. Title: origin.Title,
  98. Abstract: origin.Abstract,
  99. AddType: origin.AddType,
  100. Author: origin.Author,
  101. Content: origin.Content,
  102. ContentSub: origin.ContentSub,
  103. Stage: origin.Stage,
  104. Trend: origin.Trend,
  105. Sort: origin.Sort,
  106. IsEdit: origin.IsEdit,
  107. PublishState: origin.PublishState,
  108. PublishTime: utils.TimeTransferString(utils.FormatDateTime, origin.PublishTime),
  109. VideoUrl: origin.VideoUrl,
  110. VideoName: origin.VideoName,
  111. VideoPlaySeconds: origin.VideoPlaySeconds,
  112. VideoSize: origin.VideoSize,
  113. VideoKind: origin.VideoKind,
  114. CreateTime: origin.CreateTime,
  115. OriginalVideoUrl: origin.OriginalVideoUrl,
  116. //LastModifyAdminId: origin.LastModifyAdminId,
  117. //LastModifyAdminName: origin.LastModifyAdminName,
  118. ContentModifyTime: utils.TimeTransferString(utils.FormatDateTime, origin.ContentModifyTime),
  119. ReportLayout: origin.ReportLayout,
  120. ReportCreateTime: utils.TimeTransferString(utils.FormatDateTime, origin.ReportCreateTime),
  121. }
  122. return
  123. }
  124. // GetPublishedChapterListByReportId 根据ReportId获取已发布章节列表
  125. func GetPublishedChapterListByReportId(reportId int) (list []*ReportChapter, err error) {
  126. o := orm.NewOrmUsingDB("rddp")
  127. sql := ` SELECT * FROM report_chapter WHERE report_id = ? AND publish_state = 2 ORDER BY sort ASC`
  128. _, err = o.Raw(sql, reportId).QueryRows(&list)
  129. return
  130. }