micro_roadshow.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. //AuthOk bool `description:"是否有权限"`
  24. }
  25. // GetMicroRoadShowAudioPageList 获取微路演音频列表-分页
  26. func GetMicroRoadShowAudioPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  27. o := orm.NewOrm()
  28. sql := `SELECT
  29. a.activity_voice_id AS id,
  30. a.voice_name AS title,
  31. a.voice_url AS resource_url,
  32. 1 AS type,
  33. b.activity_time AS publish_time,
  34. b.chart_permission_id,
  35. b.chart_permission_name,
  36. a.voice_play_seconds AS play_seconds
  37. FROM
  38. cygx_activity_voice AS a
  39. JOIN cygx_activity AS b ON a.activity_id = b.activity_id `
  40. if condition != `` {
  41. sql += condition
  42. }
  43. sql += ` ORDER BY publish_time DESC`
  44. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  45. err = o.Raw(totalSql, pars).QueryRow(&total)
  46. if err != nil {
  47. return
  48. }
  49. sql += ` LIMIT ?,?`
  50. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  51. return
  52. }
  53. // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
  54. func GetMicroRoadShowVideoPageList(startSize, pageSize int, condition string, pars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
  55. o := orm.NewOrm()
  56. sql := `SELECT
  57. video_id AS id,
  58. video_name AS title,
  59. video_url AS resource_url,
  60. 2 AS type,
  61. publish_date AS publish_time,
  62. chart_permission_id,
  63. chart_permission_name,
  64. video_duration AS play_seconds
  65. FROM
  66. cygx_micro_roadshow_video
  67. WHERE
  68. publish_status = 1 `
  69. if condition != `` {
  70. sql += condition
  71. }
  72. sql += ` ORDER BY publish_time DESC`
  73. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  74. err = o.Raw(totalSql, pars).QueryRow(&total)
  75. if err != nil {
  76. return
  77. }
  78. sql += ` LIMIT ?,?`
  79. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  80. return
  81. }
  82. type AddVideoHistoryReq struct {
  83. VideoId int `description:"视频ID"`
  84. PlaySeconds string `description:"播放时长"`
  85. }
  86. type CygxMicroRoadshowVideoHistory struct {
  87. Id int `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
  88. VideoId int `description:"微路演视频id"`
  89. UserId int `description:"用户id"`
  90. Mobile string `description:"手机号"`
  91. Email string `description:"邮箱"`
  92. CompanyId int `description:"公司Id"`
  93. CompanyName string `description:"公司名称"`
  94. RealName string `description:"用户实际名称"`
  95. SellerName string `description:"所属销售"`
  96. PlaySeconds string `description:"播放时间 单位s"`
  97. CreateTime time.Time `description:"视频创建时间"`
  98. ModifyTime time.Time `description:"视频修改时间"`
  99. }
  100. func GetLastCygxMicroRoadshowVideoHistory(videoId int) (item *CygxMicroRoadshowVideoHistory, err error) {
  101. o := orm.NewOrm()
  102. sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? ORDER BY create_time DESC limit 1 `
  103. err = o.Raw(sql, videoId).QueryRow(&item)
  104. return
  105. }
  106. func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
  107. o := orm.NewOrm()
  108. _, err = o.Insert(item)
  109. return
  110. }