sketch_info.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. // WrapGetSketchInfoHandler
  12. func WrapGetSketchInfoHandler(ctx *gin.Context) {
  13. handler := newGetSketchInfoHandler(ctx)
  14. baseRun(handler)
  15. }
  16. func newGetSketchInfoHandler(ctx *gin.Context) *GetSketchInfoHandler {
  17. return &GetSketchInfoHandler{
  18. req: http_model.NewGetSketchInfoRequest(),
  19. resp: http_model.NewGetSketchInfoResponse(),
  20. ctx: ctx,
  21. }
  22. }
  23. type GetSketchInfoHandler struct {
  24. req *http_model.GetSketchInfoRequest
  25. resp *http_model.CommonResponse
  26. ctx *gin.Context
  27. }
  28. func (h *GetSketchInfoHandler) getRequest() interface{} {
  29. return h.req
  30. }
  31. func (h *GetSketchInfoHandler) getContext() *gin.Context {
  32. return h.ctx
  33. }
  34. func (h *GetSketchInfoHandler) getResponse() interface{} {
  35. return h.resp
  36. }
  37. func (h *GetSketchInfoHandler) run() {
  38. data := *&http_model.GetSketchInfoRequest{}
  39. data = *h.req
  40. res, err := service.Sketch.GetSketchInfo(h.ctx, data)
  41. if err != nil {
  42. // 数据库查询失败,返回5001
  43. logrus.Errorf("[GetSketchInfoHandler] call GetByID err:%+v\n", err)
  44. util.HandlerPackErrorResp(h.resp, consts.ErrorParamCheck, "")
  45. log.Info("GetProduct fail,req:%+v", h.req)
  46. return
  47. }
  48. h.resp.Data = res
  49. h.resp.Status = consts.ErrorSuccess
  50. }
  51. func (h *GetSketchInfoHandler) checkParam() error {
  52. return nil
  53. }