report_push_status.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package models
  2. import (
  3. "time"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type ReportPushStatus struct {
  7. ReportPushStatusId int `orm:"pk"`
  8. ReportId int `description:"报告id"`
  9. State int `description:"报告状态:0-未推送,1-已推送"`
  10. Title string `description:"报告标题"`
  11. Abstract string `description:"报告摘要"`
  12. Stage int `description:"期数"`
  13. ClassifyIdFirst int `description:"一级分类id"`
  14. ClassifyNameFirst string `description:"一级分类名称"`
  15. ClassifyIdSecond int `description:"二级分类id"`
  16. ClassifyNameSecond string `description:"二级分类名称"`
  17. ClassifyIdThird int `description:"三级分类id"`
  18. ClassifyNameThird string `description:"三级分类名称"`
  19. Author string `description:"报告作者"`
  20. ReportType int `description:"报告类型:1-eta报告"`
  21. PublishTime time.Time `description:"报告发布时间"`
  22. CreateTime time.Time `description:"创建时间"`
  23. ModifyTime time.Time `description:"修改时间"`
  24. PushTime time.Time `description:"推送时间"`
  25. }
  26. type ReportPushView struct {
  27. ReportPushStatusId int `orm:"pk"`
  28. ReportId int `description:"报告id"`
  29. Title string `description:"报告标题"`
  30. Abstract string `description:"报告摘要"`
  31. ClassifyIdFirst int `description:"一级分类id"`
  32. ClassifyNameFirst string `description:"一级分类名称"`
  33. ClassifyIdSecond int `description:"二级分类id"`
  34. ClassifyNameSecond string `description:"二级分类名称"`
  35. ClassifyIdThird int `description:"二级分类id"`
  36. ClassifyNameThird string `description:"二级分类名称"`
  37. Author string `description:"报告作者"`
  38. Stage int `description:"期数"`
  39. State int `description:"报告状态:0-未推送,1-已推送"`
  40. PushTime string `description:"推送时间"`
  41. PublishTime string `description:"报告发布时间"`
  42. ReportType int `description:"报告类型:1-eta报告"`
  43. CreateTime string `description:"创建时间"`
  44. ModifyTime string `description:"修改时间"`
  45. }
  46. func GetReportPushStatusByReportId(reportId int, reportType int) (item *ReportPushStatus, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT * FROM report_push_status WHERE report_id = ? AND report_type = ?`
  49. err = o.Raw(sql, reportId, reportType).QueryRow(&item)
  50. return
  51. }
  52. func GetReportPushStatusCountByCondition(condition string, pars []interface{}) (count int, err error) {
  53. o := orm.NewOrm()
  54. sql := `SELECT COUNT(*) AS count FROM report_push_status WHERE 1=1 AND state=1 `
  55. if condition != "" {
  56. sql += condition
  57. }
  58. err = o.Raw(sql, pars...).QueryRow(&count)
  59. return
  60. }
  61. func GetReportPushStatusByCondition(condition string, pars []interface{}, startSize int, pageSize int) (items []*ReportPushStatus, err error) {
  62. o := orm.NewOrm()
  63. sql := `SELECT * FROM report_push_status WHERE 1=1 AND state=1 `
  64. if condition != "" {
  65. sql += condition
  66. }
  67. sql += ` ORDER BY publish_time DESC LIMIT ?,?`
  68. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  69. return
  70. }
  71. func DeleteReportPushStatusByReportId(reportId int, reportType int) (err error) {
  72. o := orm.NewOrm()
  73. sql := `DELETE FROM report_push_status WHERE report_id = ? AND report_type = ?`
  74. _, err = o.Raw(sql, reportId, reportType).Exec()
  75. return
  76. }