diff --git a/app/api/api/api.go b/app/api/api/api.go new file mode 100644 index 0000000..e5f44a7 --- /dev/null +++ b/app/api/api/api.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package api + +import ( + "context" + + "xgit.pub/module/cms/app/api/api/v1" +) + +type IApiV1 interface { + Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) +} diff --git a/app/api/api/v1/api.go b/app/api/api/v1/api.go new file mode 100644 index 0000000..58e5469 --- /dev/null +++ b/app/api/api/v1/api.go @@ -0,0 +1,51 @@ +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +// CreateReq 创建视频请求 +type CreateReq struct { + g.Meta `path:"/api/video/add" method:"post" summary:"创建视频" tags:"视频"` + CollectId int `json:"collect_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:"图片"` + 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{} diff --git a/app/api/video/v1/video.go b/app/api/video/v1/video.go index ccfb33f..49641ff 100644 --- a/app/api/video/v1/video.go +++ b/app/api/video/v1/video.go @@ -28,6 +28,7 @@ type GetListRes struct { // CreateReq 创建视频请求 type CreateReq struct { g.Meta `path:"/video/add" method:"post" summary:"创建视频" tags:"视频"` + CollectId int `json:"collect_id" description:"站点" ` Title string `json:"title" description:"标题"` TitleSub string `json:"title_sub" description:"副标"` Letter string `json:"letter" description:"首字母"` @@ -76,6 +77,7 @@ type CreateRes struct{} type UpdateReq struct { g.Meta `path:"/video/update" method:"post" summary:"更新视频" tags:"视频"` Id uint `json:"id" description:""` + CollectId int `json:"collect_id" description:"站点" ` Title string `json:"title" description:"标题"` TitleSub string `json:"title_sub" description:"副标"` Letter string `json:"letter" description:"首字母"` diff --git a/app/controller/api/api.go b/app/controller/api/api.go new file mode 100644 index 0000000..b4e92a1 --- /dev/null +++ b/app/controller/api/api.go @@ -0,0 +1,5 @@ +// ================================================================================= +// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// ================================================================================= + +package api diff --git a/app/controller/api/api_new.go b/app/controller/api/api_new.go new file mode 100644 index 0000000..a23c9c8 --- /dev/null +++ b/app/controller/api/api_new.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package api + +import ( + "xgit.pub/module/cms/app/api/api" +) + +type ControllerV1 struct{} + +func NewV1() api.IApiV1 { + return &ControllerV1{} +} diff --git a/app/controller/api/api_v1_create.go b/app/controller/api/api_v1_create.go new file mode 100644 index 0000000..6e3ddb8 --- /dev/null +++ b/app/controller/api/api_v1_create.go @@ -0,0 +1,14 @@ +package api + +import ( + "context" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "xgit.pub/module/cms/app/api/api/v1" +) + +func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/app/dao/internal/video.go b/app/dao/internal/video.go index 9e63414..19df715 100644 --- a/app/dao/internal/video.go +++ b/app/dao/internal/video.go @@ -21,6 +21,7 @@ type VideoDao struct { // VideoColumns defines and stores column names for table cms_video. type VideoColumns struct { Id string // + CollectId string // 站点 Title string // 标题 TitleSub string // 副标 Letter string // 首字母 @@ -72,6 +73,7 @@ type VideoColumns struct { // videoColumns holds the columns for table cms_video. var videoColumns = VideoColumns{ Id: "id", + CollectId: "collect_id", Title: "title", TitleSub: "title_sub", Letter: "letter", diff --git a/app/logic/category/category.go b/app/logic/category/category.go index dab8c23..6a39196 100644 --- a/app/logic/category/category.go +++ b/app/logic/category/category.go @@ -205,3 +205,13 @@ func (s *sCategory) getSubCategory(rs []*model.Category, id int) []*model.Catego } return children } + +// GetCategoryNameById 获取分类名称 +func (s *sCategory) GetCategoryNameById(ctx context.Context, id uint) (name string) { + var category entity.Category + err := dao.Category.Ctx(ctx).Where(dao.Category.Columns().Id, id).Scan(&category) + if err != nil { + return + } + return category.Name +} diff --git a/app/logic/collect/collect.go b/app/logic/collect/collect.go index 401d72f..3b487da 100644 --- a/app/logic/collect/collect.go +++ b/app/logic/collect/collect.go @@ -101,3 +101,13 @@ func (s *sCollect) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res }) return } + +// GetCollectNameById 获取收藏名称 +func (s *sCollect) GetCollectNameById(ctx context.Context, id int) (name string) { + var collect entity.Collect + err := dao.Collect.Ctx(ctx).Where(dao.Collect.Columns().Id, id).Scan(&collect) + if err != nil { + return + } + return collect.Name +} diff --git a/app/logic/video/video.go b/app/logic/video/video.go index ccc32d2..4f46f47 100644 --- a/app/logic/video/video.go +++ b/app/logic/video/video.go @@ -85,7 +85,8 @@ func (s *sVideo) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetLi } else { ms[idx].WriterList = []string{} } - + ms[idx].CategoryName = service.Category().GetCategoryNameById(ctx, item.CategoryId) + ms[idx].CollectName = service.Collect().GetCollectNameById(ctx, item.CollectId) } res.Total, _ = tx.Count() err = tx.Page(req.Page, req.PageSize).Scan(&ms) diff --git a/app/model/do/video.go b/app/model/do/video.go index 3427e3e..6af54ed 100644 --- a/app/model/do/video.go +++ b/app/model/do/video.go @@ -13,6 +13,7 @@ import ( type Video struct { g.Meta `orm:"table:cms_video, do:true"` Id interface{} // + CollectId interface{} // 站点 Title interface{} // 标题 TitleSub interface{} // 副标 Letter interface{} // 首字母 diff --git a/app/model/entity/video.go b/app/model/entity/video.go index 0df3e66..cad5647 100644 --- a/app/model/entity/video.go +++ b/app/model/entity/video.go @@ -11,6 +11,7 @@ import ( // Video is the golang structure for table video. type Video struct { Id uint `json:"id" ` // + CollectId int `json:"collect_id" ` // 站点 Title string `json:"title" ` // 标题 TitleSub string `json:"title_sub" ` // 副标 Letter string `json:"letter" ` // 首字母 diff --git a/app/model/video.go b/app/model/video.go index c74f691..a1184cd 100644 --- a/app/model/video.go +++ b/app/model/video.go @@ -4,6 +4,7 @@ import "github.com/gogf/gf/v2/os/gtime" type Video struct { Id uint `json:"id" description:""` + CollectId int `json:"collect_id" ` // 站点 Title string `json:"title" description:"标题"` TitleSub string `json:"title_sub" description:"副标"` Letter string `json:"letter" description:"首字母"` @@ -53,4 +54,6 @@ type Video struct { ActorList []string `json:"actor_list" description:"演员"` DirectorList []string `json:"director_list" description:"导演"` WriterList []string `json:"writer_list" description:"编剧"` + CollectName string `json:"collect_name" description:"站点名称"` + CategoryName string `json:"category_name" description:"分类名称"` } diff --git a/app/service/category.go b/app/service/category.go index b4ce2d4..91a2e9d 100644 --- a/app/service/category.go +++ b/app/service/category.go @@ -27,6 +27,8 @@ type ( // BatchDelete 批量删除 BatchDelete(ctx context.Context, in *v1.BatchDeleteReq) (err error) Drop(ctx context.Context, source int, target int, action string) (err error) + // GetCategoryNameById 获取分类名称 + GetCategoryNameById(ctx context.Context, id uint) (name string) } ) diff --git a/app/service/collect.go b/app/service/collect.go index 484d079..42b3201 100644 --- a/app/service/collect.go +++ b/app/service/collect.go @@ -25,6 +25,8 @@ type ( 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) + // GetCollectNameById 获取收藏名称 + GetCollectNameById(ctx context.Context, id int) (name string) } )