micro_roadshow.go 19 KB

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