Browse Source

视频管理

master
chenyang 11 months ago
parent
commit
fc07b4d1d4
  1. 15
      app/api/api/api.go
  2. 51
      app/api/api/v1/api.go
  3. 2
      app/api/video/v1/video.go
  4. 5
      app/controller/api/api.go
  5. 15
      app/controller/api/api_new.go
  6. 14
      app/controller/api/api_v1_create.go
  7. 2
      app/dao/internal/video.go
  8. 10
      app/logic/category/category.go
  9. 10
      app/logic/collect/collect.go
  10. 3
      app/logic/video/video.go
  11. 1
      app/model/do/video.go
  12. 1
      app/model/entity/video.go
  13. 3
      app/model/video.go
  14. 2
      app/service/category.go
  15. 2
      app/service/collect.go

15
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)
}

51
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{}

2
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:"首字母"`

5
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

15
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{}
}

14
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)
}

2
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",

10
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
}

10
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
}

3
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)

1
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{} // 首字母

1
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" ` // 首字母

3
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:"分类名称"`
}

2
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)
}
)

2
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)
}
)

Loading…
Cancel
Save