1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // CommunityVideo 视频社区
- type CommunityVideo struct {
- CommunityVideoId int `orm:"column(community_video_id);pk" description:"问题ID"`
- Title string `description:"视频标题"`
- VarietyTagId int `description:"标签ID"`
- VarietyTagName string `description:"标签名称"`
- CoverImgUrl string `description:"封面图地址"`
- VideoUrl string `description:"视频地址"`
- VideoSeconds string `description:"视频时长,单位秒"`
- PublishState int `description:"发布状态:0-待发布 1-已发布"`
- SendThsState int `description:"客群消息推送状态:0-待推送 1-已推送"`
- IsDeleted int `description:"是否已删除 0-否 1-是"`
- PublishTime time.Time `description:"发布时间"`
- SendThsTime time.Time `description:"推送客群时间"`
- CreateTime time.Time `description:"提问时间"`
- ModifyTime time.Time `description:"修改时间"`
- DeleteTime time.Time `description:"删除时间"`
- }
- func (item *CommunityVideo) TableName() string {
- return "yb_community_video"
- }
- func (item *CommunityVideo) Add() (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- if err != nil {
- return
- }
- item.CommunityVideoId = int(lastId)
- return
- }
- func (item *CommunityVideo) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(item, cols...)
- return
- }
- // GetVideoById 主键获取视频
- func GetVideoById(videoId int) (item *CommunityVideo, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM yb_community_video WHERE community_video_id = ? AND is_deleted = 0 LIMIT 1`
- err = o.Raw(sql, videoId).QueryRow(&item)
- return
- }
- // GetCommunityVideoList 获取视频列表
- func GetCommunityVideoList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*CommunityVideo, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM yb_community_video WHERE is_deleted = 0 `
- sql += condition
- sql += ` ORDER BY create_time DESC`
- totalSQl := `SELECT COUNT(1) total FROM (` + sql + `) z`
- if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
- return
- }
- sql += ` LIMIT ?,?`
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
- return
- }
- // DeleteVideo 删除视频
- func DeleteVideo(videoId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE yb_community_video SET is_deleted = 1, delete_time = NOW() WHERE community_video_id = ? LIMIT 1`
- _, err = o.Raw(sql, videoId).Exec()
- return
- }
|