match_active.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package http
  2. import (
  3. "go-common/app/admin/main/esports/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func addAct(c *bm.Context) {
  7. v := new(model.ParamMA)
  8. if err := c.Bind(v); err != nil {
  9. return
  10. }
  11. c.JSON(esSvc.AddAct(c, v))
  12. }
  13. func editAct(c *bm.Context) {
  14. v := new(model.ParamMA)
  15. if err := c.Bind(v); err != nil {
  16. return
  17. }
  18. c.JSON(esSvc.EditAct(c, v))
  19. }
  20. func forbidAct(c *bm.Context) {
  21. v := new(struct {
  22. ID int64 `form:"id" validate:"required"`
  23. State int `form:"state" validate:"min=0,max=1"`
  24. })
  25. if err := c.Bind(v); err != nil {
  26. return
  27. }
  28. c.JSON(nil, esSvc.ForbidAct(c, v.ID, v.State))
  29. }
  30. func listAct(c *bm.Context) {
  31. var (
  32. list []*model.MatchModule
  33. cnt int64
  34. err error
  35. )
  36. v := new(struct {
  37. Mid int64 `form:"mid"`
  38. Pn int64 `form:"pn" validate:"min=0" default:"1"`
  39. Ps int64 `form:"ps" validate:"min=0,max=30" default:"20"`
  40. })
  41. if err = c.Bind(v); err != nil {
  42. return
  43. }
  44. if list, cnt, err = esSvc.ListAct(c, v.Mid, v.Pn, v.Ps); err != nil {
  45. c.JSON(nil, err)
  46. return
  47. }
  48. data := make(map[string]interface{}, 2)
  49. page := map[string]int64{
  50. "num": v.Pn,
  51. "size": v.Ps,
  52. "count": cnt,
  53. }
  54. data["page"] = page
  55. data["list"] = list
  56. c.JSON(data, nil)
  57. }