label.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 addTime(c *bm.Context) {
  8. tm := new(model.UgcTime)
  9. if err := c.Bind(tm); err != nil {
  10. return
  11. }
  12. c.JSON(nil, tvSrv.AddUgcTm(tm))
  13. }
  14. func editTime(c *bm.Context) {
  15. tm := new(model.EditUgcTime)
  16. if err := c.Bind(tm); err != nil {
  17. return
  18. }
  19. c.JSON(nil, tvSrv.EditUgcTm(tm))
  20. }
  21. func actLabels(c *bm.Context) {
  22. param := new(struct {
  23. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  24. Action string `form:"action" validate:"required"` // 0 = hide, 1 = recover
  25. })
  26. if err := c.Bind(param); err != nil {
  27. return
  28. }
  29. c.JSON(nil, tvSrv.ActLabels(param.IDs, atoi(param.Action)))
  30. }
  31. func delTmLabels(c *bm.Context) {
  32. param := new(struct {
  33. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  34. })
  35. if err := c.Bind(param); err != nil {
  36. return
  37. }
  38. c.JSON(nil, tvSrv.DelLabels(param.IDs))
  39. }
  40. func ugcLabels(c *bm.Context) {
  41. req := new(model.ReqLabel)
  42. if err := c.Bind(req); err != nil {
  43. return
  44. }
  45. if req.Param != model.ParamUgctime && req.Param != model.ParamTypeid {
  46. c.JSON(nil, ecode.RequestErr)
  47. return
  48. }
  49. c.JSON(tvSrv.PickLabels(req, model.UgcLabel))
  50. }
  51. func pgcLabels(c *bm.Context) {
  52. req := new(model.ReqLabel)
  53. if err := c.Bind(req); err != nil {
  54. return
  55. }
  56. c.JSON(tvSrv.PickLabels(req, model.PgcLabel))
  57. }
  58. func pgcLblTps(c *bm.Context) {
  59. param := new(struct {
  60. Category int `form:"category" validate:"required,min=1,gt=0"`
  61. })
  62. if err := c.Bind(param); err != nil {
  63. return
  64. }
  65. c.JSON(tvSrv.LabelTp(param.Category))
  66. }
  67. func editLabel(c *bm.Context) {
  68. param := new(struct {
  69. ID int64 `form:"id" validate:"required"`
  70. Name string `form:"name" validate:"required"`
  71. })
  72. if err := c.Bind(param); err != nil {
  73. return
  74. }
  75. c.JSON(nil, tvSrv.EditLabel(param.ID, param.Name))
  76. }
  77. func pubLabel(c *bm.Context) {
  78. param := new(struct {
  79. IDs []int64 `form:"ids,split" validate:"required,min=1,dive,gt=0"`
  80. })
  81. if err := c.Bind(param); err != nil {
  82. return
  83. }
  84. c.JSON(nil, tvSrv.PubLabel(param.IDs))
  85. }