resource_data.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. SearchTag string `description:"搜索标签"`
  17. ChartPermissionId int `description:"行业id"`
  18. SearchTitle string `description:"搜索匹配用的标题"`
  19. SearchContent string `description:"搜索匹配用的内容"`
  20. SearchOrderTime string `description:"搜索排序时间"`
  21. }
  22. type CygxResourceDataResp struct {
  23. Id int `orm:"column(id);pk"`
  24. SourceId int `description:"资源ID"`
  25. Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  26. Title string `description:"标题"`
  27. IsResearch bool `description:"是否属于研选"`
  28. BodyImg string `description:"文章封面图片"`
  29. Pv int `description:"PV"`
  30. Annotation string `description:"核心观点"`
  31. PublishDate string `description:"发布时间"`
  32. Abstract string `description:"摘要"`
  33. IsTop bool `description:"是否置顶"`
  34. IsCollection bool `description:"是否收藏 "`
  35. BackgroundImg string `description:"背景图"`
  36. City string `description:"城市"`
  37. IsSignup int `description:"是否已报名 1是 ,0 否"`
  38. IsAppointment int `description:"是否已预约纪要 1是 ,0 否"`
  39. IsCancelMeetingReminder int `description:"是否添加了消息消息提醒 1是 ,0 否"`
  40. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  41. ImgUrl string `description:"行业图片链接"`
  42. ImgUrlText string `description:"活动类型图片链接"`
  43. ActivityType int `description:"活动线上线下类型 1线上,0 线下,2线下"`
  44. IsShowOutboundCall bool `description:"是否展示预约外呼"`
  45. IsShowMeetingReminder bool `description:"是否展示会议提醒"`
  46. IsShowHelpSsk bool `description:"是否展示帮我带问"`
  47. IsShowSignup bool `description:"是否展示我要报名"`
  48. IsShowAppointment bool `description:"是否展示预约纪要"`
  49. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  50. IsShowDetails bool `description:"是否展示查看详情按钮"`
  51. YidongActivityUrl string `description:"易董活动跳转地址"`
  52. IsYidongActivity bool `description:"是否属于易董同步过来的活动"`
  53. TripStatus int `description:"行程进行状态 1:预报名,2:确定行程"`
  54. IsTrip int `description:"确定行程是否报名 1是 ,0 否"`
  55. ActivityTimeText string `description:"活动预期时间带文字"`
  56. TripImgLink string `description:"行程图片链接"`
  57. ChartPermissionId int `description:"权限id"`
  58. Expert string `description:"专家"`
  59. Speaker string `description:"主讲人"`
  60. DistinguishedGuest string `description:"嘉宾"`
  61. ActivityTime string `description:"活动预期时间"`
  62. ResourceUrl string `description:"链接"`
  63. AuthInfo *UserPermissionAuthInfo
  64. VoiceDetail *CygxActivityVoiceReq `description:"音频数据"`
  65. VideoDetail *CygxActivityVideoListResp `description:"视频数据"`
  66. AudioLink bool `description:"是否展示回放按钮"`
  67. FileType int `description:"类型: 1-音频; 2-视频"`
  68. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  69. ActivityTypeId int `description:"活动类型id"`
  70. IsYidongConduct bool `description:"是否属于易董办会 1:是 、0:否"`
  71. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  72. TencentConferenceNumber string `description:"腾讯会议号"`
  73. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  74. IsExternalLabel bool `description:"是否为外部资源"`
  75. IsResearchPoints bool `description:"是否为研选扣点"`
  76. SiginupDeadline string `description:"报名截止时间"`
  77. }
  78. type HomeResourceDataListResp struct {
  79. Paging *paging.PagingItem
  80. List []*CygxResourceDataResp `description:"列表"`
  81. }
  82. // Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  83. type HomeResourceDataListNewResp struct {
  84. Paging *paging.PagingItem
  85. List []*CygxResourceDataNewResp `description:"列表"`
  86. }
  87. type CygxResourceDataNewResp struct {
  88. Id int `orm:"column(id);pk"`
  89. BodyHighlight []string `description:"搜索高亮展示结果"`
  90. TitleHighlight string `description:"搜索高亮展示结果"`
  91. SourceId int `description:"资源ID"`
  92. Source string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
  93. PublishDate string `description:"发布时间"`
  94. Article *ArticleListResp `description:"文章"`
  95. Newchart *HomeChartListResp `description:"图表"`
  96. Roadshow *MicroRoadShowPageList `description:"微路演"`
  97. Activity *ActivityListResp `description:"活动"`
  98. Activityvideo *MicroRoadShowPageList `description:"活动视频"`
  99. Activityvoice *MicroRoadShowPageList `description:"活动音频"`
  100. Activityspecial *CygxActivitySpecialDetail `description:"专项调研活动"`
  101. Researchsummary *CygxReportSelectionRep `description:"本周研究汇总"`
  102. Minutessummary *CygxReportSelectionRep `description:"上周纪要汇总"`
  103. Meetingreviewchapt *CygxMorningMeetingGatherDetailListResp `description:"晨会精华"`
  104. ProductInterior *CygxProductInteriorResp `description:"产品内测"`
  105. IndustrialResource *IndustrialManagement `description:"产业资源包"`
  106. ReportSelection *CygxReportSelectionRep `description:"重点公司(原报告精选)"`
  107. YanxuanSpecial *CygxYanxuanSpecialItem `description:"研选专栏"`
  108. AskserieVideo *MicroRoadShowPageList `description:"活动音频"`
  109. FiccReport *ArticleListResp `description:"FICC研报"`
  110. }
  111. // 列表
  112. func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceDataNewResp, err error) {
  113. o := orm.NewOrm()
  114. sql := `SELECT * FROM cygx_resource_data WHERE 1= 1 `
  115. if condition != "" {
  116. sql += condition
  117. }
  118. sql += ` ORDER BY publish_date DESC , id DESC LIMIT ?,? `
  119. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  120. return
  121. }
  122. // 列表
  123. func GetResourceDataListCondition(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
  124. o := orm.NewOrm()
  125. sql := `SELECT * FROM cygx_resource_data WHERE 1= 1 `
  126. if condition != "" {
  127. sql += condition
  128. }
  129. sql += ` ORDER BY search_order_time DESC LIMIT ?,? `
  130. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  131. return
  132. }
  133. // 获取用户报名成功数量
  134. func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
  135. sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data WHERE 1= 1 ` + condition
  136. o := orm.NewOrm()
  137. err = o.Raw(sqlCount, pars).QueryRow(&count)
  138. return
  139. }
  140. // 删除数据
  141. func DeleteResourceData(sourceId int, source string) (err error) {
  142. o := orm.NewOrm()
  143. sql := ` DELETE FROM cygx_resource_data WHERE source_id = ? AND source =? `
  144. _, err = o.Raw(sql, sourceId, source).Exec()
  145. return
  146. }
  147. // 获取数量
  148. func GetCygxResourceDataBySourceAndIdCount(sourceId int, source string) (count int, err error) {
  149. o := orm.NewOrm()
  150. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_resource_data WHERE source_id = ? AND source =? `
  151. err = o.Raw(sqlCount, sourceId, source).QueryRow(&count)
  152. return
  153. }
  154. // 添加
  155. func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
  156. o := orm.NewOrm()
  157. lastId, err = o.Insert(item)
  158. return
  159. }
  160. // 修改
  161. func UpdateResourceDataByItem(item *CygxResourceData) (err error) {
  162. o := orm.NewOrm()
  163. updateParams := make(map[string]interface{})
  164. updateParams["PublishDate"] = item.PublishDate
  165. updateParams["SearchTag"] = item.SearchTag
  166. ptrStructOrTableName := "cygx_resource_data"
  167. whereParam := map[string]interface{}{"source_id": item.SourceId, "source": item.Source}
  168. qs := o.QueryTable(ptrStructOrTableName)
  169. for expr, exprV := range whereParam {
  170. qs = qs.Filter(expr, exprV)
  171. }
  172. _, err = qs.Update(updateParams)
  173. if err != nil {
  174. return
  175. }
  176. return
  177. }