abtest.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/interface/main/app-resource/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func abTest(c *bm.Context) {
  9. params := c.Request.Form
  10. mobiApp := params.Get("mobi_app")
  11. buildStr := params.Get("build")
  12. device := params.Get("device")
  13. plat := model.Plat(mobiApp, device)
  14. build, err := strconv.Atoi(buildStr)
  15. if err != nil {
  16. c.JSON(nil, ecode.RequestErr)
  17. return
  18. }
  19. c.JSON(abSvc.Experiment(c, plat, build), nil)
  20. }
  21. func abTestV2(c *bm.Context) {
  22. params := c.Request.Form
  23. buvid := params.Get("buvid")
  24. if buvid == "" {
  25. c.JSON(nil, ecode.RequestErr)
  26. return
  27. }
  28. c.JSON(abSvc.TemporaryABTests(c, buvid), nil)
  29. }
  30. func abserver(c *bm.Context) {
  31. params := c.Request.Form
  32. buvid := params.Get("buvid")
  33. device := params.Get("device")
  34. mobiAPP := params.Get("mobi_app")
  35. buildStr := params.Get("build")
  36. filteredStr := params.Get("filtered")
  37. if buvid == "" || device == "" || mobiAPP == "" || buildStr == "" {
  38. c.JSON(nil, ecode.RequestErr)
  39. return
  40. }
  41. build, err := strconv.Atoi(buildStr)
  42. if err != nil {
  43. c.JSON(nil, ecode.RequestErr)
  44. return
  45. }
  46. var mid int64
  47. if midInter, ok := c.Get("mid"); ok {
  48. mid = midInter.(int64)
  49. }
  50. c.JSON(abSvc.AbServer(c, buvid, device, mobiAPP, filteredStr, build, mid))
  51. }