micro_roadshow.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_cygx/utils"
  6. "time"
  7. )
  8. // MicroRoadShowListResp 微路演列表响应体
  9. type MicroRoadShowListResp struct {
  10. Paging *paging.PagingItem
  11. List []*MicroRoadShowPageList
  12. }
  13. type CygxMicroRoadshowVideo struct {
  14. VideoId int `orm:"column(video_id);pk"description:"微路演视频id"`
  15. VideoName string `description:"视频名称"`
  16. ChartPermissionId int `description:"行业Id"`
  17. ChartPermissionName string `description:"行业名称"`
  18. IndustryId int `description:"产业id"`
  19. IndustryName string `description:"产业名称"`
  20. PublishStatus int `description:"发布状态 1发布 0没有"`
  21. ModifyDate string `description:"更新时间"`
  22. PublishDate time.Time `description:"发布时间"`
  23. VideoDuration string `description:"视频时长"`
  24. VideoCounts int `description:"播放量"`
  25. VideoUrl string `description:"视频地址"`
  26. CreateTime string `description:"创建时间"`
  27. ImgUrl string `description:"视频封面图"`
  28. ShareImgUrl string `description:"视频分享图"`
  29. DetailImgUrl string `description:"产业详情页背景图"`
  30. CommentNum int `description:"留言总数"`
  31. IsSendWxMsg int `description:"是否推送过微信模板消息,1是,0:否"`
  32. }
  33. func GetMicroRoadshowVideoByVideoId(videoId int) (item *CygxMicroRoadshowVideo, err error) {
  34. o := orm.NewOrm()
  35. sql := `SELECT * from cygx_micro_roadshow_video where video_id = ? `
  36. err = o.Raw(sql, videoId).QueryRow(&item)
  37. return
  38. }
  39. // MicroRoadShowPageList 微路演列表
  40. type MicroRoadShowPageList struct {
  41. Id int `description:"音视频ID"`
  42. Title string `description:"标题"`
  43. ResourceUrl string `description:"链接"`
  44. Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
  45. PublishTime string `description:"发布时间"`
  46. BackgroundImg string `description:"背景图"`
  47. ShareImg string `description:"分享封面图"`
  48. ChartPermissionId int `description:"行业ID"`
  49. ChartPermissionName string `description:"行业名称"`
  50. IndustryName string `description:"产业名称"`
  51. PlaySeconds string `description:"音视频时长"`
  52. ActivityId int `description:"活动ID"`
  53. IsCollect bool `description:"是否收藏"`
  54. AuthInfo *UserPermissionAuthInfo
  55. }
  56. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  57. func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId, filter int) (total int, list []*MicroRoadShowPageList, err error) {
  58. o := orm.NewOrm()
  59. var sql string
  60. //if audioId+activityVideoId == 0 && filter != 2 {
  61. sql += `SELECT
  62. video_id AS id,
  63. video_name AS title,
  64. video_url AS resource_url,
  65. 3 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. industry_name,
  72. share_img_url AS share_img,
  73. "" as activity_id
  74. FROM
  75. cygx_micro_roadshow_video
  76. WHERE
  77. publish_status = 1 `
  78. if condition != `` {
  79. sql += condition
  80. }
  81. //}
  82. //if audioId+videoId+activityVideoId == 0 && filter != 2 {
  83. // sql += ` UNION ALL `
  84. //}
  85. sql += ` UNION ALL `
  86. //if audioId+videoId == 0 && filter != 2 {
  87. sql += `
  88. SELECT
  89. video_id AS id,
  90. video_name AS title,
  91. video_url AS resource_url,
  92. 2 AS type,
  93. art.activity_time as publish_time,
  94. art.chart_permission_id,
  95. art.chart_permission_name,
  96. "" AS play_seconds,
  97. "" AS background_img,
  98. "" AS industry_name,
  99. "" AS share_img,
  100. v.activity_id
  101. FROM
  102. cygx_activity_video as v
  103. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  104. if conditionAct != `` {
  105. sql += conditionAct
  106. }
  107. //}
  108. //if audioId+videoId+activityVideoId == 0 && filter == 0 {
  109. // sql += ` UNION ALL `
  110. //}
  111. sql += ` UNION ALL `
  112. //if videoId+activityVideoId == 0 && filter != 1 {
  113. sql += `
  114. SELECT
  115. a.activity_voice_id AS id,
  116. a.voice_name AS title,
  117. a.voice_url AS resource_url,
  118. 1 AS type,
  119. b.activity_time AS publish_time,
  120. b.chart_permission_id,
  121. b.chart_permission_name,
  122. a.voice_play_seconds AS play_seconds,
  123. a.img_url AS background_img,
  124. "" AS industry_name,
  125. "" AS share_img,
  126. a.activity_id
  127. FROM
  128. cygx_activity_voice AS a
  129. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  130. if conditionAudio != `` {
  131. sql += conditionAudio
  132. }
  133. //}
  134. sql += ` ORDER BY publish_time DESC`
  135. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  136. err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
  137. if err != nil {
  138. return
  139. }
  140. sql += ` LIMIT ?,?`
  141. _, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
  142. return
  143. }
  144. // CountMicroRoadShowVideoPageList 获取微路演视频数量
  145. func CountMicroRoadShowVideoPageList(condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}) (total int, err error) {
  146. o := orm.NewOrm()
  147. var sql string
  148. sql += `SELECT
  149. video_id AS id,
  150. video_name AS title,
  151. video_url AS resource_url,
  152. 3 AS type,
  153. publish_date AS publish_time,
  154. chart_permission_id,
  155. chart_permission_name,
  156. video_duration AS play_seconds,
  157. img_url AS background_img,
  158. industry_name,
  159. share_img_url AS share_img,
  160. "" as activity_id
  161. FROM
  162. cygx_micro_roadshow_video
  163. WHERE
  164. publish_status = 1 `
  165. if condition != `` {
  166. sql += condition
  167. }
  168. sql += ` UNION ALL `
  169. sql += `
  170. SELECT
  171. video_id AS id,
  172. video_name AS title,
  173. video_url AS resource_url,
  174. 2 AS type,
  175. art.activity_time as publish_time,
  176. art.chart_permission_id,
  177. art.chart_permission_name,
  178. "" AS play_seconds,
  179. "" AS background_img,
  180. "" AS industry_name,
  181. "" AS share_img,
  182. v.activity_id
  183. FROM
  184. cygx_activity_video as v
  185. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  186. if conditionAct != `` {
  187. sql += conditionAct
  188. }
  189. sql += ` UNION ALL `
  190. sql += `
  191. SELECT
  192. a.activity_voice_id AS id,
  193. a.voice_name AS title,
  194. a.voice_url AS resource_url,
  195. 1 AS type,
  196. b.activity_time AS publish_time,
  197. b.chart_permission_id,
  198. b.chart_permission_name,
  199. a.voice_play_seconds AS play_seconds,
  200. a.img_url AS background_img,
  201. "" AS industry_name,
  202. "" AS share_img,
  203. a.activity_id
  204. FROM
  205. cygx_activity_voice AS a
  206. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  207. if conditionAudio != `` {
  208. sql += conditionAudio
  209. }
  210. sql += ` ORDER BY publish_time DESC`
  211. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  212. err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
  213. return
  214. }
  215. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  216. func GetMicroRoadShowVideoPageListIkWord(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId, filter int) (list []*MicroRoadShowPageList, err error) {
  217. o := orm.NewOrm()
  218. var sql string
  219. //if audioId+activityVideoId == 0 && filter != 2 {
  220. sql += `SELECT
  221. video_id AS id,
  222. video_name AS title,
  223. video_url AS resource_url,
  224. 3 AS type,
  225. publish_date AS publish_time,
  226. chart_permission_id,
  227. chart_permission_name,
  228. video_duration AS play_seconds,
  229. img_url AS background_img,
  230. industry_name,
  231. share_img_url AS share_img,
  232. "" as activity_id
  233. FROM
  234. cygx_micro_roadshow_video
  235. WHERE
  236. publish_status = 1 `
  237. if condition != `` {
  238. sql += condition
  239. }
  240. //}
  241. //if audioId+videoId+activityVideoId == 0 && filter != 2 {
  242. // sql += ` UNION ALL `
  243. //}
  244. sql += ` UNION ALL `
  245. //if audioId+videoId == 0 && filter != 2 {
  246. sql += `
  247. SELECT
  248. video_id AS id,
  249. video_name AS title,
  250. video_url AS resource_url,
  251. 2 AS type,
  252. art.activity_time as publish_time,
  253. art.chart_permission_id,
  254. art.chart_permission_name,
  255. "" AS play_seconds,
  256. "" AS background_img,
  257. "" AS industry_name,
  258. "" AS share_img,
  259. v.activity_id
  260. FROM
  261. cygx_activity_video as v
  262. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  263. if conditionAct != `` {
  264. sql += conditionAct
  265. }
  266. //}
  267. //if audioId+videoId+activityVideoId == 0 && filter == 0 {
  268. // sql += ` UNION ALL `
  269. //}
  270. sql += ` UNION ALL `
  271. //if videoId+activityVideoId == 0 && filter != 1 {
  272. sql += `
  273. SELECT
  274. a.activity_voice_id AS id,
  275. a.voice_name AS title,
  276. a.voice_url AS resource_url,
  277. 1 AS type,
  278. b.activity_time AS publish_time,
  279. b.chart_permission_id,
  280. b.chart_permission_name,
  281. a.voice_play_seconds AS play_seconds,
  282. a.img_url AS background_img,
  283. "" AS industry_name,
  284. "" AS share_img,
  285. a.activity_id
  286. FROM
  287. cygx_activity_voice AS a
  288. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  289. if conditionAudio != `` {
  290. sql += conditionAudio
  291. }
  292. //}
  293. sql += ` ORDER BY publish_time DESC`
  294. sql += ` LIMIT ?,?`
  295. _, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
  296. return
  297. }
  298. type AddVideoHistoryReq struct {
  299. VideoId int `description:"视频ID"`
  300. PlaySeconds int `description:"播放时长"`
  301. SourceType int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
  302. }
  303. func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
  304. o := orm.NewOrm()
  305. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
  306. err = o.Raw(sql, videoId, userId).QueryRow(&item)
  307. return
  308. }
  309. func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
  310. o := orm.NewOrm()
  311. _, err = o.Insert(item)
  312. return
  313. }
  314. // MicroAudioUnionList 微路演音频联合列表
  315. type MicroAudioUnionList struct {
  316. Id int `description:"音视频ID"`
  317. AudioTitle string `description:"标题"`
  318. AudioResourceUrl string `description:"链接"`
  319. AudioType int `description:"类型: 1-音频; 2-视频"`
  320. AudioPublishTime string `description:"发布时间"`
  321. AudioImgUrl string `description:"背景图"`
  322. AudioShareImg string `description:"分享图"`
  323. AudioChartPermissionId int `description:"行业ID"`
  324. AudioChartPermissionName string `description:"行业名称"`
  325. AudioPlaySeconds string `description:"音视频时长"`
  326. AudioActivityId int `description:"活动ID"`
  327. AuthInfo *UserPermissionAuthInfo
  328. }
  329. // HomeNewestUnionList 首页最新纪要-音频联合查询结果
  330. type HomeNewestUnionList struct {
  331. ArticleId int `description:"文章id"`
  332. Title string `description:"标题"`
  333. TitleEn string `description:"英文标题 "`
  334. UpdateFrequency string `description:"更新周期"`
  335. CreateDate string `description:"创建时间"`
  336. PublishDate string `description:"发布时间"`
  337. Body string `description:"内容"`
  338. BodyHtml string `description:"内容带有HTML标签"`
  339. Abstract string `description:"摘要"`
  340. CategoryName string `description:"一级分类"`
  341. SubCategoryName string `description:"二级分类"`
  342. ExpertBackground string `description:"专家背景"`
  343. IsResearch bool `description:"是否属于研选"`
  344. Pv int `description:"PV"`
  345. ImgUrlPc string `description:"图片链接"`
  346. CategoryId string `description:"文章分类"`
  347. HttpUrl string `description:"文章链接跳转地址"`
  348. IsNeedJump bool `description:"是否需要跳转链接地址"`
  349. Source int `description:"来源 1:文章, 2:图表"`
  350. Annotation string `description:"核心观点"`
  351. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  352. MicroAudioUnionList
  353. }
  354. // GetHomeNewestListUnionList 首页最新纪要-音频联合查询
  355. func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
  356. sql := `SELECT
  357. 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,
  358. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  359. 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,
  360. "" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
  361. FROM
  362. cygx_article AS art
  363. WHERE
  364. art.publish_status = 1 `
  365. if condition != `` {
  366. sql += condition
  367. }
  368. sql += ` UNION ALL
  369. SELECT
  370. a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
  371. 0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
  372. 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
  373. FROM
  374. cygx_activity_voice AS a
  375. JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
  376. sql += ` ORDER BY publish_date DESC`
  377. sql += ` LIMIT ?,?`
  378. _, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  379. return
  380. }
  381. // GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
  382. func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
  383. o := orm.NewOrm()
  384. sql := `SELECT
  385. COUNT(1) AS count
  386. FROM
  387. (
  388. SELECT
  389. art.id
  390. FROM
  391. cygx_article AS art
  392. WHERE
  393. art.publish_status = 1 `
  394. if condition != `` {
  395. sql += condition
  396. }
  397. sql += ` UNION ALL
  398. SELECT
  399. a.activity_voice_id
  400. FROM
  401. cygx_activity_voice AS a
  402. JOIN cygx_activity AS b ON a.activity_id = b.activity_id
  403. ) z `
  404. err = o.Raw(sql, pars).QueryRow(&count)
  405. return
  406. }
  407. func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
  408. o := orm.NewOrm()
  409. sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
  410. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  411. return
  412. }
  413. // MicroRoadshowVideo 微路演视频
  414. type MicroRoadshowVideo struct {
  415. VideoId int `orm:"column(video_id);pk" description:"视频ID"`
  416. VideoName string `description:"视频标题"`
  417. ChartPermissionId int `description:"行业ID"`
  418. ChartPermissionName string `description:"行业名称"`
  419. IndustryId int `description:"产业ID"`
  420. IndustryName string `description:"产业名称"`
  421. PublishStatus int `description:"发布状态:0-未发布;1-已发布"`
  422. ModifyDate time.Time `description:"更新时间"`
  423. PublishDate time.Time `description:"发布时间"`
  424. VideoCounts int `description:"视频播放量"`
  425. VideoDuration int `description:"视频时长"`
  426. VideoUrl string `description:"视频地址"`
  427. CreateTime time.Time `description:"创建时间"`
  428. ImgUrl string `description:"背景图链接"`
  429. DetailImgUrl string `description:"产业详情页背景图"`
  430. }
  431. // GetMicroRoadshowVideoById 主键获取微路演视频
  432. func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
  433. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
  434. err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
  435. return
  436. }
  437. func UpdateCygxActivityVideoCounts(activityId int) (err error) {
  438. sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ? `
  439. o := orm.NewOrm()
  440. _, err = o.Raw(sql, activityId).Exec()
  441. return
  442. }
  443. // GetMicroRoadshowVideoByIndustryIds 根据行业ID查询产业视频列表
  444. func GetMicroRoadshowVideoByIndustryIds(industrialIdArr []int) (list []*MicroRoadshowVideo, err error) {
  445. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (` + utils.GetOrmInReplace(len(industrialIdArr)) + `) and publish_status = 1 `
  446. _, err = orm.NewOrm().Raw(sql, industrialIdArr).QueryRows(&list)
  447. return
  448. }
  449. // GetMicroRoadshowVideoByIndustryId 根据行业ID查询产业视频列表
  450. func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo, err error) {
  451. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
  452. err = orm.NewOrm().Raw(sql, industryId).QueryRow(&item)
  453. return
  454. }
  455. type AddVideoCommnetReq struct {
  456. Id int `description:"活动或产业ID"`
  457. SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
  458. Content string `description:"内容"`
  459. Title string `description:"标题"`
  460. }
  461. type MicroRoadshowCollectReq struct {
  462. Id int `description:"音频或视频ID"`
  463. SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
  464. }
  465. // GetMicroRoadshowVideoListBycondition 根据搜索条件获取搜索列表
  466. func GetMicroRoadshowVideoListBycondition(condition string, pars []interface{}, startSize, pageSize int) (list []*MicroRoadshowVideo, err error) {
  467. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE 1 =1 `
  468. if condition != "" {
  469. sql += condition
  470. }
  471. sql += ` LIMIT ?,? `
  472. _, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  473. return
  474. }
  475. // GetMicroRoadshowVideoList 获取已经发布的微路演视频
  476. func GetMicroRoadshowVideoList() (list []*MicroRoadshowVideo, err error) {
  477. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE publish_status = 1`
  478. _, err = orm.NewOrm().Raw(sql).QueryRows(&list)
  479. return
  480. }
  481. // GetMicroRoadshowVideoByIndustryIdCount 根据行业ID查询产业视频是否存在
  482. func GetMicroRoadshowVideoByIndustryIdCount(industryId int) (count int, err error) {
  483. o := orm.NewOrm()
  484. sql := `SELECT COUNT(1) count
  485. FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
  486. err = o.Raw(sql, industryId).QueryRow(&count)
  487. return
  488. }