diff --git a/delivery/http_server/benefactor/kind_box_req/get.go b/delivery/http_server/benefactor/kind_box_req/get.go index 7622514..fe858de 100644 --- a/delivery/http_server/benefactor/kind_box_req/get.go +++ b/delivery/http_server/benefactor/kind_box_req/get.go @@ -28,5 +28,5 @@ func (h Handler) Get(c echo.Context) error { return echo.NewHTTPError(code, msg) } - return c.JSON(http.StatusCreated, resp) + return c.JSON(http.StatusOK, resp) } diff --git a/delivery/http_server/benefactor/kind_box_req/route.go b/delivery/http_server/benefactor/kind_box_req/route.go index 8f1e789..e8aa613 100644 --- a/delivery/http_server/benefactor/kind_box_req/route.go +++ b/delivery/http_server/benefactor/kind_box_req/route.go @@ -9,8 +9,11 @@ import ( func (h Handler) SetRoutes(e *echo.Echo) { r := e.Group("/benefactor/kindboxreqs") - r.POST("/", h.Add, middleware.Auth(h.authSvc, h.authConfig), - middleware.BenefactorAuthorization(entity.UserBenefactorRole)) + r.Use( + middleware.Auth(h.authSvc, h.authConfig), + middleware.BenefactorAuthorization(entity.UserBenefactorRole), + ) + r.POST("/", h.Add) r.GET("/:id", h.Get) } diff --git a/repository/mysql/kind_box_req/kind_box_req.go b/repository/mysql/kind_box_req/kind_box_req.go index a8cc358..8c33403 100644 --- a/repository/mysql/kind_box_req/kind_box_req.go +++ b/repository/mysql/kind_box_req/kind_box_req.go @@ -98,6 +98,10 @@ func (d DB) GetKindBoxReqByID(ctx context.Context, kindBoxReqID, benefactorID ui ) k, err := scanKindBoxReq(row) if err != nil { + if err == sql.ErrNoRows { + return entity.KindBoxReq{}, richerror.New(op).WithErr(err). + WithMessage(errmsg.ErrorMsgNotFound).WithKind(richerror.KindNotFound) + } return entity.KindBoxReq{}, richerror.New(op).WithErr(err). WithMessage(errmsg.ErrorMsgCantScanQueryResult).WithKind(richerror.KindUnexpected) } diff --git a/service/benefactor/kind_box_req/get.go b/service/benefactor/kind_box_req/get.go index 253fd88..c4a33ac 100644 --- a/service/benefactor/kind_box_req/get.go +++ b/service/benefactor/kind_box_req/get.go @@ -12,7 +12,7 @@ func (s Service) Get(ctx context.Context, req param.KindBoxReqGetRequest) (param kindBoxReq, err := s.repo.GetKindBoxReqByID(ctx, req.KindBoxReqID, req.BenefactorID) if err != nil { - return param.KindBoxReqGetResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) + return param.KindBoxReqGetResponse{}, richerror.New(op).WithErr(err) } return param.KindBoxReqGetResponse{KindBoxReq: kindBoxReq}, nil