watermark.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package http
  2. import (
  3. "go-common/app/admin/main/tv/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func waterMarklist(c *bm.Context) {
  8. var (
  9. err error
  10. res = map[string]interface{}{}
  11. pagers *model.WaterMarkListPager
  12. )
  13. param := new(model.WaterMarkListParam)
  14. if err = c.Bind(param); err != nil {
  15. c.JSON(nil, ecode.RequestErr)
  16. return
  17. }
  18. if pagers, err = tvSrv.WaterMarkist(c, param); err != nil {
  19. res["message"] = "获取数据失败!" + err.Error()
  20. c.JSONMap(res, ecode.RequestErr)
  21. return
  22. }
  23. c.JSON(pagers, nil)
  24. }
  25. func waterMarkAdd(c *bm.Context) {
  26. var (
  27. err error
  28. res = map[string]interface{}{}
  29. addRes *model.AddEpIDResp
  30. )
  31. param := new(struct {
  32. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  33. Type string `form:"type" validate:"required"`
  34. })
  35. if err = c.Bind(param); err != nil {
  36. return
  37. }
  38. if param.Type == "seasonid" {
  39. if addRes, err = tvSrv.AddSeasonID(c, param.IDs); err != nil {
  40. res["message"] = "添加数据失败!" + err.Error()
  41. c.JSONMap(res, ecode.RequestErr)
  42. return
  43. }
  44. } else if param.Type == "epid" {
  45. if addRes, err = tvSrv.AddEpID(c, param.IDs); err != nil {
  46. res["message"] = "添加数据失败!" + err.Error()
  47. c.JSONMap(res, ecode.RequestErr)
  48. return
  49. }
  50. }
  51. c.JSON(addRes, nil)
  52. }
  53. func waterMarkDelete(c *bm.Context) {
  54. var (
  55. err error
  56. res = map[string]interface{}{}
  57. )
  58. param := new(struct {
  59. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  60. })
  61. if err = c.Bind(param); err != nil {
  62. return
  63. }
  64. if err = tvSrv.DeleteWatermark(param.IDs); err != nil {
  65. res["message"] = "删除数据失败!" + err.Error()
  66. c.JSONMap(res, ecode.RequestErr)
  67. return
  68. }
  69. c.JSON(nil, nil)
  70. }
  71. func transList(c *bm.Context) {
  72. var param = new(model.TransReq)
  73. if err := c.Bind(param); err != nil {
  74. return
  75. }
  76. if data, err := tvSrv.TransList(c, param); err == nil || err == ecode.NothingFound {
  77. c.JSON(data, nil)
  78. } else {
  79. c.JSON(data, err)
  80. }
  81. }