micro_roadshow.go 16 KB

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