activity_video.go 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. )
  6. type CygxActivityVideo struct {
  7. VideoId int `orm:"column(video_id);pk"description:"视频id"`
  8. VideoName string `description:"视频名称"`
  9. ActivityId int ` description:"活动ID"`
  10. ModifyDate string `description:"更新时间"`
  11. VideoDuration string `description:"视频时长"`
  12. VideoCounts int `description:"播放量"`
  13. VideoUrl string `description:"视频地址"`
  14. CreateTime string `description:"创建时间"`
  15. }
  16. type CygxActivityVideoResp struct {
  17. VideoId int `orm:"column(video_id);pk"description:"视频id"`
  18. ChartPermissionId int `description:"权限id"`
  19. VideoName string `description:"视频名称"`
  20. ActivityId int ` description:"活动ID"`
  21. ModifyDate string `description:"更新时间"`
  22. VideoDuration string `description:"视频时长"`
  23. VideoCounts int `description:"播放量"`
  24. VideoUrl string `description:"视频地址"`
  25. CreateTime string `description:"创建时间"`
  26. }
  27. type CygxActivityVideoReq struct {
  28. VideoName string `description:"视频名称"`
  29. VideoDuration string `description:"视频时长"`
  30. VideoUrl string `description:"视频地址"`
  31. }
  32. // 活动详情
  33. type CygxActivityVideoListResp struct {
  34. ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
  35. Id int `orm:"column(video_id)";description:"视频id"`
  36. Title string `orm:"column(video_name)";description:"视频名称"`
  37. ResourceUrl string `orm:"column(video_url)";description:"视频地址"`
  38. VideoDuration string `description:"视频时长"`
  39. Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
  40. }
  41. type CygxActivityVideoListRep struct {
  42. Paging *paging.PagingItem `description:"分页数据"`
  43. List []*CygxActivityVideoListResp
  44. }
  45. // 列表
  46. func GetActivityVideoListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT art.*,v.video_id,v.video_name,v.video_url,video_duration FROM cygx_activity as art INNER JOIN cygx_activity_video AS v ON v.activity_id = art.activity_id WHERE 1= 1 `
  49. if condition != "" {
  50. sql += condition
  51. }
  52. sql += ` LIMIT ?,?`
  53. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  54. return
  55. }
  56. // 列表
  57. func GetActivityVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoResp, err error) {
  58. o := orm.NewOrm()
  59. sql := `SELECT
  60. v.*,art.chart_permission_id
  61. FROM
  62. cygx_activity_video AS v
  63. INNER JOIN cygx_activity as art ON art.activity_id = v.activity_id WHERE 1= 1 `
  64. if condition != "" {
  65. sql += condition
  66. }
  67. sql += ` LIMIT ?,?`
  68. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  69. return
  70. }
  71. func UpdateActivityVideoCounts(activityId int) (err error) {
  72. sql := `UPDATE cygx_activity_video SET video_counts = video_counts+1 WHERE activity_id = ? `
  73. o := orm.NewOrm()
  74. _, err = o.Raw(sql, activityId).Exec()
  75. return
  76. }
  77. // GetCygxActivityVideoByActivityId 获取活动视频
  78. func GetCygxActivityVideoByActivityId(activityId int) (item *CygxActivityVideo, err error) {
  79. sql := `SELECT * FROM cygx_activity_video WHERE activity_id = ? LIMIT 1 `
  80. err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
  81. return
  82. }
  83. type CygxActivityVideoDetailResp struct {
  84. ActivityId int ` description:"活动ID"`
  85. Id int `description:"视频ID"`
  86. Title string `description:"标题"`
  87. ResourceUrl string `description:"链接"`
  88. BackgroundImg string `description:"背景图"`
  89. PlaySeconds int `description:"音视频时长"`
  90. ChartPermissionId int `description:"行业ID"`
  91. ChartPermissionName string `description:"行业名称"`
  92. Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
  93. }
  94. // GetCygxActivityVideoById 获取活动视频
  95. func GetCygxActivityVideoById(videoId int) (item *CygxActivityVideoDetailResp, err error) {
  96. sql := `SELECT
  97. v.video_id AS id,
  98. v.video_name AS title,
  99. v.video_url AS resource_url,
  100. v.video_duration AS play_seconds,
  101. v.activity_id,
  102. a.chart_permission_id,
  103. a.chart_permission_name
  104. FROM
  105. cygx_activity_video AS v
  106. INNER JOIN cygx_activity AS a ON v.activity_id = a.activity_id
  107. WHERE
  108. video_id = ?
  109. LIMIT 1 `
  110. err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
  111. return
  112. }
  113. // GetCygxActivityVideoById 获取活动视频
  114. func GetCygxActivityVideoByActivityIdInfo(activityId int) (item *CygxActivityVideoDetailResp, err error) {
  115. sql := `SELECT
  116. v.video_id AS id,
  117. v.video_name AS title,
  118. v.video_url AS resource_url,
  119. v.video_duration AS play_seconds,
  120. v.activity_id,
  121. a.chart_permission_id,
  122. a.chart_permission_name
  123. FROM
  124. cygx_activity_video AS v
  125. INNER JOIN cygx_activity AS a ON v.activity_id = a.activity_id
  126. WHERE
  127. v.activity_id = ?
  128. LIMIT 1 `
  129. err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
  130. return
  131. }
  132. // GetMicroRoadshowVideoByVideoIdCount 根据视频ID查询产业视频是否存在
  133. func GetActivityVideoByVideoIdCount(videoId int) (count int, err error) {
  134. o := orm.NewOrm()
  135. sql := `SELECT COUNT(1) count
  136. FROM cygx_activity_video WHERE video_id = ? `
  137. err = o.Raw(sql, videoId).QueryRow(&count)
  138. return
  139. }
  140. // 获取数量
  141. func GetCygxActivityVideoCount(activityId int) (count int, err error) {
  142. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_video WHERE activity_id = ? `
  143. o := orm.NewOrm()
  144. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  145. return
  146. }
  147. type ActivityVideoDetailResp struct {
  148. VideoDetail *CygxActivityVideoDetailResp
  149. AuthInfo *UserPermissionAuthInfo
  150. }
  151. // 获取所有活动视频ID
  152. func GetActivityVideoActivityIds() (activityIds string, err error) {
  153. sql := `SELECT
  154. GROUP_CONCAT( DISTINCT a.activity_id SEPARATOR ',' ) AS activityids
  155. FROM
  156. cygx_activity_video AS a `
  157. o := orm.NewOrm()
  158. err = o.Raw(sql).QueryRow(&activityIds)
  159. return
  160. }
  161. func UpdateActivityVideoCommentNum(activityId int) (err error) {
  162. sql := `UPDATE cygx_activity_video SET comment_num = comment_num+1 WHERE activity_id = ? `
  163. o := orm.NewOrm()
  164. _, err = o.Raw(sql, activityId).Exec()
  165. return
  166. }