123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- type CygxActivityVideo struct {
- VideoId int `orm:"column(video_id);pk"description:"视频id"`
- VideoName string `description:"视频名称"`
- ActivityId int ` description:"活动ID"`
- ModifyDate string `description:"更新时间"`
- VideoDuration string `description:"视频时长"`
- VideoCounts int `description:"播放量"`
- VideoUrl string `description:"视频地址"`
- CreateTime string `description:"创建时间"`
- }
- type CygxActivityVideoResp struct {
- VideoId int `orm:"column(video_id);pk"description:"视频id"`
- ChartPermissionId int `description:"权限id"`
- VideoName string `description:"视频名称"`
- ActivityId int ` description:"活动ID"`
- ModifyDate string `description:"更新时间"`
- VideoDuration string `description:"视频时长"`
- VideoCounts int `description:"播放量"`
- VideoUrl string `description:"视频地址"`
- CreateTime string `description:"创建时间"`
- }
- type CygxActivityVideoReq struct {
- VideoName string `description:"视频名称"`
- VideoDuration string `description:"视频时长"`
- VideoUrl string `description:"视频地址"`
- }
- // 活动详情
- type CygxActivityVideoListResp struct {
- ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
- Id int `orm:"column(video_id)";description:"视频id"`
- Title string `orm:"column(video_name)";description:"视频名称"`
- ResourceUrl string `orm:"column(video_url)";description:"视频地址"`
- VideoDuration string `description:"视频时长"`
- Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
- }
- type CygxActivityVideoListRep struct {
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxActivityVideoListResp
- }
- // 列表
- func GetActivityVideoListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
- o := orm.NewOrm()
- 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 AND v.is_hide = 0 `
- if condition != "" {
- sql += condition
- }
- sql += ` LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // 列表
- func GetActivityVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT
- v.*,art.chart_permission_id
- FROM
- cygx_activity_video AS v
- INNER JOIN cygx_activity as art ON art.activity_id = v.activity_id WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- sql += ` LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- func UpdateActivityVideoCounts(activityId int) (err error) {
- sql := `UPDATE cygx_activity_video SET video_counts = video_counts+1 WHERE activity_id = ? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
- // GetCygxActivityVideoByActivityId 获取活动视频
- func GetCygxActivityVideoByActivityId(activityId int) (item *CygxActivityVideo, err error) {
- sql := `SELECT * FROM cygx_activity_video WHERE activity_id = ? LIMIT 1 `
- err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
- return
- }
- type CygxActivityVideoDetailResp struct {
- ActivityId int ` description:"活动ID"`
- Id int `description:"视频ID"`
- Title string `description:"标题"`
- ResourceUrl string `description:"链接"`
- BackgroundImg string `description:"背景图"`
- PlaySeconds int `description:"音视频时长"`
- ChartPermissionId int `description:"行业ID"`
- ChartPermissionName string `description:"行业名称"`
- Type int `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
- }
- // GetCygxActivityVideoById 获取活动视频
- func GetCygxActivityVideoById(videoId int) (item *CygxActivityVideoDetailResp, err error) {
- sql := `SELECT
- v.video_id AS id,
- v.video_name AS title,
- v.video_url AS resource_url,
- v.video_duration AS play_seconds,
- v.activity_id,
- a.chart_permission_id,
- a.chart_permission_name
- FROM
- cygx_activity_video AS v
- INNER JOIN cygx_activity AS a ON v.activity_id = a.activity_id
- WHERE
- video_id = ?
- LIMIT 1 `
- err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
- return
- }
- // GetCygxActivityVideoById 获取活动视频
- func GetCygxActivityVideoByActivityIdInfo(activityId int) (item *CygxActivityVideoDetailResp, err error) {
- sql := `SELECT
- v.video_id AS id,
- v.video_name AS title,
- v.video_url AS resource_url,
- v.video_duration AS play_seconds,
- v.activity_id,
- a.chart_permission_id,
- a.chart_permission_name
- FROM
- cygx_activity_video AS v
- INNER JOIN cygx_activity AS a ON v.activity_id = a.activity_id
- WHERE
- v.activity_id = ?
- LIMIT 1 `
- err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
- return
- }
- // GetMicroRoadshowVideoByVideoIdCount 根据视频ID查询产业视频是否存在
- func GetActivityVideoByVideoIdCount(videoId int) (count int, err error) {
- o := orm.NewOrm()
- sql := `SELECT COUNT(1) count
- FROM cygx_activity_video WHERE video_id = ? `
- err = o.Raw(sql, videoId).QueryRow(&count)
- return
- }
- type ActivityVideoDetailResp struct {
- VideoDetail *CygxActivityVideoDetailResp
- AuthInfo *UserPermissionAuthInfo
- }
- // 获取所有活动视频ID
- func GetActivityVideoActivityIds() (activityIds string, err error) {
- sql := `SELECT
- GROUP_CONCAT( DISTINCT a.activity_id SEPARATOR ',' ) AS activityids
- FROM
- cygx_activity_video AS a WHERE is_hide = 0 `
- o := orm.NewOrm()
- err = o.Raw(sql).QueryRow(&activityIds)
- return
- }
- func UpdateActivityVideoCommentNum(activityId int) (err error) {
- sql := `UPDATE cygx_activity_video SET comment_num = comment_num+1 WHERE activity_id = ? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, activityId).Exec()
- return
- }
|