find_kuaishou_product.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. h.resp.Message = err.Error()
  44. return
  45. }
  46. h.resp.Status = 20000
  47. h.resp.Message = "成功查询"
  48. h.resp.Data = res
  49. }
  50. func (h *FindKuaishouProductHandler) checkParam() error {
  51. return nil
  52. }