assist.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/space/conf"
  5. "go-common/app/service/main/assist/model/assist"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. bm "go-common/library/net/http/blademaster"
  9. )
  10. func riderList(c *bm.Context) {
  11. var (
  12. mid int64
  13. pn, ps int
  14. rider *assist.AssistUpsPager
  15. err error
  16. )
  17. params := c.Request.Form
  18. midStr, _ := c.Get("mid")
  19. mid = midStr.(int64)
  20. pnStr := params.Get("pn")
  21. psStr := params.Get("ps")
  22. if pn, err = strconv.Atoi(pnStr); err != nil || pn < 1 {
  23. pn = 1
  24. }
  25. if ps, err = strconv.Atoi(psStr); err != nil || ps < 1 || ps > conf.Conf.Rule.MaxRiderPs {
  26. ps = conf.Conf.Rule.MaxRiderPs
  27. }
  28. if rider, err = spcSvc.RiderList(c, mid, pn, ps); err != nil {
  29. log.Error("spcSvc.RiderList(%d,%d,%d) error(%v)", mid, pn, ps, err)
  30. c.JSON(nil, err)
  31. return
  32. }
  33. data := make(map[string]interface{}, 2)
  34. page := map[string]int{
  35. "pn": pn,
  36. "ps": ps,
  37. "count": int(rider.Pager.Total),
  38. }
  39. data["page"] = page
  40. data["list"] = rider.Data
  41. c.JSON(data, nil)
  42. }
  43. func exitRider(c *bm.Context) {
  44. var (
  45. mid, upMid int64
  46. err error
  47. )
  48. params := c.Request.Form
  49. midStr, _ := c.Get("mid")
  50. mid = midStr.(int64)
  51. upMidStr := params.Get("up_mid")
  52. if upMid, err = strconv.ParseInt(upMidStr, 10, 64); err != nil || upMid <= 0 {
  53. c.JSON(nil, ecode.RequestErr)
  54. return
  55. }
  56. c.JSON(nil, spcSvc.ExitRider(c, mid, upMid))
  57. }