chenyang
11 months ago
13 changed files with 481 additions and 0 deletions
-
151app/api/video/v1/video.go
-
20app/api/video/video.go
-
5app/controller/video/video.go
-
15app/controller/video/video_new.go
-
14app/controller/video/video_v1_batch_delete.go
-
14app/controller/video/video_v1_create.go
-
14app/controller/video/video_v1_delete.go
-
14app/controller/video/video_v1_get.go
-
14app/controller/video/video_v1_get_list.go
-
14app/controller/video/video_v1_update.go
-
107app/logic/video/video.go
-
56app/model/video.go
-
43app/service/video.go
@ -0,0 +1,151 @@ |
|||
package v1 |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"xgit.pub/st52/xcore/dto" |
|||
) |
|||
|
|||
// GetListReq 获取视频列表请求
|
|||
type GetListReq struct { |
|||
g.Meta `path:"/video/list" method:"post" summary:"获取视频列表" tags:"视频"` |
|||
Title string `json:"title" description:"标题"` |
|||
CategoryIdList []uint `json:"category_id_list" description:"分类 ID"` |
|||
Lock string `json:"lock" description:"锁定"` |
|||
IsEnd string `json:"is_end" description:"完结"` |
|||
Copyright string `json:"copyright" description:"版权"` |
|||
Year uint `json:"year" description:"年份"` |
|||
Actor string `json:"actor" description:"演员"` |
|||
Director string `json:"director" description:"导演"` |
|||
Writer string `json:"writer" description:"编剧"` |
|||
dto.PageReq |
|||
} |
|||
|
|||
// GetListRes 获取视频列表响应
|
|||
type GetListRes struct { |
|||
dto.PageRes |
|||
} |
|||
|
|||
// CreateReq 创建视频请求
|
|||
type CreateReq struct { |
|||
g.Meta `path:"/video/add" method:"post" summary:"创建视频" tags:"视频"` |
|||
Title string `json:"title" description:"标题"` |
|||
TitleSub string `json:"title_sub" description:"副标"` |
|||
Letter string `json:"letter" description:"首字母"` |
|||
Tag string `json:"tag" description:"TAG"` |
|||
Color string `json:"color" description:"颜色"` |
|||
Lock uint `json:"lock" description:"锁定"` |
|||
Copyright uint `json:"copyright" description:"版权"` |
|||
IsEnd uint `json:"is_end" description:"完结"` |
|||
Status uint `json:"status" description:"状态"` |
|||
CategoryId uint `json:"category_id" description:"分类"` |
|||
Pic string `json:"pic" description:"图片"` |
|||
PicThumb string `json:"pic_thumb" description:"缩略图"` |
|||
PicSlide string `json:"pic_slide" description:"轮播"` |
|||
PicScreenshot string `json:"pic_screenshot" description:"截图"` |
|||
Actor string `json:"actor" description:"演员"` |
|||
Director string `json:"director" description:"导演"` |
|||
Writer string `json:"writer" description:"编剧"` |
|||
Remarks string `json:"remarks" description:"备注"` |
|||
Pubdate string `json:"pubdate" description:"发布时间"` |
|||
Total int `json:"total" description:"总集数"` |
|||
Serial string `json:"serial" description:"连载数"` |
|||
Duration string `json:"duration" description:"视频时长"` |
|||
Tv string `json:"tv" description:"电视频道"` |
|||
Weekday string `json:"weekday" description:"节目周期"` |
|||
Class string `json:"class" description:"扩展分类"` |
|||
Area string `json:"area" description:"地区"` |
|||
Lang string `json:"lang" description:"语言"` |
|||
Jumpurl string `json:"jumpurl" description:"跳转URL"` |
|||
Version string `json:"version" description:"资源版本"` |
|||
Year int `json:"year" description:"年份"` |
|||
State string `json:"state" description:"资源类别"` |
|||
DoubanScore float64 `json:"douban_score" description:"豆瓣评分"` |
|||
DoubanId int `json:"douban_id" description:"豆瓣ID"` |
|||
Up int `json:"up" description:"顶"` |
|||
Down int `json:"down" description:"踩"` |
|||
Hits int `json:"hits" description:"人气"` |
|||
HitsMonth int `json:"hits_month" description:"月人气"` |
|||
HitsWeek int `json:"hits_week" description:"周人气"` |
|||
HitsDay int `json:"hits_day" description:"天人气"` |
|||
} |
|||
|
|||
// CreateRes 创建视频响应
|
|||
type CreateRes struct{} |
|||
|
|||
// UpdateReq 更新视频请求
|
|||
type UpdateReq struct { |
|||
g.Meta `path:"/video/update" method:"post" summary:"更新视频" tags:"视频"` |
|||
Id uint `json:"id" description:""` |
|||
Title string `json:"title" description:"标题"` |
|||
TitleSub string `json:"title_sub" description:"副标"` |
|||
Letter string `json:"letter" description:"首字母"` |
|||
Tag string `json:"tag" description:"TAG"` |
|||
Color string `json:"color" description:"颜色"` |
|||
Lock uint `json:"lock" description:"锁定"` |
|||
Copyright uint `json:"copyright" description:"版权"` |
|||
IsEnd uint `json:"is_end" description:"完结"` |
|||
Status uint `json:"status" description:"状态"` |
|||
CategoryId uint `json:"category_id" description:"分类"` |
|||
Pic string `json:"pic" description:"图片"` |
|||
PicId string `json:"pic_id" description:"图片编号"` |
|||
PicLocal string `json:"pic_local" description:""` |
|||
PicThumb string `json:"pic_thumb" description:"缩略图"` |
|||
PicSlide string `json:"pic_slide" description:"轮播"` |
|||
PicScreenshot string `json:"pic_screenshot" description:"截图"` |
|||
Actor string `json:"actor" description:"演员"` |
|||
Director string `json:"director" description:"导演"` |
|||
Writer string `json:"writer" description:"编剧"` |
|||
Remarks string `json:"remarks" description:"备注"` |
|||
Pubdate string `json:"pubdate" description:"发布时间"` |
|||
Total int `json:"total" description:"总集数"` |
|||
Serial string `json:"serial" description:"连载数"` |
|||
Duration string `json:"duration" description:"视频时长"` |
|||
Tv string `json:"tv" description:"电视频道"` |
|||
Weekday string `json:"weekday" description:"节目周期"` |
|||
Class string `json:"class" description:"扩展分类"` |
|||
Area string `json:"area" description:"地区"` |
|||
Lang string `json:"lang" description:"语言"` |
|||
Jumpurl string `json:"jumpurl" description:"跳转URL"` |
|||
Version string `json:"version" description:"资源版本"` |
|||
Year int `json:"year" description:"年份"` |
|||
State string `json:"state" description:"资源类别"` |
|||
DoubanScore float64 `json:"douban_score" description:"豆瓣评分"` |
|||
DoubanId int `json:"douban_id" description:"豆瓣ID"` |
|||
Up int `json:"up" description:"顶"` |
|||
Down int `json:"down" description:"踩"` |
|||
Hits int `json:"hits" description:"人气"` |
|||
HitsMonth int `json:"hits_month" description:"月人气"` |
|||
HitsWeek int `json:"hits_week" description:"周人气"` |
|||
HitsDay int `json:"hits_day" description:"天人气"` |
|||
} |
|||
|
|||
// UpdateRes 更新视频响应
|
|||
type UpdateRes struct{} |
|||
|
|||
// DeleteReq 删除视频请求
|
|||
type DeleteReq struct { |
|||
g.Meta `path:"/video/delete" method:"post" summary:"删除视频" tags:"视频"` |
|||
Id uint `json:"id" description:"视频ID"` |
|||
} |
|||
|
|||
// DeleteRes 删除视频响应
|
|||
type DeleteRes struct{} |
|||
|
|||
// BatchDeleteReq 批量删除视频请求
|
|||
type BatchDeleteReq struct { |
|||
g.Meta `path:"/video/batch/delete" method:"post" summary:"批量删除视频" tags:"视频"` |
|||
Ids []uint `json:"ids" description:"视频ID数组"` |
|||
} |
|||
|
|||
// BatchDeleteRes 批量删除视频响应
|
|||
type BatchDeleteRes struct{} |
|||
|
|||
// GetReq 获取视频请求
|
|||
type GetReq struct { |
|||
g.Meta `path:"/video/get" method:"post" summary:"获取视频" tags:"视频"` |
|||
Id uint `json:"id" description:"视频ID"` |
|||
} |
|||
|
|||
// GetRes 获取视频响应
|
|||
type GetRes struct { |
|||
} |
@ -0,0 +1,20 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
type IVideoV1 interface { |
|||
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) |
|||
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) |
|||
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) |
|||
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) |
|||
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) |
|||
Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) |
|||
} |
@ -0,0 +1,5 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package video |
@ -0,0 +1,15 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package video |
|||
|
|||
import ( |
|||
"xgit.pub/module/cms/app/api/video" |
|||
) |
|||
|
|||
type ControllerV1 struct{} |
|||
|
|||
func NewV1() video.IVideoV1 { |
|||
return &ControllerV1{} |
|||
} |
@ -0,0 +1,14 @@ |
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) { |
|||
return nil, gerror.NewCode(gcode.CodeNotImplemented) |
|||
} |
@ -0,0 +1,14 @@ |
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) { |
|||
return nil, gerror.NewCode(gcode.CodeNotImplemented) |
|||
} |
@ -0,0 +1,14 @@ |
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) { |
|||
return nil, gerror.NewCode(gcode.CodeNotImplemented) |
|||
} |
@ -0,0 +1,14 @@ |
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) { |
|||
return nil, gerror.NewCode(gcode.CodeNotImplemented) |
|||
} |
@ -0,0 +1,14 @@ |
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) { |
|||
return nil, gerror.NewCode(gcode.CodeNotImplemented) |
|||
} |
@ -0,0 +1,14 @@ |
|||
package video |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
"github.com/gogf/gf/v2/errors/gcode" |
|||
"github.com/gogf/gf/v2/errors/gerror" |
|||
|
|||
"xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) { |
|||
return nil, gerror.NewCode(gcode.CodeNotImplemented) |
|||
} |
@ -0,0 +1,107 @@ |
|||
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 |
|||
} |
@ -0,0 +1,56 @@ |
|||
package model |
|||
|
|||
import "github.com/gogf/gf/v2/os/gtime" |
|||
|
|||
type Video struct { |
|||
Id uint `json:"id" description:""` |
|||
Title string `json:"title" description:"标题"` |
|||
TitleSub string `json:"title_sub" description:"副标"` |
|||
Letter string `json:"letter" description:"首字母"` |
|||
Tag string `json:"tag" description:"TAG"` |
|||
Color string `json:"color" description:"颜色"` |
|||
Lock uint `json:"lock" description:"锁定"` |
|||
Copyright uint `json:"copyright" description:"版权"` |
|||
IsEnd uint `json:"is_end" description:"完结"` |
|||
Status uint `json:"status" description:"状态"` |
|||
Class string `json:"class" description:"扩展分类"` |
|||
CategoryId uint `json:"category_id" description:"分类"` |
|||
Pic string `json:"pic" description:"图片"` |
|||
PicId string `json:"pic_id" description:"图片编号"` |
|||
PicLocal string `json:"pic_local" description:""` |
|||
PicThumb string `json:"pic_thumb" description:"缩略图"` |
|||
PicSlide string `json:"pic_slide" description:"轮播"` |
|||
PicScreenshot string `json:"pic_screenshot" description:"截图"` |
|||
PicStatus uint `json:"pic_status" description:"图片状态"` |
|||
Actor string `json:"actor" description:"演员"` |
|||
Director string `json:"director" description:"导演"` |
|||
Writer string `json:"writer" description:"编剧"` |
|||
Remarks string `json:"remarks" description:"备注"` |
|||
Pubdate string `json:"pubdate" description:"发布时间"` |
|||
Total int `json:"total" description:"总集数"` |
|||
Serial string `json:"serial" description:"连载数"` |
|||
Duration string `json:"duration" description:"视频时长"` |
|||
Tv string `json:"tv" description:"电视频道"` |
|||
Weekday string `json:"weekday" description:"节目周期"` |
|||
Area string `json:"area" description:"地区"` |
|||
Lang string `json:"lang" description:"语言"` |
|||
Jumpurl string `json:"jumpurl" description:"跳转URL"` |
|||
Version string `json:"version" description:"资源版本"` |
|||
Year int `json:"year" description:"年份"` |
|||
State string `json:"state" description:"资源类别"` |
|||
DoubanScore float64 `json:"douban_score" description:"豆瓣评分"` |
|||
DoubanId int `json:"douban_id" description:"豆瓣ID"` |
|||
Up int `json:"up" description:"顶"` |
|||
Down int `json:"down" description:"踩"` |
|||
Hits int `json:"hits" description:"人气"` |
|||
HitsMonth int `json:"hits_month" description:"月人气"` |
|||
HitsWeek int `json:"hits_week" description:"周人气"` |
|||
HitsDay int `json:"hits_day" description:"天人气"` |
|||
Content string `json:"content" description:"内容"` |
|||
Blurb string `json:"blurb" description:"简要介绍"` |
|||
CreatedAt *gtime.Time `json:"created_at" description:""` |
|||
UpdatedAt *gtime.Time `json:"updated_at" description:""` |
|||
ActorList []string `json:"actor_list" description:"演员"` |
|||
DirectorList []string `json:"director_list" description:"导演"` |
|||
WriterList []string `json:"writer_list" description:"编剧"` |
|||
} |
@ -0,0 +1,43 @@ |
|||
// ================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// You can delete these comments if you wish manually maintain this interface file.
|
|||
// ================================================================================
|
|||
|
|||
package service |
|||
|
|||
import ( |
|||
"context" |
|||
|
|||
v1 "xgit.pub/module/cms/app/api/video/v1" |
|||
) |
|||
|
|||
type ( |
|||
IVideo interface { |
|||
GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) |
|||
// Create 创建
|
|||
Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) |
|||
// Update 更新
|
|||
Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) |
|||
// Delete 删除
|
|||
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) |
|||
// BatchDelete 批量删除
|
|||
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) |
|||
// Get 获取
|
|||
Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) |
|||
} |
|||
) |
|||
|
|||
var ( |
|||
localVideo IVideo |
|||
) |
|||
|
|||
func Video() IVideo { |
|||
if localVideo == nil { |
|||
panic("implement not found for interface IVideo, forgot register?") |
|||
} |
|||
return localVideo |
|||
} |
|||
|
|||
func RegisterVideo(i IVideo) { |
|||
localVideo = i |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue