find_kuaishou_product.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package handler
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "youngee_b_api/consts"
  6. "youngee_b_api/model/http_model"
  7. "youngee_b_api/service"
  8. "youngee_b_api/util"
  9. )
  10. func WrapFindKuaishouProductHandler(ctx *gin.Context) {
  11. handler := newFindKuaishouProductHandler(ctx)
  12. baseRun(handler)
  13. }
  14. func newFindKuaishouProductHandler(ctx *gin.Context) *FindKuaishouProductHandler {
  15. return &FindKuaishouProductHandler{
  16. req: http_model.NewFindKuaishouProductRequest(),
  17. resp: http_model.NewFindKuaishouProductResponse(),
  18. ctx: ctx,
  19. }
  20. }
  21. type FindKuaishouProductHandler struct {
  22. req *http_model.FindKuaishouProductRequest
  23. resp *http_model.CommonResponse
  24. ctx *gin.Context
  25. }
  26. func (h *FindKuaishouProductHandler) getRequest() interface{} {
  27. return h.req
  28. }
  29. func (h *FindKuaishouProductHandler) getContext() *gin.Context {
  30. return h.ctx
  31. }
  32. func (h *FindKuaishouProductHandler) getResponse() interface{} {
  33. return h.resp
  34. }
  35. func (h *FindKuaishouProductHandler) run() {
  36. data := *&http_model.FindKuaishouProductRequest{}
  37. data = *h.req
  38. // print("data: ", data.ItemList)
  39. res, err := service.Product.QueryKuaishouProduct(h.ctx, data)
  40. if err != nil {
  41. logrus.WithContext(h.ctx).Errorf("[FindKuaishouProductHandler] error FindKuaishouProductHandler, err:%+v", err)
  42. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, consts.DefaultToast)
  43. return
  44. }
  45. h.resp.Status = 20000
  46. h.resp.Message = "成功查询"
  47. h.resp.Data = res
  48. }
  49. func (h *FindKuaishouProductHandler) checkParam() error {
  50. return nil
  51. }