match.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. package http
  2. import (
  3. match "go-common/app/interface/main/activity/model/like"
  4. bm "go-common/library/net/http/blademaster"
  5. )
  6. func matchs(c *bm.Context) {
  7. p := new(match.ParamSid)
  8. if err := c.Bind(p); err != nil {
  9. return
  10. }
  11. c.JSON(matchSvc.Match(c, p.Sid))
  12. }
  13. func addGuess(c *bm.Context) {
  14. var (
  15. mid int64
  16. err error
  17. )
  18. midStr, _ := c.Get("mid")
  19. mid = midStr.(int64)
  20. p := new(match.ParamAddGuess)
  21. if err = c.Bind(p); err != nil {
  22. return
  23. }
  24. if p.Stake < 1 {
  25. p.Stake = 1
  26. }
  27. _, err = matchSvc.AddGuess(c, mid, p)
  28. c.JSON(nil, err)
  29. }
  30. func listGuess(c *bm.Context) {
  31. var (
  32. mid int64
  33. )
  34. p := new(match.ParamSid)
  35. if err := c.Bind(p); err != nil {
  36. return
  37. }
  38. midStr, _ := c.Get("mid")
  39. mid = midStr.(int64)
  40. c.JSON(matchSvc.ListGuess(c, p.Sid, mid))
  41. }
  42. func guess(c *bm.Context) {
  43. midStr, _ := c.Get("mid")
  44. mid := midStr.(int64)
  45. p := new(match.ParamSid)
  46. if err := c.Bind(p); err != nil {
  47. return
  48. }
  49. c.JSON(matchSvc.Guess(c, mid, p))
  50. }
  51. func clearCache(c *bm.Context) {
  52. p := new(match.ParamMsg)
  53. if err := c.Bind(p); err != nil {
  54. return
  55. }
  56. c.JSON(nil, matchSvc.ClearCache(c, p.Msg))
  57. }
  58. func addFollow(c *bm.Context) {
  59. var (
  60. mid int64
  61. )
  62. midStr, _ := c.Get("mid")
  63. mid = midStr.(int64)
  64. p := new(match.ParamTeams)
  65. if err := c.Bind(p); err != nil {
  66. return
  67. }
  68. c.JSON(nil, matchSvc.AddFollow(c, mid, p.Teams))
  69. }
  70. func follow(c *bm.Context) {
  71. var (
  72. mid int64
  73. )
  74. midStr, _ := c.Get("mid")
  75. mid = midStr.(int64)
  76. c.JSON(matchSvc.Follow(c, mid))
  77. }
  78. func unStart(c *bm.Context) {
  79. var (
  80. mid int64
  81. err error
  82. total int
  83. list []*match.Object
  84. )
  85. if midInter, ok := c.Get("mid"); ok {
  86. mid = midInter.(int64)
  87. }
  88. p := new(match.ParamObject)
  89. if err = c.Bind(p); err != nil {
  90. return
  91. }
  92. if list, total, err = matchSvc.ObjectsUnStart(c, mid, p); err != nil {
  93. c.JSON(nil, err)
  94. return
  95. }
  96. data := make(map[string]interface{}, 2)
  97. page := map[string]int{
  98. "num": p.Pn,
  99. "size": p.Ps,
  100. "total": total,
  101. }
  102. data["page"] = page
  103. data["list"] = list
  104. c.JSON(data, nil)
  105. }