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

11 months ago
  1. package video
  2. import (
  3. "context"
  4. "github.com/gogf/gf/v2/text/gstr"
  5. v1 "xgit.pub/module/cms/app/api/video/v1"
  6. "xgit.pub/module/cms/app/dao"
  7. "xgit.pub/module/cms/app/model"
  8. )
  9. type sVideo struct {
  10. }
  11. func (s *sVideo) GetList(ctx context.Context, req *v1.GetListReq) (res *v1.GetListRes, err error) {
  12. res = &v1.GetListRes{}
  13. tx := dao.Video.Ctx(ctx)
  14. //var ms []*entity.Video
  15. var ms []*model.Video
  16. if req.Title != "" { //标题
  17. tx = tx.WhereLike(dao.Video.Columns().Title, "%"+req.Title+"%")
  18. }
  19. //if req.TitleSub != "" {
  20. // tx = tx.WhereLike(dao.Video.Columns().TitleSub, "%"+req.TitleSub+"%")
  21. //}
  22. if len(req.CategoryIdList) > 0 { //分类
  23. tx = tx.WhereIn(dao.Video.Columns().CategoryId, req.CategoryIdList)
  24. }
  25. if req.Lock != "" { //锁定
  26. tx = tx.Where(dao.Video.Columns().Lock, req.Lock)
  27. }
  28. if req.IsEnd != "" { //完结
  29. tx = tx.Where(dao.Video.Columns().IsEnd, req.IsEnd)
  30. }
  31. if req.Copyright != "" { //版权
  32. tx = tx.Where(dao.Video.Columns().Copyright, req.Copyright)
  33. }
  34. if req.Year > 0 { //年份
  35. tx = tx.Where(dao.Video.Columns().Year, req.Year)
  36. }
  37. if req.Actor != "" { //演员
  38. tx = tx.WhereLike(dao.Video.Columns().Actor, "%"+req.Actor+"%")
  39. }
  40. if req.Director != "" { //导演
  41. tx = tx.WhereLike(dao.Video.Columns().Director, "%"+req.Director+"%")
  42. }
  43. if req.Writer != "" { //编剧
  44. tx = tx.WhereLike(dao.Video.Columns().Writer, "%"+req.Writer+"%")
  45. }
  46. if err = tx.Page(req.Page, req.PageSize).Scan(&ms); err != nil {
  47. return
  48. }
  49. if res.Total, err = tx.Count(); err != nil {
  50. return
  51. }
  52. for idx, item := range ms {
  53. if len(item.Actor) > 0 {
  54. ms[idx].ActorList = gstr.Split(item.Actor, ",")
  55. } else {
  56. ms[idx].ActorList = []string{}
  57. }
  58. if len(item.Director) > 0 {
  59. ms[idx].DirectorList = gstr.Split(item.Director, ",")
  60. } else {
  61. ms[idx].DirectorList = []string{}
  62. }
  63. if len(item.Writer) > 0 {
  64. ms[idx].WriterList = gstr.Split(item.Writer, ",")
  65. } else {
  66. ms[idx].WriterList = []string{}
  67. }
  68. }
  69. //res.Total, _ = tx.Count()
  70. //err = tx.GetList(req.GetList, req.PageSize).Scan(&ms)
  71. res.Page = req.Page
  72. res.PageSize = req.PageSize
  73. res.Rows = ms
  74. return
  75. }
  76. // Create 创建
  77. func (s *sVideo) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) {
  78. return
  79. }
  80. // Update 更新
  81. func (s *sVideo) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.UpdateRes, err error) {
  82. return
  83. }
  84. // Delete 删除
  85. func (s *sVideo) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.DeleteRes, err error) {
  86. return
  87. }
  88. // BatchDelete 批量删除
  89. func (s *sVideo) BatchDelete(ctx context.Context, req *v1.BatchDeleteReq) (res *v1.BatchDeleteRes, err error) {
  90. return
  91. }
  92. // Get 获取
  93. func (s *sVideo) Get(ctx context.Context, req *v1.GetReq) (res *v1.GetRes, err error) {
  94. return
  95. }