micro_roadshow.go 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_mfyx/utils"
  6. "time"
  7. )
  8. // MicroRoadShowListResp 微路演列表响应体
  9. type MicroRoadShowListResp struct {
  10. Paging *paging.PagingItem
  11. List []*MicroRoadShowPageList
  12. Describe string `description:"说明"`
  13. }
  14. type CygxMicroRoadshowVideo struct {
  15. VideoId int `orm:"column(video_id);pk"description:"微路演视频id"`
  16. VideoName string `description:"视频名称"`
  17. ChartPermissionId int `description:"行业Id"`
  18. ChartPermissionName string `description:"行业名称"`
  19. IndustryId int `description:"产业id"`
  20. IndustryName string `description:"产业名称"`
  21. PublishStatus int `description:"发布状态 1发布 0没有"`
  22. ModifyDate string `description:"更新时间"`
  23. PublishDate time.Time `description:"发布时间"`
  24. VideoDuration string `description:"视频时长"`
  25. VideoCounts int `description:"播放量"`
  26. VideoUrl string `description:"视频地址"`
  27. CreateTime string `description:"创建时间"`
  28. ImgUrl string `description:"视频封面图"`
  29. ShareImgUrl string `description:"视频分享图"`
  30. DetailImgUrl string `description:"产业详情页背景图"`
  31. CommentNum int `description:"留言总数"`
  32. IsSendWxMsg int `description:"是否推送过微信模板消息,1是,0:否"`
  33. }
  34. func GetMicroRoadshowVideoByVideoId(videoId int) (item *CygxMicroRoadshowVideo, err error) {
  35. o := orm.NewOrm()
  36. sql := `SELECT * from cygx_micro_roadshow_video where video_id = ? `
  37. err = o.Raw(sql, videoId).QueryRow(&item)
  38. return
  39. }
  40. // MicroRoadShowPageList 微路演列表
  41. type MicroRoadShowPageList struct {
  42. Id int `description:"音视频ID"`
  43. SourceId int `description:"资源ID"`
  44. Title string `description:"标题"`
  45. ResourceUrl string `description:"链接"`
  46. Type int `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-问答系列"`
  47. LabelType int `description:"标签类型: 1-路演回放; 2-调研反馈; 3-产业视频; 4-问答系列"`
  48. ActivityFileType int `description:"活动音视频文件类型: 1-路演回放; 2-调研反馈"`
  49. PublishTime string `description:"发布时间"`
  50. BackgroundImg string `description:"背景图"`
  51. ShareImg string `description:"分享封面图"`
  52. ChartPermissionId int `description:"行业ID"`
  53. ChartPermissionName string `description:"行业名称"`
  54. IndustryName string `description:"产业名称"`
  55. IndustryId int `description:"产业id"`
  56. PlaySeconds string `description:"音视频时长"`
  57. ActivityId int `description:"活动ID"`
  58. IsCollect bool `description:"是否收藏"`
  59. LabelKeywordImgLink string `description:"标签关键词ico"`
  60. AuthInfo *UserPermissionAuthInfo
  61. }
  62. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  63. func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  64. o := orm.NewOrm()
  65. var sql string
  66. //if audioId+activityVideoId == 0 && filter != 2 {
  67. sql += `SELECT
  68. video_id AS id,
  69. video_name AS title,
  70. video_url AS resource_url,
  71. 3 AS type,
  72. publish_date AS publish_time,
  73. chart_permission_id,
  74. chart_permission_name,
  75. video_duration AS play_seconds,
  76. img_url AS background_img,
  77. industry_name,
  78. industry_id,
  79. share_img_url AS share_img,
  80. "" as activity_id
  81. FROM
  82. cygx_micro_roadshow_video
  83. WHERE
  84. publish_status = 1 `
  85. if condition != `` {
  86. sql += condition
  87. }
  88. //}
  89. //if audioId+videoId+activityVideoId == 0 && filter != 2 {
  90. // sql += ` UNION ALL `
  91. //}
  92. sql += ` UNION ALL `
  93. //if audioId+videoId == 0 && filter != 2 {
  94. sql += `
  95. SELECT
  96. video_id AS id,
  97. video_name AS title,
  98. video_url AS resource_url,
  99. 2 AS type,
  100. art.activity_time as publish_time,
  101. art.chart_permission_id,
  102. art.chart_permission_name,
  103. "" AS play_seconds,
  104. v.background_img,
  105. "" AS industry_name,
  106. "",
  107. v.share_img,
  108. v.activity_id
  109. FROM
  110. cygx_activity_video as v
  111. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  112. if conditionAct != `` {
  113. sql += conditionAct
  114. }
  115. //}
  116. //if audioId+videoId+activityVideoId == 0 && filter == 0 {
  117. // sql += ` UNION ALL `
  118. //}
  119. sql += ` UNION ALL `
  120. //if videoId+activityVideoId == 0 && filter != 1 {
  121. sql += `
  122. SELECT
  123. a.activity_voice_id AS id,
  124. a.voice_name AS title,
  125. a.voice_url AS resource_url,
  126. 1 AS type,
  127. b.activity_time AS publish_time,
  128. b.chart_permission_id,
  129. b.chart_permission_name,
  130. a.voice_play_seconds AS play_seconds,
  131. a.background_img,
  132. "" AS industry_name,
  133. "",
  134. a.share_img,
  135. a.activity_id
  136. FROM
  137. cygx_activity_voice AS a
  138. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  139. if conditionAudio != `` {
  140. sql += conditionAudio
  141. }
  142. //}
  143. sql += ` ORDER BY publish_time DESC`
  144. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  145. err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
  146. if err != nil {
  147. return
  148. }
  149. sql += ` LIMIT ?,?`
  150. _, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
  151. return
  152. }
  153. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  154. func GetMicroRoadShowVideoPageListV12(startSize, pageSize int, audioAct string, audioActPars []interface{}, videoAct string, videoActPars []interface{}, videoMico string, videoMicoPars []interface{}, conditionAskserie string, askseriePars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  155. o := orm.NewOrm()
  156. var sql string
  157. //活动音频1
  158. sql += `
  159. SELECT
  160. a.activity_voice_id AS id,
  161. a.activity_id AS source_id,
  162. a.voice_name AS title,
  163. a.voice_url AS resource_url,
  164. 1 AS type,
  165. b.activity_time AS publish_time,
  166. b.chart_permission_id,
  167. b.chart_permission_name,
  168. a.voice_play_seconds AS play_seconds,
  169. a.background_img,
  170. "" AS industry_name,
  171. 0 AS industry_id,
  172. a.share_img,
  173. a.file_type as activity_file_type,
  174. a.activity_id
  175. FROM
  176. cygx_activity_voice AS a
  177. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  178. if audioAct != `` {
  179. sql += audioAct
  180. }
  181. //活动视频2
  182. sql += ` UNION ALL `
  183. sql += `
  184. SELECT
  185. a.video_id AS id,
  186. a.activity_id AS source_id,
  187. a.video_name AS title,
  188. a.video_url AS resource_url,
  189. 2 AS type,
  190. b.activity_time as publish_time,
  191. b.chart_permission_id,
  192. b.chart_permission_name,
  193. a.video_duration AS play_seconds,
  194. a.background_img,
  195. "" AS industry_name,
  196. 0 AS industry_id,
  197. a.share_img,
  198. a.file_type as activity_file_type,
  199. a.activity_id
  200. FROM
  201. cygx_activity_video as a
  202. INNER JOIN cygx_activity as b on a.activity_id = b.activity_id WHERE 1= 1 `
  203. if videoAct != `` {
  204. sql += videoAct
  205. }
  206. sql += ` UNION ALL `
  207. // 产业视频3
  208. sql += `SELECT
  209. video_id AS id,
  210. video_id AS source_id,
  211. video_name AS title,
  212. video_url AS resource_url,
  213. 3 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. industry_name,
  220. industry_id,
  221. share_img_url AS share_img,
  222. '' as activity_file_type,
  223. "" as activity_id
  224. FROM
  225. cygx_micro_roadshow_video as a
  226. WHERE
  227. publish_status = 1 `
  228. if videoMico != `` {
  229. sql += videoMico
  230. }
  231. //系列问答
  232. sql += ` UNION ALL `
  233. sql += `
  234. SELECT
  235. a.askserie_video_id AS id,
  236. a.askserie_video_id AS source_id,
  237. a.video_name AS title,
  238. a.video_url AS resource_url,
  239. 4 AS type,
  240. a.publish_date AS publish_time,
  241. a.chart_permission_id,
  242. a.chart_permission_name,
  243. a.video_duration AS play_seconds,
  244. a.background_img,
  245. "" AS industry_name,
  246. 0 AS industry_id,
  247. a.share_img,
  248. '' as activity_file_type,
  249. 0 as activity_id
  250. FROM
  251. cygx_askserie_video AS a WHERE 1= 1 `
  252. if conditionAskserie != `` {
  253. sql += conditionAskserie
  254. }
  255. sql += ` ORDER BY publish_time DESC`
  256. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  257. err = o.Raw(totalSql, audioActPars, videoActPars, videoMicoPars, askseriePars).QueryRow(&total)
  258. if err != nil {
  259. return
  260. }
  261. sql += ` LIMIT ?,?`
  262. _, err = o.Raw(sql, audioActPars, videoActPars, videoMicoPars, askseriePars, startSize, pageSize).QueryRows(&list)
  263. return
  264. }
  265. // CountMicroRoadShowVideoPageList 获取微路演视频数量
  266. func CountMicroRoadShowVideoPageList(condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}) (total int, err error) {
  267. o := orm.NewOrm()
  268. var sql string
  269. sql += `SELECT
  270. video_id AS id,
  271. video_name AS title,
  272. video_url AS resource_url,
  273. 3 AS type,
  274. publish_date AS publish_time,
  275. chart_permission_id,
  276. chart_permission_name,
  277. video_duration AS play_seconds,
  278. img_url AS background_img,
  279. industry_name,
  280. share_img_url AS share_img,
  281. "" as activity_id
  282. FROM
  283. cygx_micro_roadshow_video
  284. WHERE
  285. publish_status = 1 `
  286. if condition != `` {
  287. sql += condition
  288. }
  289. sql += ` UNION ALL `
  290. sql += `
  291. SELECT
  292. video_id AS id,
  293. video_name AS title,
  294. video_url AS resource_url,
  295. 2 AS type,
  296. art.activity_time as publish_time,
  297. art.chart_permission_id,
  298. art.chart_permission_name,
  299. "" AS play_seconds,
  300. v.background_img,
  301. "" AS industry_name,
  302. v.share_img,
  303. v.activity_id
  304. FROM
  305. cygx_activity_video as v
  306. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  307. if conditionAct != `` {
  308. sql += conditionAct
  309. }
  310. sql += ` UNION ALL `
  311. sql += `
  312. SELECT
  313. a.activity_voice_id AS id,
  314. a.voice_name AS title,
  315. a.voice_url AS resource_url,
  316. 1 AS type,
  317. b.activity_time AS publish_time,
  318. b.chart_permission_id,
  319. b.chart_permission_name,
  320. a.voice_play_seconds AS play_seconds,
  321. a.background_img,
  322. "" AS industry_name,
  323. a.share_img,
  324. a.activity_id
  325. FROM
  326. cygx_activity_voice AS a
  327. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  328. if conditionAudio != `` {
  329. sql += conditionAudio
  330. }
  331. sql += ` ORDER BY publish_time DESC`
  332. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  333. err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
  334. return
  335. }
  336. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  337. func GetMicroRoadShowVideoPageListIkWord(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}) (list []*MicroRoadShowPageList, err error) {
  338. o := orm.NewOrm()
  339. var sql string
  340. //if audioId+activityVideoId == 0 && filter != 2 {
  341. sql += `SELECT
  342. video_id AS id,
  343. video_name AS title,
  344. video_url AS resource_url,
  345. 3 AS type,
  346. publish_date AS publish_time,
  347. chart_permission_id,
  348. chart_permission_name,
  349. video_duration AS play_seconds,
  350. img_url AS background_img,
  351. industry_name,
  352. share_img_url AS share_img,
  353. "" as activity_id
  354. FROM
  355. cygx_micro_roadshow_video
  356. WHERE
  357. publish_status = 1 `
  358. if condition != `` {
  359. sql += condition
  360. }
  361. //}
  362. //if audioId+videoId+activityVideoId == 0 && filter != 2 {
  363. // sql += ` UNION ALL `
  364. //}
  365. sql += ` UNION ALL `
  366. //if audioId+videoId == 0 && filter != 2 {
  367. sql += `
  368. SELECT
  369. video_id AS id,
  370. video_name AS title,
  371. video_url AS resource_url,
  372. 2 AS type,
  373. art.activity_time as publish_time,
  374. art.chart_permission_id,
  375. art.chart_permission_name,
  376. "" AS play_seconds,
  377. v.background_img,
  378. "" AS industry_name,
  379. v.share_img,
  380. v.activity_id
  381. FROM
  382. cygx_activity_video as v
  383. INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1 `
  384. if conditionAct != `` {
  385. sql += conditionAct
  386. }
  387. //}
  388. //if audioId+videoId+activityVideoId == 0 && filter == 0 {
  389. // sql += ` UNION ALL `
  390. //}
  391. sql += ` UNION ALL `
  392. //if videoId+activityVideoId == 0 && filter != 1 {
  393. sql += `
  394. SELECT
  395. a.activity_voice_id AS id,
  396. a.voice_name AS title,
  397. a.voice_url AS resource_url,
  398. 1 AS type,
  399. b.activity_time AS publish_time,
  400. b.chart_permission_id,
  401. b.chart_permission_name,
  402. a.voice_play_seconds AS play_seconds,
  403. a.background_img,
  404. "" AS industry_name,
  405. a.share_img,
  406. a.activity_id
  407. FROM
  408. cygx_activity_voice AS a
  409. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 `
  410. if conditionAudio != `` {
  411. sql += conditionAudio
  412. }
  413. //}
  414. sql += ` ORDER BY publish_time DESC`
  415. sql += ` LIMIT ?,?`
  416. _, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
  417. return
  418. }
  419. type AddVideoHistoryReq struct {
  420. SourceId int `description:"资源ID"`
  421. //VideoId int `description:"视频ID"`
  422. PlaySeconds int `description:"播放时长"`
  423. //SourceType int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
  424. SourceType int `description:"音视频来源: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
  425. InviteShareCode string `description:"销售账号邀请码"`
  426. }
  427. func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
  428. o := orm.NewOrm()
  429. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
  430. err = o.Raw(sql, videoId, userId).QueryRow(&item)
  431. return
  432. }
  433. func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
  434. o := orm.NewOrm()
  435. _, err = o.Insert(item)
  436. return
  437. }
  438. // MicroAudioUnionList 微路演音频联合列表
  439. type MicroAudioUnionList struct {
  440. Id int `description:"音视频ID"`
  441. AudioTitle string `description:"标题"`
  442. AudioResourceUrl string `description:"链接"`
  443. AudioType int `description:"类型: 1-音频; 2-视频"`
  444. AudioPublishTime string `description:"发布时间"`
  445. AudioImgUrl string `description:"背景图"`
  446. AudioShareImg string `description:"分享图"`
  447. AudioChartPermissionId int `description:"行业ID"`
  448. AudioChartPermissionName string `description:"行业名称"`
  449. AudioPlaySeconds string `description:"音视频时长"`
  450. AudioActivityId int `description:"活动ID"`
  451. AuthInfo *UserPermissionAuthInfo
  452. }
  453. // HomeNewestUnionList 首页最新纪要-音频联合查询结果
  454. type HomeNewestUnionList struct {
  455. ArticleId int `description:"文章id"`
  456. Title string `description:"标题"`
  457. TitleEn string `description:"英文标题 "`
  458. UpdateFrequency string `description:"更新周期"`
  459. CreateDate string `description:"创建时间"`
  460. PublishDate string `description:"发布时间"`
  461. Body string `description:"内容"`
  462. BodyHtml string `description:"内容带有HTML标签"`
  463. Abstract string `description:"摘要"`
  464. CategoryName string `description:"一级分类"`
  465. SubCategoryName string `description:"二级分类"`
  466. ExpertBackground string `description:"专家背景"`
  467. IsResearch bool `description:"是否属于研选"`
  468. Pv int `description:"PV"`
  469. ImgUrlPc string `description:"图片链接"`
  470. CategoryId string `description:"文章分类"`
  471. HttpUrl string `description:"文章链接跳转地址"`
  472. IsNeedJump bool `description:"是否需要跳转链接地址"`
  473. Source int `description:"来源 1:文章, 2:图表"`
  474. Annotation string `description:"核心观点"`
  475. HomeType int `description:"数据类型:0-纪要(默认); 1-微路演音频"`
  476. MicroAudioUnionList
  477. }
  478. // GetHomeNewestListUnionList 首页最新纪要-音频联合查询
  479. func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
  480. sql := `SELECT
  481. 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,
  482. (SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
  483. 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,
  484. "" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
  485. FROM
  486. cygx_article AS art
  487. WHERE
  488. art.publish_status = 1 `
  489. if condition != `` {
  490. sql += condition
  491. }
  492. sql += ` UNION ALL
  493. SELECT
  494. a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
  495. 0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
  496. 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
  497. FROM
  498. cygx_activity_voice AS a
  499. JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
  500. sql += ` ORDER BY publish_date DESC`
  501. sql += ` LIMIT ?,?`
  502. _, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  503. return
  504. }
  505. // GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
  506. func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
  507. o := orm.NewOrm()
  508. sql := `SELECT
  509. COUNT(1) AS count
  510. FROM
  511. (
  512. SELECT
  513. art.id
  514. FROM
  515. cygx_article AS art
  516. WHERE
  517. art.publish_status = 1 `
  518. if condition != `` {
  519. sql += condition
  520. }
  521. sql += ` UNION ALL
  522. SELECT
  523. a.activity_voice_id
  524. FROM
  525. cygx_activity_voice AS a
  526. JOIN cygx_activity AS b ON a.activity_id = b.activity_id
  527. ) z `
  528. err = o.Raw(sql, pars).QueryRow(&count)
  529. return
  530. }
  531. // MicroRoadshowVideo 微路演视频
  532. type MicroRoadshowVideo struct {
  533. VideoId int `orm:"column(video_id);pk" description:"视频ID"`
  534. VideoName string `description:"视频标题"`
  535. ChartPermissionId int `description:"行业ID"`
  536. ChartPermissionName string `description:"行业名称"`
  537. IndustryId int `description:"产业ID"`
  538. IndustryName string `description:"产业名称"`
  539. PublishStatus int `description:"发布状态:0-未发布;1-已发布"`
  540. ModifyDate time.Time `description:"更新时间"`
  541. PublishDate time.Time `description:"发布时间"`
  542. VideoCounts int `description:"视频播放量"`
  543. VideoDuration int `description:"视频时长"`
  544. VideoUrl string `description:"视频地址"`
  545. CreateTime time.Time `description:"创建时间"`
  546. ImgUrl string `description:"背景图链接"`
  547. DetailImgUrl string `description:"产业详情页背景图"`
  548. }
  549. // GetMicroRoadshowVideoById 主键获取微路演视频
  550. func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
  551. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
  552. err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
  553. return
  554. }
  555. func UpdateCygxMicroRoadshowVideo(videoId int) (err error) {
  556. sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ? `
  557. o := orm.NewOrm()
  558. _, err = o.Raw(sql, videoId).Exec()
  559. return
  560. }
  561. func UpdateLastCygxMicroRoadshowVideoHistory(playSeconds string, lastId int) (err error) {
  562. o := orm.NewOrm()
  563. sql := ` UPDATE cygx_micro_roadshow_video SET play_seconds = play_seconds +? WHERE id=? `
  564. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  565. return
  566. }
  567. // GetMicroRoadshowVideoByIndustryIds 根据行业ID查询产业视频列表
  568. func GetMicroRoadshowVideoByIndustryIds(industrialIdArr []int) (list []*MicroRoadshowVideo, err error) {
  569. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (` + utils.GetOrmInReplace(len(industrialIdArr)) + `) and publish_status = 1 `
  570. _, err = orm.NewOrm().Raw(sql, industrialIdArr).QueryRows(&list)
  571. return
  572. }
  573. // GetMicroRoadshowVideoByIndustryId 根据行业ID查询产业视频列表
  574. func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo, err error) {
  575. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
  576. err = orm.NewOrm().Raw(sql, industryId).QueryRow(&item)
  577. return
  578. }
  579. type AddVideoCommnetReq struct {
  580. //Id int `description:"活动或产业ID"`
  581. SourceId int `description:"资源ID"`
  582. SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
  583. Content string `description:"内容"`
  584. Title string `description:"标题"`
  585. }
  586. type MicroRoadshowCollectReq struct {
  587. SourceId int `description:"音频或视频ID"`
  588. SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
  589. }
  590. // GetMicroRoadshowVideoListBycondition 根据搜索条件获取搜索列表
  591. func GetMicroRoadshowVideoListBycondition(condition string, pars []interface{}, startSize, pageSize int) (list []*MicroRoadshowVideo, err error) {
  592. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE 1 =1 `
  593. if condition != "" {
  594. sql += condition
  595. }
  596. sql += ` LIMIT ?,? `
  597. _, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  598. return
  599. }
  600. // GetMicroRoadshowVideoList 获取已经发布的微路演视频
  601. func GetMicroRoadshowVideoList() (list []*MicroRoadshowVideo, err error) {
  602. sql := `SELECT * FROM cygx_micro_roadshow_video WHERE publish_status = 1`
  603. _, err = orm.NewOrm().Raw(sql).QueryRows(&list)
  604. return
  605. }
  606. // GetMicroRoadshowVideoByIndustryIdCount 根据行业ID查询产业视频是否存在
  607. func GetMicroRoadshowVideoByIndustryIdCount(industryId int) (count int, err error) {
  608. o := orm.NewOrm()
  609. sql := `SELECT COUNT(1) count
  610. FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
  611. err = o.Raw(sql, industryId).QueryRow(&count)
  612. return
  613. }
  614. func GetMicroRoadShowVideoPageListByActivityIds(activityIds []int) (list []*MicroRoadShowPageList, err error) {
  615. lenArr := len(activityIds)
  616. if lenArr == 0 {
  617. return
  618. }
  619. o := orm.NewOrm()
  620. var sql string
  621. //活动音频1
  622. sql += `
  623. SELECT
  624. a.activity_voice_id AS id,
  625. a.activity_id AS source_id,
  626. a.voice_name AS title,
  627. a.voice_url AS resource_url,
  628. 1 AS type,
  629. b.activity_time AS publish_time,
  630. b.chart_permission_id,
  631. b.chart_permission_name,
  632. a.voice_play_seconds AS play_seconds,
  633. a.background_img,
  634. "" AS industry_name,
  635. 0 AS industry_id,
  636. a.share_img,
  637. a.file_type as activity_file_type,
  638. a.activity_id
  639. FROM
  640. cygx_activity_voice AS a
  641. JOIN cygx_activity AS b ON a.activity_id = b.activity_id WHERE 1= 1 AND a.activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
  642. //活动视频2
  643. sql += ` UNION ALL `
  644. sql += `
  645. SELECT
  646. a.video_id AS id,
  647. a.activity_id AS source_id,
  648. a.video_name AS title,
  649. a.video_url AS resource_url,
  650. 2 AS type,
  651. b.activity_time as publish_time,
  652. b.chart_permission_id,
  653. b.chart_permission_name,
  654. a.video_duration AS play_seconds,
  655. a.background_img,
  656. "" AS industry_name,
  657. 0 AS industry_id,
  658. a.share_img,
  659. a.file_type as activity_file_type,
  660. a.activity_id
  661. FROM
  662. cygx_activity_video as a
  663. INNER JOIN cygx_activity as b on a.activity_id = b.activity_id WHERE 1= 1 AND a.activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
  664. sql += ` ORDER BY publish_time DESC`
  665. _, err = o.Raw(sql, activityIds, activityIds).QueryRows(&list)
  666. return
  667. }