store_find.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package handler
  2. import (
  3. "youngee_b_api/consts"
  4. "youngee_b_api/model/http_model"
  5. "youngee_b_api/service"
  6. "youngee_b_api/util"
  7. "github.com/gin-gonic/gin"
  8. "github.com/sirupsen/logrus"
  9. log "github.com/sirupsen/logrus"
  10. )
  11. func WrapFindStoreHandler(ctx *gin.Context) {
  12. handler := newFindStoreHandler(ctx)
  13. baseRun(handler)
  14. }
  15. func newFindStoreHandler(ctx *gin.Context) *FindStoreHandler {
  16. return &FindStoreHandler{
  17. req: http_model.NewFindStoreRequest(),
  18. resp: http_model.NewFindStoreResponse(),
  19. ctx: ctx,
  20. }
  21. }
  22. type FindStoreHandler struct {
  23. req *http_model.FindStoreRequest
  24. resp *http_model.CommonResponse
  25. ctx *gin.Context
  26. }
  27. func (h *FindStoreHandler) getRequest() interface{} {
  28. return h.req
  29. }
  30. func (h *FindStoreHandler) getContext() *gin.Context {
  31. return h.ctx
  32. }
  33. func (h *FindStoreHandler) getResponse() interface{} {
  34. return h.resp
  35. }
  36. func (h *FindStoreHandler) run() {
  37. res, err := service.LocalLife.GetStoreInfo(h.ctx, h.req)
  38. if err != nil {
  39. // 数据库查询失败,返回5001
  40. logrus.Errorf("[FindStoreHandler] call FindByID err:%+v\n", err)
  41. util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
  42. log.Info("FindStore fail,req:%+v", h.req)
  43. return
  44. }
  45. h.resp.Data = res
  46. }
  47. func (h *FindStoreHandler) checkParam() error {
  48. return nil
  49. }