daily.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 dailyID(c *bm.Context) {
  10. params := c.Request.Form
  11. mobiApp := params.Get("mobi_app")
  12. mobiApp = model.MobiAPPBuleChange(mobiApp)
  13. device := params.Get("device")
  14. buildStr := params.Get("build")
  15. pnStr := params.Get("pn")
  16. psStr := params.Get("ps")
  17. dailyIDStr := params.Get("daily_id")
  18. dailyID, err := strconv.Atoi(dailyIDStr)
  19. if err != nil {
  20. log.Error("dailyID(%s) error(%v)", dailyIDStr, err)
  21. c.JSON(nil, ecode.RequestErr)
  22. return
  23. }
  24. plat := model.Plat(mobiApp, device)
  25. pn, err := strconv.Atoi(pnStr)
  26. if err != nil || pn < 1 {
  27. pn = 1
  28. }
  29. ps, err := strconv.Atoi(psStr)
  30. if err != nil || ps > 60 || ps <= 0 {
  31. ps = 60
  32. }
  33. build, err := strconv.Atoi(buildStr)
  34. if err != nil {
  35. log.Error("build(%s) error(%v)", buildStr, err)
  36. c.JSON(nil, ecode.RequestErr)
  37. return
  38. }
  39. data := dailySvc.Daily(c, plat, build, dailyID, pn, ps)
  40. returnJSON(c, data, nil)
  41. }
  42. func columnList(c *bm.Context) {
  43. params := c.Request.Form
  44. mobiApp := params.Get("mobi_app")
  45. mobiApp = model.MobiAPPBuleChange(mobiApp)
  46. device := params.Get("device")
  47. buildStr := params.Get("build")
  48. categoryIDStr := params.Get("category_id")
  49. categoryID, err := strconv.Atoi(categoryIDStr)
  50. if err != nil {
  51. log.Error("categoryID(%s) error(%v)", categoryIDStr, err)
  52. c.JSON(nil, ecode.RequestErr)
  53. return
  54. }
  55. plat := model.Plat(mobiApp, device)
  56. build, err := strconv.Atoi(buildStr)
  57. if err != nil {
  58. log.Error("build(%s) error(%v)", buildStr, err)
  59. c.JSON(nil, ecode.RequestErr)
  60. return
  61. }
  62. data := dailySvc.ColumnList(plat, build, categoryID)
  63. returnJSON(c, data, nil)
  64. }
  65. func category(c *bm.Context) {
  66. params := c.Request.Form
  67. mobiApp := params.Get("mobi_app")
  68. mobiApp = model.MobiAPPBuleChange(mobiApp)
  69. device := params.Get("device")
  70. buildStr := params.Get("build")
  71. categoryIDStr := params.Get("category_id")
  72. columnIDStr := params.Get("column_id")
  73. pnStr := params.Get("pn")
  74. psStr := params.Get("ps")
  75. categoryID, err := strconv.Atoi(categoryIDStr)
  76. if err != nil {
  77. log.Error("categoryID(%s) error(%v)", categoryIDStr, err)
  78. c.JSON(nil, ecode.RequestErr)
  79. return
  80. }
  81. columnID, _ := strconv.Atoi(columnIDStr)
  82. plat := model.Plat(mobiApp, device)
  83. build, err := strconv.Atoi(buildStr)
  84. if err != nil {
  85. log.Error("build(%s) error(%v)", buildStr, err)
  86. c.JSON(nil, ecode.RequestErr)
  87. return
  88. }
  89. pn, err := strconv.Atoi(pnStr)
  90. if err != nil || pn < 1 {
  91. pn = 1
  92. }
  93. ps, err := strconv.Atoi(psStr)
  94. if err != nil || ps > 60 || ps <= 0 {
  95. ps = 60
  96. }
  97. data := dailySvc.Category(plat, build, categoryID, columnID, pn, ps)
  98. returnJSON(c, data, nil)
  99. }