report.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package models
  2. import (
  3. "fmt"
  4. "hongze/hongze_task/utils"
  5. "github.com/beego/beego/v2/client/orm"
  6. "time"
  7. )
  8. type Report struct {
  9. Id int `orm:"column(id)" description:"报告Id"`
  10. AddType int `description:"新增方式:1:新增报告,2:继承报告"`
  11. ClassifyIdFirst int `description:"一级分类id"`
  12. ClassifyNameFirst string `description:"一级分类名称"`
  13. ClassifyIdSecond int `description:"二级分类id"`
  14. ClassifyNameSecond string `description:"二级分类名称"`
  15. Title string `description:"标题"`
  16. Abstract string `description:"摘要"`
  17. Author string `description:"作者"`
  18. Frequency string `description:"频度"`
  19. CreateTime string `description:"创建时间"`
  20. ModifyTime time.Time `description:"修改时间"`
  21. State int `description:"1:未发布,2:已发布"`
  22. PublishTime time.Time `description:"发布时间"`
  23. Stage int `description:"期数"`
  24. MsgIsSend int `description:"消息是否已发送,0:否,1:是"`
  25. Content string `description:"内容"`
  26. VideoUrl string `description:"音频文件URL"`
  27. VideoName string `description:"音频文件名称"`
  28. VideoPlaySeconds string `description:"音频播放时长"`
  29. ContentSub string `description:"内容前两个章节"`
  30. HasChapter int `description:"是否有章节 0-否 1-是"`
  31. ChapterType string `description:"章节类型 day-晨报 week-周报"`
  32. OldReportId int `description:"research_report表ID(后续一两个版本过渡需要,之后可移除)"`
  33. }
  34. func GetReportById(reportId int) (item *Report, err error) {
  35. o := orm.NewOrmUsingDB("rddp")
  36. sql := `SELECT * FROM report WHERE id=?`
  37. err = o.Raw(sql, reportId).QueryRow(&item)
  38. return
  39. }
  40. func GetReport() (items []*Report, err error) {
  41. sql := `SELECT * FROM report ORDER BY id ASC `
  42. o := orm.NewOrmUsingDB("rddp")
  43. _, err = o.Raw(sql).QueryRows(&items)
  44. return
  45. }
  46. func ModifyReportContentSub(id int, contentSub string) (err error) {
  47. sql := `UPDATE report SET content_sub=? WHERE id=? `
  48. o := orm.NewOrmUsingDB("rddp")
  49. _, err = o.Raw(sql, contentSub, id).Exec()
  50. return
  51. }
  52. func GetReportLimit() (items []*Report, err error) {
  53. sql := `SELECT * FROM report WHERE state=2 ORDER BY id DESC LIMIT 50 `
  54. o := orm.NewOrmUsingDB("rddp")
  55. _, err = o.Raw(sql).QueryRows(&items)
  56. return
  57. }
  58. func EditReportContent(reportId int, content, contentSub string) (err error) {
  59. o := orm.NewOrmUsingDB("rddp")
  60. sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  61. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  62. return
  63. }
  64. //删除报告日志记录-保留3个月
  65. func DeleteReportSaveLog() {
  66. startDateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDateTime)
  67. fmt.Println(startDateTime)
  68. }
  69. func EditReportContentHtml(reportId int, content string) (err error) {
  70. o := orm.NewOrmUsingDB("rddp")
  71. sql := ` UPDATE report SET content=?,modify_time=NOW() WHERE id=? `
  72. _, err = o.Raw(sql, content, reportId).Exec()
  73. return
  74. }