sketch_photo.go 1.4 KB

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