report.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package models
  2. import (
  3. "fmt"
  4. "hongze/hongze_task/utils"
  5. "rdluck_tools/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. }
  31. func GetReportById(reportId int) (item *Report, err error) {
  32. o := orm.NewOrm()
  33. o.Using("rddp")
  34. sql := `SELECT * FROM report WHERE id=?`
  35. err = o.Raw(sql, reportId).QueryRow(&item)
  36. return
  37. }
  38. func GetReport() (items []*Report, err error) {
  39. sql := `SELECT * FROM report ORDER BY id ASC `
  40. o := orm.NewOrm()
  41. o.Using("rddp")
  42. _, err = o.Raw(sql).QueryRows(&items)
  43. return
  44. }
  45. func ModifyReportContentSub(id int, contentSub string) (err error) {
  46. sql := `UPDATE report SET content_sub=? WHERE id=? `
  47. o := orm.NewOrm()
  48. o.Using("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.NewOrm()
  55. o.Using("rddp")
  56. _, err = o.Raw(sql).QueryRows(&items)
  57. return
  58. }
  59. func EditReportContent(reportId int, content, contentSub string) (err error) {
  60. o := orm.NewOrm()
  61. o.Using("rddp")
  62. sql := ` UPDATE report SET content=?,content_sub=?,modify_time=NOW() WHERE id=? `
  63. _, err = o.Raw(sql, content, contentSub, reportId).Exec()
  64. return
  65. }
  66. //删除报告日志记录-保留3个月
  67. func DeleteReportSaveLog() {
  68. startDateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDateTime)
  69. fmt.Println(startDateTime)
  70. }
  71. func EditReportContentHtml(reportId int, content string) (err error) {
  72. o := orm.NewOrm()
  73. o.Using("rddp")
  74. sql := ` UPDATE report SET content=?,modify_time=NOW() WHERE id=? `
  75. _, err = o.Raw(sql, content, reportId).Exec()
  76. return
  77. }