match_detail.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package http
  2. import (
  3. "go-common/app/admin/main/esports/model"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func addDetail(c *bm.Context) {
  7. v := new(model.MatchDetail)
  8. if err := c.Bind(v); err != nil {
  9. return
  10. }
  11. c.JSON(nil, esSvc.AddDetail(c, v))
  12. }
  13. func editDetail(c *bm.Context) {
  14. v := new(model.MatchDetail)
  15. if err := c.Bind(v); err != nil {
  16. return
  17. }
  18. c.JSON(nil, esSvc.EditDetail(c, v))
  19. }
  20. func forbidDetail(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.ForbidDetail(c, v.ID, v.State))
  29. }
  30. func onLine(c *bm.Context) {
  31. v := new(struct {
  32. ID int64 `form:"id" validate:"required"`
  33. State int64 `form:"state" validate:"min=0,max=1"`
  34. })
  35. if err := c.Bind(v); err != nil {
  36. return
  37. }
  38. c.JSON(nil, esSvc.UpOnline(c, v.ID, v.State))
  39. }
  40. func listDetail(c *bm.Context) {
  41. var (
  42. list []*model.MatchDetail
  43. cnt int64
  44. err error
  45. )
  46. v := new(struct {
  47. MaID int64 `json:"ma_id,omitempty" form:"ma_id" validate:"required"`
  48. Pn int64 `form:"pn" validate:"min=0" default:"1"`
  49. Ps int64 `form:"ps" validate:"min=0,max=30" default:"20"`
  50. })
  51. if err = c.Bind(v); err != nil {
  52. return
  53. }
  54. if list, cnt, err = esSvc.ListDetail(c, v.MaID, v.Pn, v.Ps); err != nil {
  55. c.JSON(nil, err)
  56. return
  57. }
  58. data := make(map[string]interface{}, 2)
  59. page := map[string]int64{
  60. "num": v.Pn,
  61. "size": v.Ps,
  62. "count": cnt,
  63. }
  64. data["page"] = page
  65. data["list"] = list
  66. c.JSON(data, nil)
  67. }