resource_data.go 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. }
  33. // Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  34. type HomeResourceDataListResp struct {
  35. Paging *paging.PagingItem
  36. List []*CygxResourceDataResp `description:"列表"`
  37. }
  38. // 列表
  39. func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT * FROM cygx_resource_data WHERE 1= 1 `
  42. if condition != "" {
  43. sql += condition
  44. }
  45. sql += ` ORDER BY publish_date DESC , id DESC LIMIT ?,? `
  46. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  47. return
  48. }
  49. // 获取用户报名成功数量
  50. func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
  51. sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data WHERE 1= 1 ` + condition
  52. o := orm.NewOrm()
  53. err = o.Raw(sqlCount, pars).QueryRow(&count)
  54. return
  55. }
  56. // 添加
  57. func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
  58. o := orm.NewOrm()
  59. lastId, err = o.Insert(item)
  60. return
  61. }
  62. // 删除数据
  63. func DeleteResourceData(sourceId int, source string) (err error) {
  64. o := orm.NewOrm()
  65. sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =? `
  66. _, err = o.Raw(sql, sourceId, source).Exec()
  67. return
  68. }
  69. // 修改数据
  70. func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
  71. o := orm.NewOrm()
  72. sql := `UPDATE cygx_resource_data SET publish_date=? WHERE source_id=? AND source =? `
  73. _, err = o.Raw(sql, publishDate, sourceId, source).Exec()
  74. return
  75. }
  76. // 批量删除
  77. func DeleteResourceDataList(condition string, pars []interface{}) (err error) {
  78. if condition == "" {
  79. return
  80. }
  81. o := orm.NewOrm()
  82. sql := `DELETE FROM cygx_resource_data WHERE 1=1 ` + condition
  83. _, err = o.Raw(sql, pars).Exec()
  84. return
  85. }