activity_video.go 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. type CygxActivityVideo struct {
  8. VideoId int `orm:"column(video_id);pk"description:"视频id"`
  9. VideoName string `description:"视频名称"`
  10. ActivityId int ` description:"活动ID"`
  11. ModifyDate string `description:"更新时间"`
  12. VideoDuration string `description:"视频时长"`
  13. VideoCounts int `description:"播放量"`
  14. VideoUrl string `description:"视频地址"`
  15. BackgroundImg string `description:"封面图片"`
  16. ShareImg string `description:"分享图片"`
  17. IsByHand int `description:"是否手动修改过"`
  18. FileType int `description:"文件类型,1:路演回放,2:调研反馈"`
  19. CreateTime string `description:"创建时间"`
  20. }
  21. type CygxActivityVideoReq struct {
  22. VideoName string `description:"视频名称"`
  23. VideoDuration string `description:"视频时长"`
  24. VideoUrl string `description:"视频地址"`
  25. BackgroundImg string `description:"封面图片"`
  26. ShareImg string `description:"分享图片"`
  27. }
  28. // 活动详情
  29. type CygxActivityVideoListResp struct {
  30. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  31. ActivityTypeId int `description:"活动类型id"`
  32. ActivityName string `description:"活动名称"`
  33. ActivityTimeText string `description:"活动时间"`
  34. ActivityTypeName string `description:"活动类型名称"`
  35. ChartPermissionId int `description:"行业id"`
  36. ChartPermissionName string `description:"行业名称"`
  37. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  38. Label string `description:"标签"`
  39. TemporaryLabel string `description:"临时标签"`
  40. VideoId int `orm:"column(video_id);pk"description:"视频id"`
  41. VideoName string `description:"视频名称"`
  42. VideoCounts int `description:"播放量"`
  43. VideoDuration string `description:"视频时长"`
  44. CommentNum int `description:"留言总数"`
  45. VideoUrl string `description:"视频地址"`
  46. FileName string `description:"文件类型名称"`
  47. }
  48. type CygxActivityVideoListRep struct {
  49. Paging *paging.PagingItem `description:"分页数据"`
  50. List []*CygxActivityVideoListResp
  51. }
  52. // 添加
  53. func AddCygxActivityVideo(item *CygxActivityVideo) (newId int64, err error) {
  54. o := orm.NewOrmUsingDB("hz_cygx")
  55. newId, err = o.Insert(item)
  56. return
  57. }
  58. // 修改
  59. func UpdateCygxActivityVideo(item *CygxActivityVideo) (err error) {
  60. to := orm.NewOrmUsingDB("hz_cygx")
  61. updateParams := make(map[string]interface{})
  62. updateParams["VideoName"] = item.VideoName
  63. updateParams["VideoDuration"] = item.VideoDuration
  64. updateParams["VideoUrl"] = item.VideoUrl
  65. updateParams["BackgroundImg"] = item.BackgroundImg
  66. updateParams["ShareImg"] = item.ShareImg
  67. updateParams["FileType"] = item.FileType
  68. updateParams["ModifyDate"] = time.Now()
  69. ptrStructOrTableName := "cygx_activity_video"
  70. whereParam := map[string]interface{}{"activity_id": item.ActivityId}
  71. qs := to.QueryTable(ptrStructOrTableName)
  72. for expr, exprV := range whereParam {
  73. qs = qs.Filter(expr, exprV)
  74. }
  75. _, err = qs.Update(updateParams)
  76. return
  77. }
  78. // 获取数量
  79. func GetActivityVideoCount(condition string, pars []interface{}) (count int, err error) {
  80. sqlCount := ` SELECT
  81. COUNT( 1 ) AS count
  82. FROM
  83. cygx_activity AS art
  84. INNER JOIN cygx_activity_video AS v ON v.activity_id = art.activity_id
  85. WHERE
  86. 1 = 1 `
  87. if condition != "" {
  88. sqlCount += condition
  89. }
  90. o := orm.NewOrmUsingDB("hz_cygx")
  91. err = o.Raw(sqlCount, pars).QueryRow(&count)
  92. return
  93. }
  94. // 获取数量
  95. func GetActivityVideoCountByActivityId(activityId int) (count int, err error) {
  96. o := orm.NewOrmUsingDB("hz_cygx")
  97. sqlCount := ` SELECT
  98. COUNT( 1 ) AS count
  99. FROM
  100. JOIN cygx_activity_video
  101. WHERE activity_id = ? `
  102. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  103. return
  104. }
  105. // 列表
  106. func GetActivityVideoListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
  107. o := orm.NewOrmUsingDB("hz_cygx")
  108. sql := `SELECT art.*,v.video_id,v.video_name,v.video_counts,video_duration,
  109. (SELECT COUNT(1) FROM cygx_article_comment AS h WHERE h.activity_id=art.activity_id AND h.industry_id = 0 AND h.activity_voice_id = 0) AS comment_num
  110. FROM cygx_activity as art INNER JOIN cygx_activity_video AS v ON v.activity_id = art.activity_id WHERE 1= 1 `
  111. if condition != "" {
  112. sql += condition
  113. }
  114. sql += ` LIMIT ?,?`
  115. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  116. return
  117. }
  118. // 历史记录
  119. func GetActivityVideoHistoryById(condition string, pars []interface{}) (item []*CygxMicroRoadshowVoiceHistory, err error) {
  120. o := orm.NewOrmUsingDB("hz_cygx")
  121. sql := ` SELECT
  122. h.*
  123. FROM
  124. cygx_activity_video_history AS h
  125. INNER JOIN cygx_activity_video AS v
  126. WHERE
  127. 1 = 1
  128. AND v.video_id = h.video_id `
  129. if condition != "" {
  130. sql += condition
  131. }
  132. sql += ` ORDER BY h.create_time DESC `
  133. _, err = o.Raw(sql, pars).QueryRows(&item)
  134. return
  135. }
  136. // 详情
  137. func GetCygxActivityVideoReqDetail(activityId int) (item *CygxActivityVideo, err error) {
  138. o := orm.NewOrmUsingDB("hz_cygx")
  139. sql := `SELECT * FROM cygx_activity_video WHERE activity_id= ? `
  140. err = o.Raw(sql, activityId).QueryRow(&item)
  141. return
  142. }
  143. // 列表
  144. func GetCygxActivityVideoReqDetailByVideoId(videoId int) (item *CygxActivityVideo, err error) {
  145. o := orm.NewOrmUsingDB("hz_cygx")
  146. sql := `SELECT * FROM cygx_activity_video WHERE video_id= ? `
  147. err = o.Raw(sql, videoId).QueryRow(&item)
  148. return
  149. }
  150. // 列表
  151. func GetActivityVideoList(condition string, pars []interface{}) (items []*CygxActivityVideoListResp, err error) {
  152. o := orm.NewOrmUsingDB("hz_cygx")
  153. sql := ` SELECT * FROM cygx_activity_video WHERE 1=1 `
  154. if condition != "" {
  155. sql += condition
  156. }
  157. _, err = o.Raw(sql, pars).QueryRows(&items)
  158. return
  159. }
  160. // 列表
  161. func GetCygxActivityVideoList(condition string, pars []interface{}) (items []*CygxActivityVideo, err error) {
  162. o := orm.NewOrmUsingDB("hz_cygx")
  163. sql := ` SELECT * FROM cygx_activity_video WHERE 1=1 `
  164. if condition != "" {
  165. sql += condition
  166. }
  167. _, err = o.Raw(sql, pars).QueryRows(&items)
  168. return
  169. }
  170. // MicroRoadShowDefaultImgList 微路演行业默认背景图列表
  171. type MicroRoadShowDefaultImgList struct {
  172. Audio []*MicroRoadShowDefaultImg `description:"音频"`
  173. Video []*MicroRoadShowDefaultImg `description:"视频"`
  174. }
  175. // MicroRoadShowDefaultImg 微路演行业默认背景图
  176. type MicroRoadShowDefaultImg struct {
  177. ChartPermissionId int `description:"行业ID"`
  178. ChartPermissionName string `description:"行业名称"`
  179. ImgUrl string `description:"背景图"`
  180. ShareImg string `description:"分享图"`
  181. }
  182. // MicroRoadShowDefaultImgList 微路演行业默认背景图列表
  183. type ActivityVideoDefaultImgList struct {
  184. Audio []*ActivityVideoDefaultImg `description:"音频"`
  185. Video []*ActivityVideoDefaultImg `description:"视频"`
  186. }
  187. type ActivityVideoDefaultImg struct {
  188. ChartPermissionId int `description:"行业ID"`
  189. List []*MicroRoadShowDefaultImg
  190. }
  191. type ActivityVideoDefaultImgListResp struct {
  192. List []*MicroRoadShowDefaultImg
  193. }
  194. type ActivityVideoDefaultImgResp struct {
  195. BackgroundImg string `description:"封面图片"`
  196. ShareImg string `description:"分享图"`
  197. }
  198. // 删除数据
  199. func DeleteCygxActivityVideo(activityId int) (err error) {
  200. o := orm.NewOrmUsingDB("hz_cygx")
  201. sql := ` DELETE FROM cygx_activity_video WHERE activity_id= ? `
  202. _, err = o.Raw(sql, activityId).Exec()
  203. return
  204. }
  205. func Updatevideo_url(video_url string, video_id int) (err error) {
  206. sql := `UPDATE cygx_activity_video SET video_url =? WHERE video_id=? `
  207. o := orm.NewOrmUsingDB("hz_cygx")
  208. _, err = o.Raw(sql, video_url, video_id).Exec()
  209. return
  210. }
  211. // 获取数量
  212. func GetActivityVoiceAndVideoList(condition, conditionVoice, conditionVideo, conditionOrder string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, total int, err error) {
  213. o := orm.NewOrmUsingDB("hz_cygx")
  214. sql := `
  215. SELECT
  216. art.activity_id,
  217. art.activity_time,
  218. art.activity_name,
  219. art.activity_type_name,
  220. art.chart_permission_name,
  221. art.activity_time_text,
  222. v.activity_voice_id as video_id,
  223. v.voice_name as video_name,
  224. v.voice_counts as video_counts,
  225. v.comment_num as comment_num,
  226. v.voice_play_seconds as video_duration,
  227. v.voice_url as video_url
  228. FROM
  229. cygx_activity AS art
  230. INNER JOIN cygx_activity_voice AS v ON v.activity_id = art.activity_id
  231. WHERE
  232. 1 = 1 ` + condition + conditionVoice
  233. sql += ` UNION ALL`
  234. sql += ` SELECT
  235. art.activity_id,
  236. art.activity_time,
  237. art.activity_name,
  238. art.activity_type_name,
  239. art.chart_permission_name,
  240. art.activity_time_text,
  241. v.video_id,
  242. v.video_name,
  243. v.video_counts,
  244. v.comment_num as comment_num,
  245. v.video_duration,
  246. v.video_url
  247. FROM
  248. cygx_activity AS art
  249. INNER JOIN cygx_activity_video AS v ON v.activity_id = art.activity_id
  250. WHERE
  251. 1 = 1 ` + condition + conditionVideo + conditionOrder
  252. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  253. err = o.Raw(totalSql, pars, pars).QueryRow(&total)
  254. if err != nil {
  255. return
  256. }
  257. sql += ` LIMIT ?,?`
  258. _, err = o.Raw(sql, pars, pars, startSize, pageSize).QueryRows(&items)
  259. return
  260. }