micro_roadshow.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // MicroRoadShowListResp 微路演列表响应体
  8. type MicroRoadShowListResp struct {
  9. Paging *paging.PagingItem
  10. List []*MicroRoadShowPageList
  11. }
  12. // MicroRoadShowPageList 微路演列表
  13. type MicroRoadShowPageList struct {
  14. Id int `description:"音视频ID"`
  15. Title string `description:"标题"`
  16. ResourceUrl string `description:"链接"`
  17. Type int `description:"类型: 1-音频; 2-视频"`
  18. PublishTime string `description:"发布时间"`
  19. BackgroundImg string `description:"背景图"`
  20. ShareImg string `description:"分享封面图"`
  21. ChartPermissionId int `description:"行业ID"`
  22. ChartPermissionName string `description:"行业名称"`
  23. PlaySeconds string `description:"音视频时长"`
  24. ActivityId int `description:"活动ID"`
  25. AuthInfo *UserPermissionAuthInfo
  26. }
  27. // GetMicroRoadShowAudioPageList 获取微路演音频列表-分页
  28. func GetMicroRoadShowAudioPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  29. o := orm.NewOrm()
  30. sql := `SELECT
  31. a.activity_voice_id AS id,
  32. a.voice_name AS title,
  33. a.voice_url AS resource_url,
  34. 1 AS type,
  35. b.activity_time AS publish_time,
  36. b.chart_permission_id,
  37. b.chart_permission_name,
  38. a.voice_play_seconds AS play_seconds,
  39. a.img_url AS background_img,
  40. a.activity_id
  41. FROM
  42. cygx_activity_voice AS a
  43. JOIN cygx_activity AS b ON a.activity_id = b.activity_id
  44. WHERE 1 = 1 `
  45. if condition != `` {
  46. sql += condition
  47. }
  48. sql += ` ORDER BY publish_time DESC`
  49. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  50. err = o.Raw(totalSql, pars).QueryRow(&total)
  51. if err != nil {
  52. return
  53. }
  54. sql += ` LIMIT ?,?`
  55. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  56. return
  57. }
  58. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  59. func GetMicroRoadShowVideoPageList(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  60. o := orm.NewOrm()
  61. sql := `SELECT
  62. video_id AS id,
  63. video_name AS title,
  64. video_url AS resource_url,
  65. 2 AS type,
  66. publish_date AS publish_time,
  67. chart_permission_id,
  68. chart_permission_name,
  69. video_duration AS play_seconds,
  70. img_url AS background_img,
  71. "" as activity_id
  72. FROM
  73. cygx_micro_roadshow_video
  74. WHERE
  75. publish_status = 1 `
  76. if condition != `` {
  77. sql += condition
  78. }
  79. sql += ` UNION ALL
  80. SELECT
  81. video_id AS id,
  82. video_name AS title,
  83. video_url AS resource_url,
  84. 3 AS type,
  85. art.activity_time as publish_time,
  86. 0,
  87. "",
  88. "",
  89. "",
  90. v.activity_id
  91. FROM
  92. cygx_activity_video as v
  93. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  94. if conditionAct != `` {
  95. sql += conditionAct
  96. }
  97. sql += ` ORDER BY publish_time DESC`
  98. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  99. err = o.Raw(totalSql, pars, parsAct).QueryRow(&total)
  100. if err != nil {
  101. return
  102. }
  103. sql += ` LIMIT ?,?`
  104. _, err = o.Raw(sql, pars, parsAct, startSize, pageSize).QueryRows(&list)
  105. return
  106. }
  107. type AddVideoHistoryReq struct {
  108. VideoId int `description:"视频ID"`
  109. PlaySeconds int `description:"播放时长"`
  110. SourceType int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
  111. }
  112. type CygxMicroRoadshowVideoHistory struct {
  113. Id int `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
  114. VideoId int `description:"微路演视频id"`
  115. UserId int `description:"用户id"`
  116. Mobile string `description:"手机号"`
  117. Email string `description:"邮箱"`
  118. CompanyId int `description:"公司Id"`
  119. CompanyName string `description:"公司名称"`
  120. RealName string `description:"用户实际名称"`
  121. SellerName string `description:"所属销售"`
  122. PlaySeconds string `description:"播放时间 单位s"`
  123. CreateTime time.Time `description:"视频创建时间"`
  124. ModifyTime time.Time `description:"视频修改时间"`
  125. }
  126. func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
  127. o := orm.NewOrm()
  128. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
  129. err = o.Raw(sql, videoId, userId).QueryRow(&item)
  130. return
  131. }
  132. func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
  133. o := orm.NewOrm()
  134. _, err = o.Insert(item)
  135. return
  136. }
  137. // MicroAudioUnionList 微路演音频联合列表
  138. type MicroAudioUnionList struct {
  139. Id int `description:"音视频ID"`
  140. AudioTitle string `description:"标题"`
  141. AudioResourceUrl string `description:"链接"`
  142. AudioType int `description:"类型: 1-音频; 2-视频"`
  143. AudioPublishTime string `description:"发布时间"`
  144. AudioImgUrl string `description:"背景图"`
  145. AudioShareImg string `description:"分享图"`
  146. AudioChartPermissionId int `description:"行业ID"`
  147. AudioChartPermissionName string `description:"行业名称"`
  148. AudioPlaySeconds string `description:"音视频时长"`
  149. AudioActivityId int `description:"活动ID"`
  150. AuthInfo *UserPermissionAuthInfo
  151. }
  152. // HomeNewestUnionList 首页最新纪要-音频联合查询结果
  153. type HomeNewestUnionList struct {
  154. ArticleId int `description:"文章id"`
  155. Title string `description:"标题"`
  156. TitleEn string `description:"英文标题 "`
  157. UpdateFrequency string `description:"更新周期"`
  158. CreateDate string `description:"创建时间"`
  159. PublishDate string `description:"发布时间"`
  160. Body string `description:"内容"`
  161. BodyHtml string `description:"内容带有HTML标签"`
  162. Abstract string `description:"摘要"`
  163. CategoryName string `description:"一级分类"`
  164. SubCategoryName string `description:"二级分类"`
  165. ExpertBackground string `description:"专家背景"`
  166. IsResearch bool `description:"是否属于研选"`
  167. Pv int `description:"PV"`
  168. ImgUrlPc string `description:"图片链接"`
  169. CategoryId string `description:"文章分类"`
  170. HttpUrl string `description:"文章链接跳转地址"`
  171. IsNeedJump bool `description:"是否需要跳转链接地址"`
  172. Source int `description:"来源 1:文章, 2:图表"`
  173. Annotation string `description:"核心观点"`
  174. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  175. MicroAudioUnionList
  176. }
  177. // GetHomeNewestListUnionList 首页最新纪要-音频联合查询
  178. func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
  179. sql := `SELECT
  180. id, article_id, title, title_en, update_frequency, create_date, publish_date, body, abstract, category_name, sub_category_name, expert_background, category_id, source, annotation,
  181. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  182. 0 AS home_type, "" AS audio_title, "" AS audio_resource_url, 0 AS audio_type, "" AS audio_publish_time, 0 AS audio_chart_permission_id, "" AS audio_chart_permission_name,
  183. "" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
  184. FROM
  185. cygx_article AS art
  186. WHERE
  187. art.publish_status = 1 `
  188. if condition != `` {
  189. sql += condition
  190. }
  191. sql += ` UNION ALL
  192. SELECT
  193. a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
  194. 0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
  195. b.chart_permission_id, b.chart_permission_name, a.voice_play_seconds AS audio_play_seconds, a.img_url AS audio_img_url, a.activity_id AS audio_activity_id
  196. FROM
  197. cygx_activity_voice AS a
  198. JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
  199. sql += ` ORDER BY publish_date DESC`
  200. sql += ` LIMIT ?,?`
  201. _, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  202. return
  203. }
  204. // GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
  205. func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
  206. o := orm.NewOrm()
  207. sql := `SELECT
  208. COUNT(1) AS count
  209. FROM
  210. (
  211. SELECT
  212. art.id
  213. FROM
  214. cygx_article AS art
  215. WHERE
  216. art.publish_status = 1 `
  217. if condition != `` {
  218. sql += condition
  219. }
  220. sql += ` UNION ALL
  221. SELECT
  222. a.activity_voice_id
  223. FROM
  224. cygx_activity_voice AS a
  225. JOIN cygx_activity AS b ON a.activity_id = b.activity_id
  226. ) z `
  227. err = o.Raw(sql, pars).QueryRow(&count)
  228. return
  229. }
  230. func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
  231. o := orm.NewOrm()
  232. sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
  233. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  234. return
  235. }
  236. // MicroRoadshowVideo 微路演视频
  237. type MicroRoadshowVideo struct {
  238. VideoId int `orm:"column(video_id);pk" description:"视频ID"`
  239. VideoName string `description:"视频标题"`
  240. ChartPermissionId int `description:"行业ID"`
  241. ChartPermissionName string `description:"行业名称"`
  242. IndustryId int `description:"产业ID"`
  243. IndustryName string `description:"产业名称"`
  244. PublishStatus int `description:"发布状态:0-未发布;1-已发布"`
  245. ModifyDate time.Time `description:"更新时间"`
  246. PublishDate time.Time `description:"发布时间"`
  247. VideoCounts int `description:"视频播放量"`
  248. VideoDuration int `description:"视频时长"`
  249. VideoUrl string `description:"视频地址"`
  250. CreateTime time.Time `description:"创建时间"`
  251. ImgUrl string `description:"背景图链接"`
  252. }
  253. // GetMicroRoadshowVideoById 主键获取微路演视频
  254. func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
  255. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
  256. err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
  257. return
  258. }
  259. func UpdateCygxActivityVideoCounts(activityId int) (err error) {
  260. sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ? `
  261. o := orm.NewOrm()
  262. _, err = o.Raw(sql, activityId).Exec()
  263. return
  264. }