micro_roadshow.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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 CygxMicroRoadshowVideo struct {
  8. VideoId int `orm:"column(video_id);pk"description:"微路演视频id"`
  9. VideoName string `description:"视频名称"`
  10. ChartPermissionId int `description:"行业Id"`
  11. ChartPermissionName string `description:"行业名称"`
  12. IndustryId int `description:"产业id"`
  13. IndustryName string `description:"产业名称"`
  14. PublishStatus int `description:"发布状态 1发布 0没有"`
  15. ModifyDate string `description:"更新时间"`
  16. PublishDate time.Time `description:"发布时间"`
  17. VideoDuration string `description:"视频时长"`
  18. VideoCounts int `description:"播放量"`
  19. VideoUrl string `description:"视频地址"`
  20. CreateTime string `description:"创建时间"`
  21. ImgUrl string `description:"视频封面图"`
  22. ShareImgUrl string `description:"视频分享图"`
  23. DetailImgUrl string `description:"产业详情页背景图"`
  24. CommentNum int `description:"留言总数"`
  25. IsSendWxMsg int `description:"是否推送过微信模板消息,1是,0:否"`
  26. }
  27. type CygxMicroRoadshowVideoResp struct {
  28. VideoId int `orm:"column(video_id);pk"description:"微路演视频id"`
  29. VideoName string `description:"视频名称"`
  30. ChartPermissionId int `description:"行业Id"`
  31. ChartPermissionName string `description:"行业名称"`
  32. IndustryId int `description:"产业id"`
  33. IndustryName string `description:"产业名称"`
  34. PublishStatus int `description:"发布状态 1发布 0没有"`
  35. ModifyDate string `description:"更新时间"`
  36. PublishDate string `description:"发布时间"`
  37. VideoDuration string `description:"视频时长"`
  38. VideoCounts int `description:"播放量"`
  39. VideoUrl string `description:"视频地址"`
  40. CreateTime string `description:"创建时间"`
  41. ImgUrl string `description:"视频封面图"`
  42. ShareImgUrl string `description:"视频分享图"`
  43. DetailImgUrl string `description:"产业详情页背景图"`
  44. CommentNum int `description:"留言总数"`
  45. }
  46. type MicroRoadshowVideoListResp struct {
  47. Paging *paging.PagingItem
  48. List []*CygxMicroRoadshowVideoResp
  49. }
  50. func GetMicroRoadshowVideoList(condition, sortStr string, pars []interface{}, startSize, pageSize int) (items []*CygxMicroRoadshowVideo, err error) {
  51. o := orm.NewOrmUsingDB("hz_cygx")
  52. sql := ` SELECT *,(SELECT COUNT(1) FROM cygx_article_comment AS h WHERE h.industry_id=v.industry_id AND h.activity_id = 0 ) AS comment_num FROM cygx_micro_roadshow_video as v WHERE 1=1 `
  53. if condition != "" {
  54. sql += condition
  55. }
  56. if sortStr == "" {
  57. sortStr = "ORDER BY publish_date DESC "
  58. }
  59. sql += sortStr + ` LIMIT ?,? `
  60. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  61. return
  62. }
  63. func GetCygxMicroRoadshowVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxMicroRoadshowVideo, err error) {
  64. o := orm.NewOrmUsingDB("hz_cygx")
  65. sql := ` SELECT * FROM cygx_micro_roadshow_video as v WHERE 1=1 `
  66. if condition != "" {
  67. sql += condition
  68. }
  69. sql += ` LIMIT ?,? `
  70. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  71. return
  72. }
  73. func GetMicroRoadshowVideoListCount(condition string, pars []interface{}) (count int, err error) {
  74. o := orm.NewOrmUsingDB("hz_cygx")
  75. sql := `SELECT COUNT(1) AS count FROM cygx_micro_roadshow_video WHERE 1=1 `
  76. if condition != "" {
  77. sql += condition
  78. }
  79. err = o.Raw(sql, pars).QueryRow(&count)
  80. return
  81. }
  82. // 视频保存请求参数
  83. type VideoAddReq struct {
  84. VideoId int `description:"视频Id"`
  85. VideoName string `description:"视频标题"`
  86. VideoUrl string `description:"视频地址"`
  87. VideoDuration string `description:"视频时长"`
  88. ChartPermissionId int `description:"行业id"`
  89. IndustryId int `description:"产业id"`
  90. ImgUrl string `description:"视频封面图"`
  91. ShareImgUrl string `description:"视频分享图"`
  92. DetailImgUrl string `description:"产业详情页背景图"`
  93. PublishDate string `description:"发布时间"`
  94. PublishOrSave int `description:"保存或发布 1发布 0保存"`
  95. }
  96. func GetMicroRoadshowVideoByTitle(title string) (count int, err error) {
  97. o := orm.NewOrmUsingDB("hz_cygx")
  98. sql := ` SELECT COUNT(1) AS count FROM cygx_micro_roadshow_video WHERE video_name =? `
  99. err = o.Raw(sql, title).QueryRow(&count)
  100. return
  101. }
  102. // 新增视频
  103. func AddMicroRoadshowVideo(item *CygxMicroRoadshowVideo) (newId int64, err error) {
  104. o := orm.NewOrmUsingDB("hz_cygx")
  105. newId, err = o.Insert(item)
  106. return
  107. }
  108. // 视频编辑请求参数
  109. type VideoEditReq struct {
  110. VideoId int `description:"视频id"`
  111. VideoName string `description:"视频标题"`
  112. VideoUrl string `description:"视频地址"`
  113. VideoDuration string `description:"视频时长"`
  114. ChartPermissionId int `description:"行业Id"`
  115. ChartPermissionName string `description:"行业名称"`
  116. IndustryId int `description:"产业id"`
  117. IndustryName string `description:"产业名称"`
  118. PublishDate string `description:"发布时间"`
  119. }
  120. // 新增视频
  121. func EditVideo(item *CygxMicroRoadshowVideo) (err error) {
  122. o := orm.NewOrmUsingDB("hz_cygx")
  123. sql := " UPDATE cygx_micro_roadshow_video SET " +
  124. " video_url = ?, video_name = ?,chart_permission_id=?, chart_permission_name=?, industry_id =?, industry_name =?, " +
  125. " modify_date=?, publish_date=?, video_duration=?, img_url=?, share_img_url=?, detail_img_url=?, publish_status=? WHERE video_id = ? "
  126. _, err = o.Raw(sql, item.VideoUrl, item.VideoName, item.ChartPermissionId, item.ChartPermissionName,
  127. item.IndustryId, item.IndustryName, item.ModifyDate, item.PublishDate, item.VideoDuration, item.ImgUrl, item.ShareImgUrl, item.DetailImgUrl, item.PublishStatus, item.VideoId).Exec()
  128. return
  129. }
  130. // 修改
  131. func UpdateCygxMicroRoadshowVideo(item *CygxMicroRoadshowVideo) (err error) {
  132. to := orm.NewOrmUsingDB("hz_cygx")
  133. updateParams := make(map[string]interface{})
  134. updateParams["ShareImgUrl"] = item.ShareImgUrl
  135. ptrStructOrTableName := "cygx_micro_roadshow_video"
  136. whereParam := map[string]interface{}{"video_id": item.VideoId}
  137. qs := to.QueryTable(ptrStructOrTableName)
  138. for expr, exprV := range whereParam {
  139. qs = qs.Filter(expr, exprV)
  140. }
  141. _, err = qs.Update(updateParams)
  142. return
  143. }
  144. func PublishVideoCancel(videoId, publishOrCancle int) (err error) {
  145. if publishOrCancle == 0 {
  146. publishOrCancle = 3 // 取消发布状态
  147. }
  148. o := orm.NewOrmUsingDB("hz_cygx")
  149. sql := `UPDATE cygx_micro_roadshow_video SET publish_status=?,modify_date=NOW() WHERE video_id =?`
  150. _, err = o.Raw(sql, publishOrCancle, videoId).Exec()
  151. return
  152. }
  153. type CygxMicroRoadshowVideoHistory struct {
  154. Id int `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
  155. VideoId int `description:"微路演视频id"`
  156. UserId int `description:"用户id"`
  157. Mobile string `description:"手机号"`
  158. Email string `description:"邮箱"`
  159. CompanyId int `description:"公司Id"`
  160. CompanyName string `description:"公司名称"`
  161. RealName string `description:"用户实际名称"`
  162. SellerName string `description:"所属销售"`
  163. PlaySeconds string `description:"播放时间 单位s"`
  164. CreateTime string `description:"视频创建时间"`
  165. ModifyTime time.Time `description:"视频修改时间"`
  166. RegisterPlatform string `description:"来源 1小程序,2:网页"`
  167. }
  168. func GetMicroRoadshowVideoHistoryByIdPage(condition string, pars []interface{}, startSize, pageSize int) (item []*CygxMicroRoadshowVideoHistory, err error) {
  169. o := orm.NewOrmUsingDB("hz_cygx")
  170. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE 1=1 `
  171. if condition != "" {
  172. sql += condition
  173. }
  174. sql += ` ORDER BY create_time DESC LIMIT ?,? `
  175. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
  176. return
  177. }
  178. func GetMicroRoadshowVideoHistoryById(condition string, pars []interface{}) (item []*CygxMicroRoadshowVideoHistory, err error) {
  179. o := orm.NewOrmUsingDB("hz_cygx")
  180. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE 1=1 `
  181. if condition != "" {
  182. sql += condition
  183. }
  184. sql += ` ORDER BY create_time DESC `
  185. _, err = o.Raw(sql, pars).QueryRows(&item)
  186. return
  187. }
  188. //type CygxMicroRoadshowVoice struct {
  189. // ActivityVoiceId int `orm:"column(activity_voice_id);pk"description:"微路演视频id"`
  190. // ActivityId string `description:"活动Id"`
  191. // VoiceName string `description:"音频名称"`
  192. // ChartPermissionId int `description:"行业Id"`
  193. // ChartPermissionName string `description:"行业名称"`
  194. // IndustryId int `description:"产业id"`
  195. // IndustryName string `description:"产业名称"`
  196. // ModifyDate string `description:"更新时间"`
  197. // PublishDate string `description:"发布时间"`
  198. // VoicePlaySeconds string `description:"音频时长"`
  199. // VoiceCounts int `description:"播放量"`
  200. // VoiceUrl string `description:"音频地址"`
  201. // CreateTime string `description:"创建时间"`
  202. //}
  203. type CygxMicroRoadshowVoice struct {
  204. ActivityVoiceId int `description:"微路演音频id"`
  205. ActivityId string `description:"活动Id"`
  206. VoiceName string `description:"音频名称"`
  207. ChartPermissionId int `description:"行业Id"`
  208. ChartPermissionName string `description:"行业名称"`
  209. IndustryId int `description:"产业id"`
  210. IndustryName string `description:"产业名称"`
  211. ModifyTime string `description:"更新时间"`
  212. PublishDate string `description:"发布时间"`
  213. VoicePlaySeconds string `description:"音频时长"`
  214. VoiceCounts int `description:"播放量"`
  215. VoiceUrl string `description:"音频地址"`
  216. CreateTime string `description:"创建时间"`
  217. Label string `description:"活动标签"`
  218. ActivityTypeId string `description:"活动类型Id"`
  219. ActivityTypeName string `description:"活动类型名称"`
  220. ActivityTime time.Time `description:"活动类型时间"`
  221. ActivityTimeText string `description:"活动类型时间文字"`
  222. CommentNum int `description:"留言总数"`
  223. }
  224. type CygxMicroRoadshowVoiceRsep struct {
  225. ActivityVoiceId int `description:"微路演音频id"`
  226. ActivityId string `description:"活动Id"`
  227. VoiceName string `description:"音频名称"`
  228. ChartPermissionId int `description:"行业Id"`
  229. ChartPermissionName string `description:"行业名称"`
  230. IndustryId int `description:"产业id"`
  231. IndustryName string `description:"产业名称"`
  232. ModifyTime string `description:"更新时间"`
  233. PublishDate string `description:"发布时间"`
  234. VoicePlaySeconds string `description:"音频时长"`
  235. VoiceCounts int `description:"播放量"`
  236. VoiceUrl string `description:"音频地址"`
  237. CreateTime string `description:"创建时间"`
  238. Label string `description:"活动标签"`
  239. ActivityTypeId string `description:"活动类型Id"`
  240. ActivityTypeName string `description:"活动类型名称"`
  241. ActivityTime string `description:"活动类型时间"`
  242. ActivityTimeText string `description:"活动类型时间文字"`
  243. CommentNum int `description:"留言总数"`
  244. }
  245. type MicroRoadshowVoiceListResp struct {
  246. Paging *paging.PagingItem
  247. List []*CygxMicroRoadshowVoiceRsep
  248. }
  249. func GetMicroRoadshowVoiceList(condition, sortStr string, pars []interface{}, startSize, pageSize int) (items []*CygxMicroRoadshowVoice, err error) {
  250. o := orm.NewOrmUsingDB("hz_cygx")
  251. sql := ` SELECT
  252. v.*,
  253. a.label,
  254. a.activity_type_id,
  255. a.activity_type_name,
  256. a.activity_time,
  257. a.activity_time_text,
  258. (SELECT COUNT(1) FROM cygx_article_comment AS h WHERE h.activity_id=a.activity_id AND h.industry_id = 0 AND h.video_id = 0) AS comment_num,
  259. a.chart_permission_name
  260. FROM
  261. cygx_activity_voice AS v
  262. INNER JOIN cygx_activity AS a
  263. WHERE
  264. v.activity_id = a.activity_id `
  265. if condition != "" {
  266. sql += condition
  267. }
  268. if sortStr == "" {
  269. sortStr = "ORDER BY a.activity_time DESC "
  270. }
  271. sql += sortStr + ` LIMIT ?,? `
  272. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  273. return
  274. }
  275. func GetMicroRoadshowVoiceListCount(condition string, pars []interface{}) (count int, err error) {
  276. o := orm.NewOrmUsingDB("hz_cygx")
  277. sql := `SELECT
  278. COUNT(1) AS count
  279. FROM
  280. cygx_activity_voice AS v
  281. INNER JOIN cygx_activity AS a
  282. WHERE
  283. v.activity_id = a.activity_id `
  284. if condition != "" {
  285. sql += condition
  286. }
  287. err = o.Raw(sql, pars).QueryRow(&count)
  288. return
  289. }
  290. type PermissionNameAndIndustryName struct {
  291. PermissionName string
  292. PermissionId int
  293. IndustryName string
  294. }
  295. func GetPermissionNameAndIndustryNameByIndustryId(industryId int) (item *PermissionNameAndIndustryName, err error) {
  296. o := orm.NewOrmUsingDB("hz_cygx")
  297. sql := `SELECT
  298. cm.industry_name as industry_name,
  299. cm.chart_permission_id AS permission_id
  300. FROM
  301. cygx_industrial_management AS cm
  302. WHERE
  303. 1=1
  304. AND cm.industrial_management_id = ? `
  305. err = o.Raw(sql, industryId).QueryRow(&item)
  306. return
  307. }
  308. type MicroRoadshowVideoHistoryListResp struct {
  309. Paging *paging.PagingItem
  310. List []*CygxMicroRoadshowVideoHistory
  311. }
  312. type CygxMicroRoadshowVoiceHistory struct {
  313. Id int `orm:"column(id);pk"description:"音频id"`
  314. VideoId int `description:"微路演音频id"`
  315. ActivityId int `description:"活动id"`
  316. UserId int `description:"用户id"`
  317. Mobile string `description:"手机号"`
  318. Email string `description:"邮箱"`
  319. CompanyId int `description:"公司Id"`
  320. CompanyName string `description:"公司名称"`
  321. RealName string `description:"用户实际名称"`
  322. SellerName string `description:"所属销售"`
  323. PlaySeconds string `description:"播放时间 单位s"`
  324. CreateTime string `description:"视频创建时间"`
  325. ModifyTime time.Time `description:"视频修改时间"`
  326. RegisterPlatform string `description:"来源 1小程序,2:网页"`
  327. }
  328. func GetMicroRoadshowVoiceHistoryById(condition string, pars []interface{}) (item []*CygxMicroRoadshowVoiceHistory, err error) {
  329. o := orm.NewOrmUsingDB("hz_cygx")
  330. sql := ` SELECT
  331. h.*
  332. FROM
  333. cygx_activity_voice_history AS h
  334. INNER JOIN cygx_activity_voice AS v
  335. WHERE
  336. 1 = 1
  337. AND v.activity_id = h.activity_id
  338. `
  339. if condition != "" {
  340. sql += condition
  341. }
  342. sql += ` ORDER BY create_time DESC `
  343. _, err = o.Raw(sql, pars).QueryRows(&item)
  344. return
  345. }
  346. func GetPermissionNameAndIndustryNameByChartPermissionId(ChartPermissionId int) (item *PermissionNameAndIndustryName, err error) {
  347. o := orm.NewOrm()
  348. sql := `SELECT
  349. chart_permission_id AS permission_id,
  350. chart_permission_name AS permission_name
  351. FROM
  352. chart_permission
  353. WHERE
  354. chart_permission_id = ? `
  355. err = o.Raw(sql, ChartPermissionId).QueryRow(&item)
  356. return
  357. }
  358. func GetMicroRoadshowVideoByIndustryId(industryId int) (item *CygxMicroRoadshowVideo, err error) {
  359. o := orm.NewOrmUsingDB("hz_cygx")
  360. sql := `SELECT * from cygx_micro_roadshow_video where industry_id = ? `
  361. err = o.Raw(sql, industryId).QueryRow(&item)
  362. return
  363. }
  364. func GetMicroRoadshowVideoByVideoId(videoId int) (item *CygxMicroRoadshowVideo, err error) {
  365. o := orm.NewOrmUsingDB("hz_cygx")
  366. sql := `SELECT * from cygx_micro_roadshow_video where video_id = ? `
  367. err = o.Raw(sql, videoId).QueryRow(&item)
  368. return
  369. }
  370. // 修改是否推送过模板消息的状态
  371. func UpdateIsSendWxMsg(videoId, isSendWxMsg int) (err error) {
  372. o := orm.NewOrmUsingDB("hz_cygx")
  373. sql := `UPDATE cygx_micro_roadshow_video SET is_send_wx_msg=? WHERE video_id =?`
  374. _, err = o.Raw(sql, isSendWxMsg, videoId).Exec()
  375. return
  376. }
  377. func GetMicroRoadshowVoiceById(activityId int) (item *CygxMicroRoadshowVoice, err error) {
  378. o := orm.NewOrmUsingDB("hz_cygx")
  379. sql := `SELECT
  380. v.*,
  381. a.label,
  382. a.activity_type_id,
  383. a.activity_type_name,
  384. a.activity_time,
  385. a.activity_time_text,
  386. a.chart_permission_name
  387. FROM
  388. cygx_activity_voice AS v
  389. INNER JOIN cygx_activity AS a
  390. WHERE
  391. v.activity_id = a.activity_id AND v.activity_id = ?`
  392. err = o.Raw(sql, activityId).QueryRow(&item)
  393. return
  394. }