micro_roadshow.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "time"
  6. )
  7. // MicroRoadShowListResp 微路演列表响应体
  8. type MicroRoadShowListResp struct {
  9. Paging *paging.PagingItem
  10. List []*MicroRoadShowPageList
  11. }
  12. // MicroRoadShowPageList 微路演列表
  13. type MicroRoadShowPageList struct {
  14. Id int `description:"音视频ID"`
  15. Title string `description:"标题"`
  16. ResourceUrl string `description:"链接"`
  17. Type int `description:"类型: 1-音频; 2-视频"`
  18. PublishTime string `description:"发布时间"`
  19. BackgroundImg string `description:"背景图"`
  20. ChartPermissionId int `description:"行业ID"`
  21. ChartPermissionName string `description:"行业名称"`
  22. PlaySeconds string `description:"音视频时长"`
  23. ActivityId int `description:"活动ID"`
  24. AuthInfo *UserPermissionAuthInfo
  25. }
  26. // GetMicroRoadShowAudioPageList 获取微路演音频列表-分页
  27. func GetMicroRoadShowAudioPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  28. o := orm.NewOrm()
  29. sql := `SELECT
  30. a.activity_voice_id AS id,
  31. a.voice_name AS title,
  32. a.voice_url AS resource_url,
  33. 1 AS type,
  34. b.activity_time AS publish_time,
  35. b.chart_permission_id,
  36. b.chart_permission_name,
  37. a.voice_play_seconds AS play_seconds,
  38. a.img_url AS background_img,
  39. a.activity_id
  40. FROM
  41. cygx_activity_voice AS a
  42. JOIN cygx_activity AS b ON a.activity_id = b.activity_id `
  43. if condition != `` {
  44. sql += condition
  45. }
  46. sql += ` ORDER BY publish_time DESC`
  47. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  48. err = o.Raw(totalSql, pars).QueryRow(&total)
  49. if err != nil {
  50. return
  51. }
  52. sql += ` LIMIT ?,?`
  53. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  54. return
  55. }
  56. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  57. func GetMicroRoadShowVideoPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  58. o := orm.NewOrm()
  59. sql := `SELECT
  60. video_id AS id,
  61. video_name AS title,
  62. video_url AS resource_url,
  63. 2 AS type,
  64. publish_date AS publish_time,
  65. chart_permission_id,
  66. chart_permission_name,
  67. video_duration AS play_seconds,
  68. img_url AS background_img
  69. FROM
  70. cygx_micro_roadshow_video
  71. WHERE
  72. publish_status = 1 `
  73. if condition != `` {
  74. sql += condition
  75. }
  76. sql += ` ORDER BY publish_time DESC`
  77. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  78. err = o.Raw(totalSql, pars).QueryRow(&total)
  79. if err != nil {
  80. return
  81. }
  82. sql += ` LIMIT ?,?`
  83. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  84. return
  85. }
  86. type AddVideoHistoryReq struct {
  87. VideoId int `description:"视频ID"`
  88. PlaySeconds string `description:"播放时长"`
  89. }
  90. type CygxMicroRoadshowVideoHistory struct {
  91. Id int `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
  92. VideoId int `description:"微路演视频id"`
  93. UserId int `description:"用户id"`
  94. Mobile string `description:"手机号"`
  95. Email string `description:"邮箱"`
  96. CompanyId int `description:"公司Id"`
  97. CompanyName string `description:"公司名称"`
  98. RealName string `description:"用户实际名称"`
  99. SellerName string `description:"所属销售"`
  100. PlaySeconds string `description:"播放时间 单位s"`
  101. CreateTime time.Time `description:"视频创建时间"`
  102. ModifyTime time.Time `description:"视频修改时间"`
  103. }
  104. func GetLastCygxMicroRoadshowVideoHistory(videoId int) (item *CygxMicroRoadshowVideoHistory, err error) {
  105. o := orm.NewOrm()
  106. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? ORDER BY create_time DESC limit 1 `
  107. err = o.Raw(sql, videoId).QueryRow(&item)
  108. return
  109. }
  110. func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
  111. o := orm.NewOrm()
  112. _, err = o.Insert(item)
  113. return
  114. }