resource.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package http
  2. import (
  3. "strconv"
  4. "strings"
  5. "go-common/app/service/main/resource/model"
  6. "go-common/library/ecode"
  7. bm "go-common/library/net/http/blademaster"
  8. )
  9. func resource(c *bm.Context) {
  10. var (
  11. params = c.Request.Form
  12. rid int
  13. err error
  14. )
  15. ridStr := params.Get("rid")
  16. if rid, err = strconv.Atoi(ridStr); err != nil {
  17. c.JSON(nil, ecode.RequestErr)
  18. return
  19. }
  20. c.JSON(resSvc.Resource(c, rid), nil)
  21. }
  22. func resources(c *bm.Context) {
  23. var (
  24. params = c.Request.Form
  25. rid int
  26. rids []int
  27. err error
  28. )
  29. ridsStr := params.Get("rids")
  30. sArr := strings.Split(ridsStr, ",")
  31. for _, s := range sArr {
  32. if rid, err = strconv.Atoi(s); err != nil {
  33. c.JSON(nil, ecode.RequestErr)
  34. return
  35. }
  36. rids = append(rids, rid)
  37. }
  38. c.JSON(resSvc.Resources(c, rids), nil)
  39. }
  40. func indexIcon(c *bm.Context) {
  41. c.JSON(resSvc.IndexIcon(c), nil)
  42. }
  43. func playerIcon(c *bm.Context) {
  44. c.JSON(resSvc.PlayerIcon(c))
  45. }
  46. func cmtbox(c *bm.Context) {
  47. var (
  48. params = c.Request.Form
  49. id int64
  50. err error
  51. )
  52. if id, err = strconv.ParseInt(params.Get("id"), 10, 64); err != nil {
  53. c.JSON(nil, ecode.RequestErr)
  54. return
  55. }
  56. c.JSON(resSvc.Cmtbox(c, id))
  57. }
  58. func regionCard(c *bm.Context) {
  59. var (
  60. params = c.Request.Form
  61. err error
  62. )
  63. mobiApp := params.Get("mobi_app")
  64. buildStr := params.Get("build")
  65. // check params
  66. build, err := strconv.Atoi(buildStr)
  67. if err != nil {
  68. c.JSON(nil, ecode.RequestErr)
  69. return
  70. }
  71. device := params.Get("device")
  72. plat := model.Plat(mobiApp, device)
  73. c.JSON(resSvc.RegionCard(c, plat, build))
  74. }
  75. func audit(c *bm.Context) {
  76. c.JSON(resSvc.Audit(c), nil)
  77. }