rank.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/app-show/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func rankAll(c *bm.Context) {
  10. params := c.Request.Form
  11. mobiApp := params.Get("mobi_app")
  12. device := params.Get("device")
  13. order := params.Get("order")
  14. buildStr := params.Get("build")
  15. pnStr := params.Get("pn")
  16. psStr := params.Get("ps")
  17. plat := model.Plat(mobiApp, device)
  18. pn, err := strconv.Atoi(pnStr)
  19. if err != nil || pn < 1 {
  20. pn = 1
  21. }
  22. ps, err := strconv.Atoi(psStr)
  23. if err != nil || ps > 100 || ps <= 0 {
  24. ps = 100
  25. }
  26. if ((pn-1)*ps)+1 > 100 {
  27. returnJSON(c, _emptyShowItems, nil)
  28. return
  29. }
  30. build, _ := strconv.Atoi(buildStr)
  31. var mid int64
  32. if midInter, ok := c.Get("mid"); ok {
  33. mid = midInter.(int64)
  34. }
  35. // GetAudit
  36. if audit, ok := rankSvc.Audit(c, mobiApp, order, plat, build, 0); ok {
  37. returnJSON(c, audit, nil)
  38. } else {
  39. data := rankSvc.RankShow(c, plat, 0, pn, ps, mid, order)
  40. returnJSON(c, data, nil)
  41. }
  42. }
  43. func rankRegion(c *bm.Context) {
  44. params := c.Request.Form
  45. mobiApp := params.Get("mobi_app")
  46. device := params.Get("device")
  47. ridStr := params.Get("rid")
  48. buildStr := params.Get("build")
  49. pnStr := params.Get("pn")
  50. psStr := params.Get("ps")
  51. plat := model.Plat(mobiApp, device)
  52. rid, err := strconv.Atoi(ridStr)
  53. if err != nil {
  54. log.Error("ridStr(%s) error(%v)", ridStr, err)
  55. c.JSON(nil, ecode.RequestErr)
  56. return
  57. }
  58. pn, err := strconv.Atoi(pnStr)
  59. if err != nil || pn < 1 {
  60. pn = 1
  61. }
  62. ps, err := strconv.Atoi(psStr)
  63. if err != nil || ps > 100 || ps <= 0 {
  64. ps = 100
  65. }
  66. if ((pn-1)*ps)+1 > 100 {
  67. returnJSON(c, _emptyShowItems, nil)
  68. return
  69. }
  70. build, _ := strconv.Atoi(buildStr)
  71. var mid int64
  72. if midInter, ok := c.Get("mid"); ok {
  73. mid = midInter.(int64)
  74. }
  75. // GetAudit
  76. if audit, ok := rankSvc.Audit(c, mobiApp, "all", plat, build, rid); ok {
  77. returnJSON(c, audit, nil)
  78. } else {
  79. data := rankSvc.RankShow(c, plat, rid, pn, ps, mid, "all")
  80. returnJSON(c, data, nil)
  81. }
  82. }