recsys.go 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package http
  2. import (
  3. "encoding/json"
  4. "go-common/app/service/bbq/recsys/api/grpc/v1"
  5. bm "go-common/library/net/http/blademaster"
  6. "io/ioutil"
  7. )
  8. // start this just a example
  9. func start(c *bm.Context) {
  10. arg := new(v1.RecsysRequest)
  11. if err := c.Bind(arg); err != nil {
  12. return
  13. }
  14. c.JSON(srv.Start(c, arg))
  15. }
  16. func reqRecsys(c *bm.Context) {
  17. res, _ := ioutil.ReadAll(c.Request.Body)
  18. arg := new(v1.RecsysRequest)
  19. json.Unmarshal(res, &arg)
  20. if err := c.Bind(arg); err != nil {
  21. return
  22. }
  23. c.JSON(srv.Start(c, arg))
  24. }
  25. func relatedRecsys(c *bm.Context) {
  26. res, _ := ioutil.ReadAll(c.Request.Body)
  27. arg := new(v1.RecsysRequest)
  28. json.Unmarshal(res, &arg)
  29. if err := c.Bind(arg); err != nil {
  30. return
  31. }
  32. c.JSON(srv.RelatedRecService(c, arg))
  33. }
  34. func upsRecsys(c *bm.Context) {
  35. res, _ := ioutil.ReadAll(c.Request.Body)
  36. arg := new(v1.RecsysRequest)
  37. json.Unmarshal(res, &arg)
  38. if err := c.Bind(arg); err != nil {
  39. return
  40. }
  41. c.JSON(srv.UpsRecService(c, arg))
  42. }