forked from ebhomengo/niki
fix(benefactor): fix getting benefactor kind box request by id
This commit is contained in:
parent
8521cdbf20
commit
d405c01b7b
|
@ -28,5 +28,5 @@ func (h Handler) Get(c echo.Context) error {
|
||||||
return echo.NewHTTPError(code, msg)
|
return echo.NewHTTPError(code, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(http.StatusCreated, resp)
|
return c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,11 @@ import (
|
||||||
func (h Handler) SetRoutes(e *echo.Echo) {
|
func (h Handler) SetRoutes(e *echo.Echo) {
|
||||||
r := e.Group("/benefactor/kindboxreqs")
|
r := e.Group("/benefactor/kindboxreqs")
|
||||||
|
|
||||||
r.POST("/", h.Add, middleware.Auth(h.authSvc, h.authConfig),
|
r.Use(
|
||||||
middleware.BenefactorAuthorization(entity.UserBenefactorRole))
|
middleware.Auth(h.authSvc, h.authConfig),
|
||||||
|
middleware.BenefactorAuthorization(entity.UserBenefactorRole),
|
||||||
|
)
|
||||||
|
|
||||||
|
r.POST("/", h.Add)
|
||||||
r.GET("/:id", h.Get)
|
r.GET("/:id", h.Get)
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,10 @@ func (d DB) GetKindBoxReqByID(ctx context.Context, kindBoxReqID, benefactorID ui
|
||||||
)
|
)
|
||||||
k, err := scanKindBoxReq(row)
|
k, err := scanKindBoxReq(row)
|
||||||
if err != nil {
|
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).
|
return entity.KindBoxReq{}, richerror.New(op).WithErr(err).
|
||||||
WithMessage(errmsg.ErrorMsgCantScanQueryResult).WithKind(richerror.KindUnexpected)
|
WithMessage(errmsg.ErrorMsgCantScanQueryResult).WithKind(richerror.KindUnexpected)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
kindBoxReq, err := s.repo.GetKindBoxReqByID(ctx, req.KindBoxReqID, req.BenefactorID)
|
||||||
if err != nil {
|
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
|
return param.KindBoxReqGetResponse{KindBoxReq: kindBoxReq}, nil
|
||||||
|
|
Loading…
Reference in New Issue