smart_report.go 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package models
  2. import (
  3. "eta_gn/eta_task/global"
  4. "fmt"
  5. "time"
  6. )
  7. type SmartReport struct {
  8. SmartReportId int `orm:"column(smart_report_id)" description:"智能研报ID"`
  9. ReportCode string `description:"报告唯一编码"`
  10. ClassifyIdFirst int `description:"一级分类ID"`
  11. ClassifyNameFirst string `description:"一级分类名称"`
  12. ClassifyIdSecond int `description:"二级分类ID"`
  13. ClassifyNameSecond string `description:"二级分类名称"`
  14. AddType int `description:"新增方式:1-新增报告;2-继承报告"`
  15. Title string `description:"标题"`
  16. Abstract string `description:"摘要"`
  17. Author string `description:"作者"`
  18. Frequency string `description:"频度"`
  19. Stage int `description:"期数"`
  20. Content string `description:"内容"`
  21. ContentSub string `description:"内容前两个章节"`
  22. ContentStruct string `description:"内容组件"`
  23. VideoUrl string `description:"音频文件URL"`
  24. VideoName string `description:"音频文件名称"`
  25. VideoPlaySeconds string `description:"音频播放时长"`
  26. VideoSize string `description:"音频文件大小,单位M"`
  27. AdminId int `description:"创建者ID"`
  28. AdminRealName string `description:"创建者姓名"`
  29. State int `description:"发布状态:1-待发布;2-已发布"`
  30. PublishTime time.Time `description:"发布时间"`
  31. PrePublishTime time.Time `description:"预发布时间"`
  32. PreMsgSend int `description:"定时发布后是否推送模版消息:0-否;1-是"`
  33. MsgIsSend int `description:"消息是否已发送:0-否;1-是"`
  34. MsgSendTime time.Time `description:"模版消息发送时间"`
  35. CreateTime time.Time `description:"创建时间"`
  36. ModifyTime time.Time `description:"修改时间"`
  37. }
  38. func (m *SmartReport) TableName() string {
  39. return "smart_report"
  40. }
  41. func (m *SmartReport) PrimaryId() string {
  42. return "smart_report_id"
  43. }
  44. func (m *SmartReport) Update(cols []string) (err error) {
  45. err = global.DmSQL["rddp"].Select(cols).Updates(m).Error
  46. return
  47. }
  48. func (m *SmartReport) GetItemById(id int) (item *SmartReport, err error) {
  49. sql := fmt.Sprintf(`SELECT * FROM %s WHERE %s = ? LIMIT 1`, m.TableName(), m.PrimaryId())
  50. err = global.DmSQL["rddp"].Raw(sql, id).Find(&item).Error
  51. return
  52. }
  53. func GetPrePublishSmartReports(startTime, endTime string) (list []*SmartReport, err error) {
  54. sql := `SELECT * FROM smart_report WHERE state = 1 AND pre_publish_time >= ? AND pre_publish_time <= ?`
  55. err = global.DmSQL["rddp"].Raw(sql, startTime, endTime).Find(&list).Error
  56. return
  57. }
  58. func PublishSmartReportById(reportId int, publishTime time.Time) (err error) {
  59. sql := `UPDATE smart_report SET state = 2, publish_time = ?, msg_is_send = 1, msg_send_time = NOW(), modify_time = NOW() WHERE smart_report_id = ?`
  60. err = global.DmSQL["rddp"].Exec(sql, publishTime, reportId).Error
  61. return
  62. }
  63. type ElasticSmartReport struct {
  64. SmartReportId int `description:"智能研报ID"`
  65. Title string `description:"标题"`
  66. Abstract string `description:"摘要"`
  67. BodyContent string `description:"内容"`
  68. PublishTime string `description:"发布时间"`
  69. PublishState int `description:"发布状态 1-未发布 2-已发布"`
  70. Author string `description:"作者"`
  71. ClassifyIdFirst int `description:"一级分类ID"`
  72. ClassifyNameFirst string `description:"一级分类名称"`
  73. ClassifyIdSecond int `description:"二级分类ID"`
  74. ClassifyNameSecond string `description:"二级分类名称"`
  75. StageStr string `description:"报告期数"`
  76. Frequency string `description:"频度"`
  77. }
  78. type Report2ImgQueueReq struct {
  79. ReportType int `description:"报告类型: 1-研报; 2-智能研报"`
  80. ReportCode string `description:"报告唯一编码"`
  81. }