You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
2.6 KiB
86 lines
2.6 KiB
package short
|
|
|
|
import (
|
|
"github.com/golangkit/formatime"
|
|
"live/app/lib/db"
|
|
)
|
|
|
|
type Short struct {
|
|
db.BaseModel
|
|
Id uint `gorm:"column:id" json:"id"`
|
|
UserId uint `gorm:"column:user_id" json:"userId"`
|
|
GoodsId uint `gorm:"column:goods_id" json:"goodsId"`
|
|
TopicId uint `gorm:"column:topic_id" json:"topicId"`
|
|
Content string `gorm:"column:content" json:"content"`
|
|
FileId string `gorm:"column:file_id" json:"fileId"`
|
|
CreatedAt formatime.Second `gorm:"column:created_at" json:"createdAt"`
|
|
UpdatedAt formatime.Second `gorm:"column:updated_at" json:"updatedAt"`
|
|
MediaUrl string `gorm:"column:media_url" json:"mediaUrl"`
|
|
CoverUrl string `gorm:"column:cover_url" json:"coverUrl"`
|
|
IsDel int `gorm:"column:is_del" json:"isDel"`
|
|
Compliance int `gorm:"column:compliance" json:"compliance"`
|
|
Pass int `gorm:"column:pass" json:"pass"`
|
|
Emg string `gorm:"column:emg" json:"emg"`
|
|
}
|
|
|
|
// 插入
|
|
func (s *Short) Create(short *Short) uint {
|
|
s.GetDb().Create(short)
|
|
if short.Id > 0 {
|
|
return short.Id
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// @Title 根据ids和userId获取短视频信息
|
|
// @Param userId uint true "会员id"
|
|
// @Param ids []uint true ""
|
|
func (s *Short) GetByUserIdAndIds(userId uint, ids []uint) (result []Short) {
|
|
if userId <= 0 || len(ids) == 0 {
|
|
return
|
|
}
|
|
s.GetDb().Model(s).Find(&result, "id in (?) and user_id = ?", ids, userId)
|
|
return
|
|
}
|
|
|
|
// @Title 获取话题短视频列表
|
|
func (s *Short) GetList(start, limit int) (result []Short) {
|
|
s.GetDb().Model(s).Order("id desc").Offset(start).Limit(limit).
|
|
Find(&result, "is_del = 0 and pass=2")
|
|
return
|
|
}
|
|
|
|
// @Title 获取话题短视频列表数量
|
|
func (s *Short) GetListCount() (result int64) {
|
|
s.GetDb().Model(s).Where("is_del = 0").Count(&result)
|
|
return
|
|
}
|
|
|
|
// @Title 获取话题短视频列表
|
|
func (s *Short) GetListByTopicId(topicId uint, start, limit int) (result []Short) {
|
|
if topicId <= 0 {
|
|
return
|
|
}
|
|
s.GetDb().Model(s).Order("id desc").Offset(start).Limit(limit).
|
|
Find(&result, "topic_id = ? and is_del = 0", topicId)
|
|
return
|
|
}
|
|
|
|
// @Title 获取话题短视频列表数量
|
|
func (s *Short) GetListCountByTopicId(topicId uint) (result int64) {
|
|
if topicId <= 0 {
|
|
return
|
|
}
|
|
s.GetDb().Model(s).Where("topic_id = ? and is_del = 0", topicId).Count(&result)
|
|
return
|
|
}
|
|
|
|
// @Title 获取短视频详情
|
|
func (s *Short) GetInfoById(id uint) (result Short) {
|
|
if id <= 0 {
|
|
return
|
|
}
|
|
s.GetDb().Model(s).Where("id = ? and is_del = 0", id).First(&result)
|
|
return
|
|
}
|