module.go 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package http
  2. import (
  3. "encoding/json"
  4. "strconv"
  5. "time"
  6. mdl "go-common/app/interface/main/app-resource/model/module"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. bm "go-common/library/net/http/blademaster"
  10. )
  11. func list(c *bm.Context) {
  12. var (
  13. params = c.Request.Form
  14. build, sysver, level, scale, arch int
  15. err error
  16. env string
  17. )
  18. mobiApp := params.Get("mobi_app")
  19. device := params.Get("device")
  20. platform := params.Get("platform")
  21. env = params.Get("env")
  22. if env != mdl.EnvRelease && env != mdl.EnvTest && env != mdl.EnvDefault {
  23. env = mdl.EnvRelease
  24. }
  25. build, _ = strconv.Atoi(params.Get("build"))
  26. sysver, _ = strconv.Atoi(params.Get("sysver"))
  27. level, _ = strconv.Atoi(params.Get("level"))
  28. scale, _ = strconv.Atoi(params.Get("scale"))
  29. arch, _ = strconv.Atoi(params.Get("arch"))
  30. rPoolName := params.Get("resource_pool_name")
  31. // NOTE: don't ask way rPoolName coded "pink", idiot demand! fuck!!!
  32. // rPoolName := "pink"
  33. // params
  34. verlist := params.Get("verlist")
  35. var versions []*mdl.Versions
  36. if verlist != "" {
  37. if err = json.Unmarshal([]byte(verlist), &versions); err != nil {
  38. log.Error("http list() json.Unmarshal(%s) mobile_app(%s) device(%s) build(%d) error(%v)", verlist, mobiApp, device, build, err)
  39. }
  40. }
  41. data := moduleSvc.List(c, mobiApp, device, platform, rPoolName, env, build, sysver, level, scale, arch, versions, time.Now())
  42. c.JSON(data, nil)
  43. }
  44. func module(c *bm.Context) {
  45. var (
  46. params = c.Request.Form
  47. build, sysver, level, scale, arch int
  48. err error
  49. env string
  50. )
  51. mobiApp := params.Get("mobi_app")
  52. device := params.Get("device")
  53. platform := params.Get("platform")
  54. env = params.Get("env")
  55. if env != mdl.EnvRelease && env != mdl.EnvTest && env != mdl.EnvDefault {
  56. env = mdl.EnvRelease
  57. }
  58. build, _ = strconv.Atoi(params.Get("build"))
  59. sysver, _ = strconv.Atoi(params.Get("sysver"))
  60. level, _ = strconv.Atoi(params.Get("level"))
  61. scale, _ = strconv.Atoi(params.Get("scale"))
  62. arch, _ = strconv.Atoi(params.Get("arch"))
  63. rPoolName := params.Get("resource_pool_name")
  64. // NOTE: don't ask way rPoolName coded "pink", idiot demand! fuck!!!
  65. // rPoolName := "pink"
  66. rName := params.Get("resource_name")
  67. verStr := params.Get("ver")
  68. ver, _ := strconv.Atoi(verStr)
  69. if rPoolName == "" || rName == "" {
  70. c.JSON(nil, ecode.RequestErr)
  71. return
  72. }
  73. data, err := moduleSvc.Resource(c, mobiApp, device, platform, rPoolName, rName, env, ver, build, sysver, level, scale, arch, time.Now())
  74. if err != nil {
  75. c.JSON(nil, err)
  76. return
  77. }
  78. c.JSON(data, nil)
  79. }