1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type VideoTagsItems struct {
- TagsId int `description:"标签id"`
- TagsName string `description:"标签名称"`
- }
- type VideoTagsListResp struct {
- List []*VideoTagsItems
- }
- func GetVideoTagsList() (items []*VideoTagsItems, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT * FROM tags WHERE tags_type=1 ORDER BY sort ASC `
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- type VideoList struct {
- VideoId int `description:"视频id"`
- Title string `description:"视频标题"`
- VideoUrl string `description:"视频地址"`
- VideoCoverUrl string `description:"视频封面地址"`
- Status int `description:"视频状态:0:未发布,1:已发布"`
- PublishTime string `description:"视频发布时间"`
- PlaySeconds uint32 `description:"视频播放时长"`
- CreateTime time.Time `description:"视频创建时间"`
- ModifyTime time.Time `description:"视频修改时间"`
- TagsName string `description:"标签名称"`
- }
- func GetVideoIdByKeyWord(tagName string) (video_id string, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := ` SELECT GROUP_CONCAT(DISTINCT a.video_id) AS video_id FROM video_tags AS a
- INNER JOIN tags AS b ON a.tags_id=b.tags_id
- WHERE b.tags_name=? `
- err = o.Raw(sql, tagName).QueryRow(&video_id)
- return
- }
- func GetVideoListCount(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT COUNT(DISTINCT a.video_id) AS count
- FROM video AS a WHERE 1=1 `
- if condition != "" {
- sql += condition
- }
- err = o.Raw(sql, pars).QueryRow(&count)
- return
- }
- func GetVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*VideoList, err error) {
- o := orm.NewOrmUsingDB("rddp")
- sql := `SELECT a.*,GROUP_CONCAT(c.tags_name SEPARATOR '/') AS tags_name FROM video AS a
- INNER JOIN video_tags AS b ON a.video_id=b.video_id
- INNER JOIN tags AS c ON b.tags_id=c.tags_id
- WHERE 1=1 AND status=1 `
- if condition != "" {
- sql += condition
- }
- sql += ` GROUP BY a.video_id ORDER BY a.modify_time DESC LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- type VideoListResp struct {
- List []*VideoList
- Status int `description:"权限状态:0:有权限,1:无权限"`
- }
|