resource_data.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type CygxResourceData struct {
  8. Id int `orm:"column(id);pk"`
  9. SourceId int `description:"资源ID"`
  10. Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  11. Title string `description:"标题"`
  12. Annotation string `description:"核心观点"`
  13. CreateTime time.Time `description:"创建时间"`
  14. PublishDate string `description:"发布时间"`
  15. Abstract string `description:"摘要"`
  16. }
  17. type CygxResourceDataResp struct {
  18. Id int `orm:"column(id);pk"`
  19. SourceId int `description:"资源ID"`
  20. Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  21. PublishDate string `description:"发布时间"`
  22. Article *HomeArticle `description:"文章"`
  23. Newchart *HomeChartListResp `description:"图表"`
  24. Roadshow *MicroRoadShowPageList `description:"微路演"`
  25. Activity *ActivityDetail `description:"活动"`
  26. Activityvideo *MicroRoadShowPageList `description:"活动视频"`
  27. Activityvoice *MicroRoadShowPageList `description:"活动音频"`
  28. Activityspecial *CygxActivitySpecialDetail `description:"专项调研活动"`
  29. Researchsummary *CygxReportSelectionRep `description:"本周研究汇总"`
  30. Minutessummary *CygxReportSelectionRep `description:"上周纪要汇总"`
  31. Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
  32. ProductInterior *CygxProductInteriorResp `description:"产品内测"`
  33. }
  34. // Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  35. type HomeResourceDataListResp struct {
  36. Paging *paging.PagingItem
  37. List []*CygxResourceDataResp `description:"列表"`
  38. }
  39. // 列表
  40. func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT * FROM cygx_resource_data WHERE 1= 1 `
  43. if condition != "" {
  44. sql += condition
  45. }
  46. sql += ` ORDER BY publish_date DESC , id DESC LIMIT ?,? `
  47. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  48. return
  49. }
  50. // 获取用户报名成功数量
  51. func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
  52. sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data WHERE 1= 1 ` + condition
  53. o := orm.NewOrm()
  54. err = o.Raw(sqlCount, pars).QueryRow(&count)
  55. return
  56. }
  57. // 添加
  58. func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
  59. o := orm.NewOrm()
  60. lastId, err = o.Insert(item)
  61. return
  62. }
  63. // 删除数据
  64. func DeleteResourceData(sourceId int, source string) (err error) {
  65. o := orm.NewOrm()
  66. sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =? `
  67. _, err = o.Raw(sql, sourceId, source).Exec()
  68. return
  69. }
  70. // 修改数据
  71. func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
  72. o := orm.NewOrm()
  73. sql := `UPDATE cygx_resource_data SET publish_date=? WHERE source_id=? AND source =? `
  74. _, err = o.Raw(sql, publishDate, sourceId, source).Exec()
  75. return
  76. }
  77. // 批量删除
  78. func DeleteResourceDataList(condition string, pars []interface{}) (err error) {
  79. if condition == "" {
  80. return
  81. }
  82. o := orm.NewOrm()
  83. sql := `DELETE FROM cygx_resource_data WHERE 1=1 ` + condition
  84. _, err = o.Raw(sql, pars).Exec()
  85. return
  86. }