figure.go 860 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/service/main/figure/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func figureInfo(c *bm.Context) {
  10. var (
  11. err error
  12. params = c.Request.Form
  13. midStr = params.Get("mid")
  14. )
  15. mid, err := strconv.ParseInt(midStr, 10, 64)
  16. if err != nil {
  17. log.Error("strconv.ParseInt(%s) error(%+v)", midStr, err)
  18. c.JSON(nil, ecode.RequestErr)
  19. return
  20. }
  21. c.JSON(svc.FigureWithRank(c, mid))
  22. }
  23. func figureInfos(c *bm.Context) {
  24. var (
  25. err error
  26. v = &model.ParamBatchInfo{}
  27. )
  28. if err = c.Bind(v); err != nil {
  29. return
  30. }
  31. if len(v.MIDs) > 50 {
  32. err = ecode.RequestErr
  33. return
  34. }
  35. var (
  36. frs []*model.FigureWithRank
  37. )
  38. frs, err = svc.BatchFigureWithRank(c, v.MIDs)
  39. if frs == nil {
  40. frs = make([]*model.FigureWithRank, 0)
  41. }
  42. c.JSON(frs, err)
  43. }