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.
 
 
 

107 lines
2.7 KiB

package video
import (
"context"
"github.com/gogf/gf/v2/text/gstr"
v1 "xgit.pub/module/cms/app/api/video/v1"
"xgit.pub/module/cms/app/dao"
"xgit.pub/module/cms/app/model"
)
type sVideo struct {
}
func (s *sVideo) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
res = &v1.GetListRes{}
tx := dao.Video.Ctx(ctx)
//var ms []*entity.Video
var ms []*model.Video
if req.Title != "" { //标题
tx = tx.WhereLike(dao.Video.Columns().Title, "%"+req.Title+"%")
}
//if req.TitleSub != "" {
// tx = tx.WhereLike(dao.Video.Columns().TitleSub, "%"+req.TitleSub+"%")
//}
if len(req.CategoryIdList) > 0 { //分类
tx = tx.WhereIn(dao.Video.Columns().CategoryId, req.CategoryIdList)
}
if req.Lock != "" { //锁定
tx = tx.Where(dao.Video.Columns().Lock, req.Lock)
}
if req.IsEnd != "" { //完结
tx = tx.Where(dao.Video.Columns().IsEnd, req.IsEnd)
}
if req.Copyright != "" { //版权
tx = tx.Where(dao.Video.Columns().Copyright, req.Copyright)
}
if req.Year > 0 { //年份
tx = tx.Where(dao.Video.Columns().Year, req.Year)
}
if req.Actor != "" { //演员
tx = tx.WhereLike(dao.Video.Columns().Actor, "%"+req.Actor+"%")
}
if req.Director != "" { //导演
tx = tx.WhereLike(dao.Video.Columns().Director, "%"+req.Director+"%")
}
if req.Writer != "" { //编剧
tx = tx.WhereLike(dao.Video.Columns().Writer, "%"+req.Writer+"%")
}
if err = tx.Page(req.Page, req.PageSize).Scan(&ms); err != nil {
return
}
if res.Total, err = tx.Count(); err != nil {
return
}
for idx, item := range ms {
if len(item.Actor) > 0 {
ms[idx].ActorList = gstr.Split(item.Actor, ",")
} else {
ms[idx].ActorList = []string{}
}
if len(item.Director) > 0 {
ms[idx].DirectorList = gstr.Split(item.Director, ",")
} else {
ms[idx].DirectorList = []string{}
}
if len(item.Writer) > 0 {
ms[idx].WriterList = gstr.Split(item.Writer, ",")
} else {
ms[idx].WriterList = []string{}
}
}
//res.Total, _ = tx.Count()
//err = tx.GetList(req.GetList, req.PageSize).Scan(&ms)
res.Page = req.Page
res.PageSize = req.PageSize
res.Rows = ms
return
}
// Create 创建
func (s *sVideo) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
return
}
// Update 更新
func (s *sVideo) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
return
}
// Delete 删除
func (s *sVideo) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
return
}
// BatchDelete 批量删除
func (s *sVideo) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) {
return
}
// Get 获取
func (s *sVideo) Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) {
return
}