micro_roadshow.go 23 KB

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