123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package english_video
- import (
- "hongze/hongze_yb_en_api/global"
- "hongze/hongze_yb_en_api/models/base"
- "time"
- )
- type EnglishVideo struct {
- Id uint `gorm:"primaryKey;column:id" json:"id"`
- ClassifyIdFirst int `gorm:"column:classify_id_first" json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `gorm:"column:classify_name_first" json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `gorm:"column:classify_id_second" json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `gorm:"column:classify_name_second" json:"classify_name_second"` //二级分类名称
- Title string `gorm:"column:title" json:"title"` //标题
- Abstract string `gorm:"column:abstract" json:"abstract"` //摘要
- Author string `gorm:"column:author" json:"author"` //作者
- State int8 `gorm:"column:state" json:"state"` //1:未发布,2:已发布
- PublishTime time.Time `gorm:"column:publish_time" json:"publish_time"` //发布时间
- Overview string `gorm:"column:overview" json:"overview"` //概述
- VideoUrl string `gorm:"column:video_url" json:"video_url"` //视频文件URL
- VideoCoverUrl string `gorm:"column:video_cover_url" json:"video_cover_url"` //视频文件封面地址
- VideoSeconds string `gorm:"column:video_seconds" json:"video_seconds"` //视频时长
- VideoCode string `gorm:"column:video_code" json:"video_code"` //唯一编码
- Pv int `gorm:"column:pv" json:"pv"`
- ShareUrl string `gorm:"column:share_url" json:"share_url"` //分享url
- PvEmail uint `gorm:"column:pv_email" json:"pv_email"` //分享邮箱的PV
- EmailState uint8 `gorm:"column:email_state" json:"email_state"` //是否已群发邮件:0-否; 1-是
- base.TimeBase
- }
- // TableName get sql table name.获取数据库表名
- func (r *EnglishVideo) TableName() string {
- return "english_video"
- }
- type VideoListReq struct {
- ClassifyIdFirst int `json:"classify_id_first" form:"classify_id_first"`
- ClassifyIdSecond int `json:"classify_id_second" form:"classify_id_second"`
- base.PageReq
- }
- type VideoListItem struct {
- Id uint `json:"id"`
- ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
- Title string `json:"title"` //标题
- Abstract string `json:"abstract"` //摘要
- Author string `json:"author"` //作者
- PublishTime string `json:"publish_time"` //发布时间
- VideoUrl string `json:"video_url"` //视频文件URL
- VideoCoverUrl string `json:"video_cover_url"` //视频文件封面地址
- VideoSeconds string `json:"video_seconds"` //视频时长
- VideoCode string `json:"video_code"` //唯一编码
- ShareUrl string `json:"share_url"` //分享url
- CreateTime string `json:"create_time"` //创建时间
- ModifyTime string `json:"modify_time"` //最后更新时间
- }
- type VideoSearchReq struct {
- KeyWord string `json:"key_word" form:"key_word"`
- base.PageReq
- }
- type VideoDetailReq struct {
- VideoCode string `json:"video_code" form:"video_code" binding:"required"` //唯一编码
- ShareEmail int `json:"share_email" form:"share_email"` //推送的邮箱ID
- }
- type VideoDetail struct {
- Id uint `json:"id"`
- ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
- Title string `json:"title"` //标题
- Abstract string `json:"abstract"` //摘要
- Author string `json:"author"` //作者
- PublishTime string `json:"publish_time"` //发布时间
- VideoUrl string `json:"video_url"` //视频文件URL
- VideoCoverUrl string `json:"video_cover_url"` //视频文件封面地址
- VideoSeconds string `json:"video_seconds"` //视频时长
- VideoCode string `json:"video_code"` //唯一编码
- CreateTime string `json:"create_time"` //创建时间
- ModifyTime string `json:"modify_time"` //最后更新时间
- Overview string `json:"overview"` //概述
- }
- type VideoDetailResp struct {
- Video *VideoDetail `json:"Video"`
- AuthOk bool `json:"auth_ok"`
- }
- type SearchEnglishVideoItem struct {
- Id uint `json:"id"`
- ClassifyIdFirst int `json:"classify_id_first"` //一级分类id
- ClassifyNameFirst string `json:"classify_name_first"` //一级分类名称
- ClassifyIdSecond int `json:"classify_id_second"` //二级分类id
- ClassifyNameSecond string `json:"classify_name_second"` //二级分类名称
- Title string `json:"title"` //标题
- Author string `json:"author"` //作者
- PublishTime string `json:"publish_time"` //发布时间
- VideoCode string `json:"video_code"` //唯一编码
- CreateTime string `json:"create_time"` //创建时间
- ContentSub string `json:"content_sub"` //内容前两个章节"`
- }
- func (r *EnglishVideo) SelectPage(page base.IPage, condition string, pars []interface{}) (count int64, results []*EnglishVideo, err error) {
- results = make([]*EnglishVideo, 0)
- query := global.DEFAULT_MYSQL.Model(r).
- Select("*").
- Where(condition, pars...)
- query.Count(&count)
- if len(page.GetOrderItemsString()) > 0 {
- query = query.Order(page.GetOrderItemsString())
- }
- err = query.Limit(int(page.GetPageSize())).Offset(int(page.Offset())).Find(&results).Error
- return
- }
- func (r *EnglishVideo) GetEnglishVideoByCode(videoCode string) (item *EnglishVideo, err error) {
- err = global.MYSQL["rddp"].Model(r).Where("video_code= ?", videoCode).First(&item).Error
- return
- }
- // 修改
- func (r *EnglishVideo) Update(updateCols []string) (err error) {
- err = global.DEFAULT_MYSQL.Model(r).Select(updateCols).Updates(r).Error
- return
- }
- func (r *EnglishVideo) UpdatePvEmailByVideoCode(videoCode string) (err error) {
- sql := `UPDATE english_video SET pv_email = pv_email+1 WHERE video_code = ? `
- err = global.DEFAULT_MYSQL.Exec(sql, videoCode).Error
- return
- }
- func (r *EnglishVideo) UpdatePvByVideoCode(videoCode string) (err error) {
- sql := `UPDATE english_video SET pv = pv+1 WHERE video_code = ? `
- err = global.DEFAULT_MYSQL.Exec(sql, videoCode).Error
- return
- }
- // GetVideosByIds 通过IDs获取集合
- func (r *EnglishVideo) GetVideosByIds(ids []uint) (list []*EnglishVideo, err error) {
- err = global.DEFAULT_MYSQL.Model(r).Where("id IN (?)", ids).Scan(&list).Error
- return
- }
|