micro_roadshow.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. // GetMicroRoadShowAudioTotal 获取微路演音频数量
  59. func GetMicroRoadShowAudioTotal(condition string, pars []interface{}) (total int, err error) {
  60. o := orm.NewOrm()
  61. sql := `SELECT
  62. a.activity_id
  63. FROM
  64. cygx_activity_voice AS a
  65. JOIN cygx_activity AS b ON a.activity_id = b.activity_id
  66. WHERE 1 = 1 `
  67. if condition != `` {
  68. sql += condition
  69. }
  70. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  71. err = o.Raw(totalSql, pars).QueryRow(&total)
  72. if err != nil {
  73. return
  74. }
  75. return
  76. }
  77. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  78. func GetMicroRoadShowVideoPageList(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  79. o := orm.NewOrm()
  80. sql := `SELECT
  81. video_id AS id,
  82. video_name AS title,
  83. video_url AS resource_url,
  84. 2 AS type,
  85. publish_date AS publish_time,
  86. chart_permission_id,
  87. chart_permission_name,
  88. video_duration AS play_seconds,
  89. img_url AS background_img,
  90. "" as activity_id
  91. FROM
  92. cygx_micro_roadshow_video
  93. WHERE
  94. publish_status = 1 `
  95. if condition != `` {
  96. sql += condition
  97. }
  98. sql += ` UNION ALL
  99. SELECT
  100. video_id AS id,
  101. video_name AS title,
  102. video_url AS resource_url,
  103. 2 AS type,
  104. art.activity_time as publish_time,
  105. art.chart_permission_id,
  106. art.chart_permission_name,
  107. "",
  108. "",
  109. v.activity_id
  110. FROM
  111. cygx_activity_video as v
  112. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  113. if conditionAct != `` {
  114. sql += conditionAct
  115. }
  116. sql += ` ORDER BY publish_time DESC`
  117. //totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  118. //err = o.Raw(totalSql, pars, parsAct).QueryRow(&total)
  119. //if err != nil {
  120. // return
  121. //}
  122. sql += ` LIMIT ?,?`
  123. _, err = o.Raw(sql, pars, parsAct, startSize, pageSize).QueryRows(&list)
  124. return
  125. }
  126. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  127. func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId int) (total int, list []*MicroRoadShowPageList, err error) {
  128. o := orm.NewOrm()
  129. var sql string
  130. if audioId+activityVideoId == 0 {
  131. sql += `SELECT
  132. video_id AS id,
  133. video_name AS title,
  134. video_url AS resource_url,
  135. 2 AS type,
  136. publish_date AS publish_time,
  137. chart_permission_id,
  138. chart_permission_name,
  139. video_duration AS play_seconds,
  140. img_url AS background_img,
  141. "" as activity_id
  142. FROM
  143. cygx_micro_roadshow_video
  144. WHERE
  145. publish_status = 1 `
  146. if condition != `` {
  147. sql += condition
  148. }
  149. }
  150. if audioId+videoId+activityVideoId == 0 {
  151. sql += ` UNION ALL `
  152. }
  153. if audioId+videoId == 0 {
  154. sql += `
  155. SELECT
  156. video_id AS id,
  157. video_name AS title,
  158. video_url AS resource_url,
  159. 2 AS type,
  160. art.activity_time as publish_time,
  161. art.chart_permission_id,
  162. art.chart_permission_name,
  163. "" AS play_seconds,
  164. "" AS background_img,
  165. v.activity_id
  166. FROM
  167. cygx_activity_video as v
  168. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  169. if conditionAct != `` {
  170. sql += conditionAct
  171. }
  172. }
  173. if audioId+videoId+activityVideoId == 0 {
  174. sql += ` UNION ALL `
  175. }
  176. if videoId+activityVideoId == 0 {
  177. sql += `
  178. SELECT
  179. a.activity_voice_id AS id,
  180. a.voice_name AS title,
  181. a.voice_url AS resource_url,
  182. 1 AS type,
  183. b.activity_time AS publish_time,
  184. b.chart_permission_id,
  185. b.chart_permission_name,
  186. a.voice_play_seconds AS play_seconds,
  187. a.img_url AS background_img,
  188. a.activity_id
  189. FROM
  190. cygx_activity_voice AS a
  191. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  192. if conditionAudio != `` {
  193. sql += conditionAudio
  194. }
  195. }
  196. sql += ` ORDER BY publish_time DESC`
  197. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  198. err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
  199. if err != nil {
  200. return
  201. }
  202. sql += ` LIMIT ?,?`
  203. _, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
  204. return
  205. }
  206. // GetMicroRoadShowVideoTotal 获取微路演视频总量
  207. func GetMicroRoadShowVideoTotal(condition string, pars []interface{}, conditionAct string, parsAct []interface{}) (total int, err error) {
  208. o := orm.NewOrm()
  209. sql := `SELECT
  210. video_id AS id,
  211. video_name AS title,
  212. video_url AS resource_url,
  213. 2 AS type,
  214. publish_date AS publish_time,
  215. chart_permission_id,
  216. chart_permission_name,
  217. video_duration AS play_seconds,
  218. img_url AS background_img,
  219. "" as activity_id
  220. FROM
  221. cygx_micro_roadshow_video
  222. WHERE
  223. publish_status = 1 `
  224. if condition != `` {
  225. sql += condition
  226. }
  227. sql += ` UNION ALL
  228. SELECT
  229. video_id AS id,
  230. video_name AS title,
  231. video_url AS resource_url,
  232. 2 AS type,
  233. art.activity_time as publish_time,
  234. art.chart_permission_id,
  235. art.chart_permission_name,
  236. "",
  237. "",
  238. v.activity_id
  239. FROM
  240. cygx_activity_video as v
  241. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  242. if conditionAct != `` {
  243. sql += conditionAct
  244. }
  245. sql += ` ORDER BY publish_time DESC`
  246. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  247. err = o.Raw(totalSql, pars, parsAct).QueryRow(&total)
  248. return
  249. }
  250. type AddVideoHistoryReq struct {
  251. VideoId int `description:"视频ID"`
  252. PlaySeconds int `description:"播放时长"`
  253. SourceType int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
  254. }
  255. type CygxMicroRoadshowVideoHistory struct {
  256. Id int `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
  257. VideoId int `description:"微路演视频id"`
  258. UserId int `description:"用户id"`
  259. Mobile string `description:"手机号"`
  260. Email string `description:"邮箱"`
  261. CompanyId int `description:"公司Id"`
  262. CompanyName string `description:"公司名称"`
  263. RealName string `description:"用户实际名称"`
  264. SellerName string `description:"所属销售"`
  265. PlaySeconds string `description:"播放时间 单位s"`
  266. CreateTime time.Time `description:"视频创建时间"`
  267. ModifyTime time.Time `description:"视频修改时间"`
  268. }
  269. func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
  270. o := orm.NewOrm()
  271. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
  272. err = o.Raw(sql, videoId, userId).QueryRow(&item)
  273. return
  274. }
  275. func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
  276. o := orm.NewOrm()
  277. _, err = o.Insert(item)
  278. return
  279. }
  280. // MicroAudioUnionList 微路演音频联合列表
  281. type MicroAudioUnionList struct {
  282. Id int `description:"音视频ID"`
  283. AudioTitle string `description:"标题"`
  284. AudioResourceUrl string `description:"链接"`
  285. AudioType int `description:"类型: 1-音频; 2-视频"`
  286. AudioPublishTime string `description:"发布时间"`
  287. AudioImgUrl string `description:"背景图"`
  288. AudioShareImg string `description:"分享图"`
  289. AudioChartPermissionId int `description:"行业ID"`
  290. AudioChartPermissionName string `description:"行业名称"`
  291. AudioPlaySeconds string `description:"音视频时长"`
  292. AudioActivityId int `description:"活动ID"`
  293. AuthInfo *UserPermissionAuthInfo
  294. }
  295. // HomeNewestUnionList 首页最新纪要-音频联合查询结果
  296. type HomeNewestUnionList struct {
  297. ArticleId int `description:"文章id"`
  298. Title string `description:"标题"`
  299. TitleEn string `description:"英文标题 "`
  300. UpdateFrequency string `description:"更新周期"`
  301. CreateDate string `description:"创建时间"`
  302. PublishDate string `description:"发布时间"`
  303. Body string `description:"内容"`
  304. BodyHtml string `description:"内容带有HTML标签"`
  305. Abstract string `description:"摘要"`
  306. CategoryName string `description:"一级分类"`
  307. SubCategoryName string `description:"二级分类"`
  308. ExpertBackground string `description:"专家背景"`
  309. IsResearch bool `description:"是否属于研选"`
  310. Pv int `description:"PV"`
  311. ImgUrlPc string `description:"图片链接"`
  312. CategoryId string `description:"文章分类"`
  313. HttpUrl string `description:"文章链接跳转地址"`
  314. IsNeedJump bool `description:"是否需要跳转链接地址"`
  315. Source int `description:"来源 1:文章, 2:图表"`
  316. Annotation string `description:"核心观点"`
  317. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  318. MicroAudioUnionList
  319. }
  320. // GetHomeNewestListUnionList 首页最新纪要-音频联合查询
  321. func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
  322. sql := `SELECT
  323. 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,
  324. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  325. 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,
  326. "" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
  327. FROM
  328. cygx_article AS art
  329. WHERE
  330. art.publish_status = 1 `
  331. if condition != `` {
  332. sql += condition
  333. }
  334. sql += ` UNION ALL
  335. SELECT
  336. a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
  337. 0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
  338. 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
  339. FROM
  340. cygx_activity_voice AS a
  341. JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
  342. sql += ` ORDER BY publish_date DESC`
  343. sql += ` LIMIT ?,?`
  344. _, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  345. return
  346. }
  347. // GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
  348. func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
  349. o := orm.NewOrm()
  350. sql := `SELECT
  351. COUNT(1) AS count
  352. FROM
  353. (
  354. SELECT
  355. art.id
  356. FROM
  357. cygx_article AS art
  358. WHERE
  359. art.publish_status = 1 `
  360. if condition != `` {
  361. sql += condition
  362. }
  363. sql += ` UNION ALL
  364. SELECT
  365. a.activity_voice_id
  366. FROM
  367. cygx_activity_voice AS a
  368. JOIN cygx_activity AS b ON a.activity_id = b.activity_id
  369. ) z `
  370. err = o.Raw(sql, pars).QueryRow(&count)
  371. return
  372. }
  373. func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
  374. o := orm.NewOrm()
  375. sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
  376. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  377. return
  378. }
  379. // MicroRoadshowVideo 微路演视频
  380. type MicroRoadshowVideo struct {
  381. VideoId int `orm:"column(video_id);pk" description:"视频ID"`
  382. VideoName string `description:"视频标题"`
  383. ChartPermissionId int `description:"行业ID"`
  384. ChartPermissionName string `description:"行业名称"`
  385. IndustryId int `description:"产业ID"`
  386. IndustryName string `description:"产业名称"`
  387. PublishStatus int `description:"发布状态:0-未发布;1-已发布"`
  388. ModifyDate time.Time `description:"更新时间"`
  389. PublishDate time.Time `description:"发布时间"`
  390. VideoCounts int `description:"视频播放量"`
  391. VideoDuration int `description:"视频时长"`
  392. VideoUrl string `description:"视频地址"`
  393. CreateTime time.Time `description:"创建时间"`
  394. ImgUrl string `description:"背景图链接"`
  395. }
  396. // GetMicroRoadshowVideoById 主键获取微路演视频
  397. func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
  398. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
  399. err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
  400. return
  401. }
  402. func UpdateCygxActivityVideoCounts(activityId int) (err error) {
  403. sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ? `
  404. o := orm.NewOrm()
  405. _, err = o.Raw(sql, activityId).Exec()
  406. return
  407. }