resource_data.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. BodyHighlight []string `description:"搜索高亮展示结果"`
  20. IsSummary int `description:"是否是纪要"`
  21. SourceId int `description:"资源ID"`
  22. Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  23. PublishDate string `description:"发布时间"`
  24. Article *HomeArticle `description:"文章"`
  25. Newchart *HomeChartListResp `description:"图表"`
  26. Roadshow *MicroRoadShowPageList `description:"微路演"`
  27. Activity *ActivityDetail `description:"活动"`
  28. Activityvideo *MicroRoadShowPageList `description:"活动视频"`
  29. Activityvoice *MicroRoadShowPageList `description:"活动音频"`
  30. Activityspecial *CygxActivitySpecialDetail `description:"专项调研活动"`
  31. Researchsummary *CygxReportSelectionRep `description:"本周研究汇总"`
  32. Minutessummary *CygxReportSelectionRep `description:"上周纪要汇总"`
  33. Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
  34. ProductInterior *CygxProductInteriorResp `description:"产品内测"`
  35. IndustrialResource *IndustrialManagementHotResp `description:"产业资源包"`
  36. }
  37. // Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  38. type HomeResourceDataListResp struct {
  39. Paging *paging.PagingItem
  40. List []*CygxResourceDataResp `description:"列表"`
  41. }
  42. // 列表
  43. func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
  44. o := orm.NewOrm()
  45. sql := `SELECT * FROM cygx_resource_data WHERE 1= 1 `
  46. if condition != "" {
  47. sql += condition
  48. }
  49. sql += ` ORDER BY publish_date DESC , id DESC LIMIT ?,? `
  50. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  51. return
  52. }
  53. // 获取用户报名成功数量
  54. func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
  55. sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data WHERE 1= 1 ` + condition
  56. o := orm.NewOrm()
  57. err = o.Raw(sqlCount, pars).QueryRow(&count)
  58. return
  59. }
  60. // 添加
  61. func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
  62. o := orm.NewOrm()
  63. lastId, err = o.Insert(item)
  64. return
  65. }
  66. // 删除数据
  67. func DeleteResourceData(sourceId int, source string) (err error) {
  68. o := orm.NewOrm()
  69. sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =? `
  70. _, err = o.Raw(sql, sourceId, source).Exec()
  71. return
  72. }
  73. // 修改数据
  74. func UpdateResourceData(sourceId int, source, publishDate string) (err error) {
  75. o := orm.NewOrm()
  76. sql := `UPDATE cygx_resource_data SET publish_date=? WHERE source_id=? AND source =? `
  77. _, err = o.Raw(sql, publishDate, sourceId, source).Exec()
  78. return
  79. }
  80. // 批量删除
  81. func DeleteResourceDataList(condition string, pars []interface{}) (err error) {
  82. if condition == "" {
  83. return
  84. }
  85. o := orm.NewOrm()
  86. sql := `DELETE FROM cygx_resource_data WHERE 1=1 ` + condition
  87. _, err = o.Raw(sql, pars).Exec()
  88. return
  89. }