resource_data.go 12 KB

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