Browse Source

视频管理

master
chenyang 11 months ago
parent
commit
80d2c2ab36
  1. 4
      app/api/category/v1/category.go
  2. 7
      app/controller/video/video_v1_batch_delete.go
  3. 7
      app/controller/video/video_v1_create.go
  4. 7
      app/controller/video/video_v1_delete.go
  5. 7
      app/controller/video/video_v1_get.go
  6. 7
      app/controller/video/video_v1_get_list.go
  7. 7
      app/controller/video/video_v1_update.go
  8. 5
      app/logic/category/category.go
  9. 3
      app/logic/collect/collect.go
  10. 18
      app/logic/video/video.go
  11. 4
      app/service/video.go
  12. 25
      go.sum

4
app/api/category/v1/category.go

@ -48,7 +48,9 @@ type CreateReq struct {
}
// CreateRes 创建分类返回参数
type CreateRes struct{}
type CreateRes struct {
Id int64 `json:"id"`
}
// UpdateReq 更新分类请求参数
type UpdateReq struct {

7
app/controller/video/video_v1_batch_delete.go

@ -2,13 +2,12 @@ package video
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/service"
"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)
err = service.Video().BatchDelete(ctx, req)
return
}

7
app/controller/video/video_v1_create.go

@ -2,13 +2,12 @@ package video
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/service"
"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)
res, err = service.Video().Create(ctx, req)
return
}

7
app/controller/video/video_v1_delete.go

@ -2,13 +2,12 @@ package video
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/service"
"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)
err = service.Video().Delete(ctx, req)
return
}

7
app/controller/video/video_v1_get.go

@ -2,13 +2,12 @@ package video
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/service"
"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)
res, err = service.Video().Get(ctx, req)
return
}

7
app/controller/video/video_v1_get_list.go

@ -2,13 +2,12 @@ package video
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/service"
"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)
res, err = service.Video().GetList(ctx, req)
return
}

7
app/controller/video/video_v1_update.go

@ -2,13 +2,12 @@ package video
import (
"context"
"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
"xgit.pub/module/cms/app/service"
"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)
err = service.Video().Update(ctx, req)
return
}

5
app/logic/category/category.go

@ -71,6 +71,7 @@ func (s *sCategory) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.Ge
// Create 创建
func (s *sCategory) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
err = dao.Category.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
if req.Union == "" {
req.Union, _ = pinyin.New(req.Name).Split("").Mode(pinyin.InitialsInCapitals).Convert()
@ -82,9 +83,9 @@ func (s *sCategory) Create(ctx context.Context, req *v1.CreateReq) (res *v1.Crea
if m.Extend, err = gjson.EncodeString(req.CategoryExtend); err != nil {
return nil
}
res = &v1.CreateRes{}
//id, err = dao.Category.Ctx(ctx).InsertAndGetId(in)
_, err = dao.Category.Ctx(ctx).InsertAndGetId(m)
res.Id, err = dao.Category.Ctx(ctx).InsertAndGetId(m)
return err
})
return

3
app/logic/collect/collect.go

@ -39,6 +39,9 @@ func (s *sCollect) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.Get
}
var list []*entity.Collect
err = tx.Page(req.Page, req.PageSize).Scan(&list)
res.Rows = list
res.Page = req.Page
res.PageSize = req.PageSize
return
}

18
app/logic/video/video.go

@ -8,11 +8,21 @@ import (
v1 "xgit.pub/module/cms/app/api/video/v1"
"xgit.pub/module/cms/app/dao"
"xgit.pub/module/cms/app/model"
"xgit.pub/module/cms/app/service"
)
type sVideo struct {
}
func init() {
Video := New()
service.RegisterVideo(Video)
}
func New() *sVideo {
return &sVideo{}
}
func (s *sVideo) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
res = &v1.GetListRes{}
tx := dao.Video.Ctx(ctx)
@ -49,7 +59,9 @@ func (s *sVideo) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetLi
if req.Writer != "" { //编剧
tx = tx.WhereLike(dao.Video.Columns().Writer, "%"+req.Writer+"%")
}
if req.Order == "" {
tx = tx.OrderDesc(dao.Video.Columns().Id)
}
if err = tx.Page(req.Page, req.PageSize).Scan(&ms); err != nil {
return
}
@ -75,8 +87,8 @@ func (s *sVideo) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetLi
}
}
//res.Total, _ = tx.Count()
//err = tx.GetList(req.GetList, req.PageSize).Scan(&ms)
res.Total, _ = tx.Count()
err = tx.Page(req.Page, req.PageSize).Scan(&ms)
res.Page = req.Page
res.PageSize = req.PageSize
res.Rows = ms

4
app/service/video.go

@ -19,9 +19,9 @@ type (
// Update 更新
Update(ctx context.Context, req *v1.UpdateReq) (err error)
// Delete 删除
Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error)
Delete(ctx context.Context, req *v1.DeleteReq) (err error)
// BatchDelete 批量删除
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error)
BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (err error)
// Get 获取
Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error)
}

25
go.sum

@ -3,20 +3,20 @@ github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/gogf/gf/v2 v2.5.2 h1:fACJE7DJH6iTGHGhgiNY1uuZIZtr2IqQkJ52E+wBnt8=
github.com/gogf/gf/v2 v2.5.2/go.mod h1:7yf5qp0BznfsYx7Sw49m3mQvBsHpwAjJk3Q9ZnKoUEc=
github.com/gogf/gf/v2 v2.6.0 h1:hQdi31tuvRQTIZ2YLls6Gr5oULAabDPyYYKBE4xSNLg=
github.com/gogf/gf/v2 v2.6.0/go.mod h1:x2XONYcI4hRQ/4gMNbWHmZrNzSEIg20s2NULbzom5k0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grokify/html-strip-tags-go v0.0.1 h1:0fThFwLbW7P/kOiTBs03FsJSV9RM2M/Q/MOnCQxKMo0=
@ -26,8 +26,7 @@ github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPK
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
@ -35,27 +34,25 @@ github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY=
go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM=
go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M=
go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8=
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

Loading…
Cancel
Save