From ed5c1650407bd76acd449f6ece124de8abd413b7 Mon Sep 17 00:00:00 2001 From: Abolfazl Nourzad Date: Fri, 26 Jan 2024 09:32:25 +0330 Subject: [PATCH] Deleting the commented codes --- delivery/http_server/admin/kind_box/add.go | 23 ----- delivery/http_server/admin/kind_box/get.go | 31 ------ .../http_server/admin/kind_box/get_all.go | 25 ----- delivery/http_server/admin/kind_box/route.go | 5 - delivery/http_server/admin/kind_box/update.go | 31 ------ .../http_server/admin/kind_box_req/add.go | 31 ------ .../http_server/admin/kind_box_req/get.go | 23 ----- .../http_server/admin/kind_box_req/get_all.go | 24 ----- .../http_server/admin/kind_box_req/route.go | 6 -- .../http_server/admin/kind_box_req/update.go | 31 ------ .../benefactor/kind_box_req/get.go | 23 ----- .../benefactor/kind_box_req/get_all.go | 16 ---- .../benefactor/kind_box_req/route.go | 4 - .../benefactor/kind_box_req/update.go | 23 ----- repository/mysql/kind_box_req/kind_box_req.go | 1 + service/admin/kind_box/delete.go | 19 ---- service/admin/kind_box/get.go | 18 ---- service/admin/kind_box/get_all.go | 17 ---- service/admin/kind_box/service.go | 9 -- service/admin/kind_box/update.go | 28 ------ service/admin/kind_box_req/add.go | 16 ---- service/admin/kind_box_req/delete.go | 20 ---- service/admin/kind_box_req/get.go | 20 ---- service/admin/kind_box_req/get_all.go | 20 ---- service/admin/kind_box_req/service.go | 6 -- service/admin/kind_box_req/update.go | 28 ------ service/benefactor/kind_box_req/delete.go | 12 --- service/benefactor/kind_box_req/get.go | 11 --- service/benefactor/kind_box_req/get_all.go | 12 --- service/benefactor/kind_box_req/service.go | 5 - service/benefactor/kind_box_req/update.go | 17 ---- validator/admin/kind_box/add.go | 38 -------- validator/admin/kind_box/delete.go | 44 --------- validator/admin/kind_box/get.go | 43 --------- validator/admin/kind_box/update.go | 58 ------------ validator/admin/kind_box/validator.go | 94 ------------------- validator/admin/kind_box_req/add.go | 45 --------- validator/admin/kind_box_req/delete.go | 44 --------- validator/admin/kind_box_req/get.go | 43 --------- validator/admin/kind_box_req/update.go | 49 ---------- validator/admin/kind_box_req/validator.go | 58 ------------ 41 files changed, 1 insertion(+), 1070 deletions(-) diff --git a/delivery/http_server/admin/kind_box/add.go b/delivery/http_server/admin/kind_box/add.go index fce2ac8..3cc696d 100644 --- a/delivery/http_server/admin/kind_box/add.go +++ b/delivery/http_server/admin/kind_box/add.go @@ -1,24 +1 @@ package adminkindboxhandler - -// func (h Handler) Add(c echo.Context) error { -// var req param.KindBoxAddRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.adminKindBoxVld.ValidateAddRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.adminKindBoxSvc.Add(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box/get.go b/delivery/http_server/admin/kind_box/get.go index 1ff0ff5..3cc696d 100644 --- a/delivery/http_server/admin/kind_box/get.go +++ b/delivery/http_server/admin/kind_box/get.go @@ -1,32 +1 @@ package adminkindboxhandler - -// import ( -// "net/http" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" -// echo "github.com/labstack/echo/v4" -//) -// -// func (h Handler) Get(c echo.Context) error { -// var req param.KindBoxGetRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.adminKindBoxVld.ValidateGetRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.adminKindBoxSvc.Get(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box/get_all.go b/delivery/http_server/admin/kind_box/get_all.go index c39e2a2..3cc696d 100644 --- a/delivery/http_server/admin/kind_box/get_all.go +++ b/delivery/http_server/admin/kind_box/get_all.go @@ -1,26 +1 @@ package adminkindboxhandler - -// -// import ( -// "net/http" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" -// echo "github.com/labstack/echo/v4" -//) -// -// func (h Handler) GetAll(c echo.Context) error { -// var req param.KindBoxGetAllRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// -// resp, sErr := h.adminKindBoxSvc.GetAll(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box/route.go b/delivery/http_server/admin/kind_box/route.go index 72d97ce..ef9bd24 100644 --- a/delivery/http_server/admin/kind_box/route.go +++ b/delivery/http_server/admin/kind_box/route.go @@ -5,9 +5,4 @@ import ( ) func (h Handler) SetRoutes(_ *echo.Echo) { - //nolint - // r.POST("/", h.Add).Name = "admin-addkindbox" - // r.GET("/:id", h.Get).Name = "admin-getkindboxbyid" - // r.GET("/", h.GetAll).Name = "admin-getallkindbox" - // r.PATCH("/:id", h.Update).Name = "admin-updatekindbox" } diff --git a/delivery/http_server/admin/kind_box/update.go b/delivery/http_server/admin/kind_box/update.go index e52ad0a..3cc696d 100644 --- a/delivery/http_server/admin/kind_box/update.go +++ b/delivery/http_server/admin/kind_box/update.go @@ -1,32 +1 @@ package adminkindboxhandler - -// import ( -// "net/http" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" -// echo "github.com/labstack/echo/v4" -//) -// -// func (h Handler) Update(c echo.Context) error { -// var req param.KindBoxUpdateRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.adminKindBoxVld.ValidateUpdateRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.adminKindBoxSvc.Update(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box_req/add.go b/delivery/http_server/admin/kind_box_req/add.go index faacba5..b5635e7 100644 --- a/delivery/http_server/admin/kind_box_req/add.go +++ b/delivery/http_server/admin/kind_box_req/add.go @@ -1,32 +1 @@ package adminkindboxreqhandler - -// import ( -// "net/http" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" -// echo "github.com/labstack/echo/v4" -//) -// -// func (h Handler) Add(c echo.Context) error { -// var req param.KindBoxReqAddRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.adminKindBoxReqVld.ValidateAddRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.adminKindBoxReqSvc.Add(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box_req/get.go b/delivery/http_server/admin/kind_box_req/get.go index fa66c9a..b5635e7 100644 --- a/delivery/http_server/admin/kind_box_req/get.go +++ b/delivery/http_server/admin/kind_box_req/get.go @@ -1,24 +1 @@ package adminkindboxreqhandler - -// func (h Handler) Get(c echo.Context) error { -// var req param.KindBoxReqGetRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.adminKindBoxReqVld.ValidateGetRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.adminKindBoxReqSvc.Get(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box_req/get_all.go b/delivery/http_server/admin/kind_box_req/get_all.go index 241e186..b5635e7 100644 --- a/delivery/http_server/admin/kind_box_req/get_all.go +++ b/delivery/http_server/admin/kind_box_req/get_all.go @@ -1,25 +1 @@ package adminkindboxreqhandler - -// import ( -// "net/http" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" -// echo "github.com/labstack/echo/v4" -//) -// -// func (h Handler) GetAll(c echo.Context) error { -// var req param.KindBoxReqGetAllRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// -// resp, sErr := h.adminKindBoxReqSvc.GetAll(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/admin/kind_box_req/route.go b/delivery/http_server/admin/kind_box_req/route.go index 578dd01..a751fea 100644 --- a/delivery/http_server/admin/kind_box_req/route.go +++ b/delivery/http_server/admin/kind_box_req/route.go @@ -7,12 +7,6 @@ import ( func (h Handler) SetRoutes(e *echo.Echo) { r := e.Group("/admin/kindboxreqs") - //nolint:gocritic - //r.POST("/", h.Add).Name = "admin-addkindboxreq" - //r.GET("/:id", h.Get).Name = "admin-getkindboxreqbyid" - //r.GET("/", h.GetAll).Name = "admin-getallkindboxreq" - //nolint:gocritic - //r.PATCH("/:id", h.Update).Name = "admin-updatekindboxreq" // todo - add acl r.PATCH("/accept-kind-box-req/:id", h.Accept) r.PATCH("/reject-kind-box-req/:id", h.Reject) diff --git a/delivery/http_server/admin/kind_box_req/update.go b/delivery/http_server/admin/kind_box_req/update.go index 5e6b2c6..b5635e7 100644 --- a/delivery/http_server/admin/kind_box_req/update.go +++ b/delivery/http_server/admin/kind_box_req/update.go @@ -1,32 +1 @@ package adminkindboxreqhandler - -// import ( -// "net/http" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" -// echo "github.com/labstack/echo/v4" -//) -// -// func (h Handler) Update(c echo.Context) error { -// var req param.KindBoxReqUpdateRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.adminKindBoxReqVld.ValidateUpdateRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.adminKindBoxReqSvc.Update(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/benefactor/kind_box_req/get.go b/delivery/http_server/benefactor/kind_box_req/get.go index 113e576..9ea2099 100644 --- a/delivery/http_server/benefactor/kind_box_req/get.go +++ b/delivery/http_server/benefactor/kind_box_req/get.go @@ -1,24 +1 @@ package benefactorkindboxreqhandler - -// func (h Handler) Get(c echo.Context) error { -// var req param.KindBoxReqGetRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateGetRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.benefactorKindBoxReqSvc.Get(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/benefactor/kind_box_req/get_all.go b/delivery/http_server/benefactor/kind_box_req/get_all.go index b06f9d8..9ea2099 100644 --- a/delivery/http_server/benefactor/kind_box_req/get_all.go +++ b/delivery/http_server/benefactor/kind_box_req/get_all.go @@ -1,17 +1 @@ package benefactorkindboxreqhandler - -// func (h Handler) GetAll(c echo.Context) error { -// var req param.KindBoxReqGetAllRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// -// resp, sErr := h.benefactorKindBoxReqSvc.GetAll(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/delivery/http_server/benefactor/kind_box_req/route.go b/delivery/http_server/benefactor/kind_box_req/route.go index a5b9b08..a4d2b0e 100644 --- a/delivery/http_server/benefactor/kind_box_req/route.go +++ b/delivery/http_server/benefactor/kind_box_req/route.go @@ -11,8 +11,4 @@ func (h Handler) SetRoutes(e *echo.Echo) { r.POST("/", h.Add, middleware.Auth(h.authSvc, h.authConfig), middleware.BenefactorAuthorization(entity.UserBenefactorRole)) - //nolint:gocritic - // r.GET("/:id", h.Get) - // r.GET("/", h.GetAll) - // r.PATCH("/:id", h.Update) } diff --git a/delivery/http_server/benefactor/kind_box_req/update.go b/delivery/http_server/benefactor/kind_box_req/update.go index 0ae0f40..9ea2099 100644 --- a/delivery/http_server/benefactor/kind_box_req/update.go +++ b/delivery/http_server/benefactor/kind_box_req/update.go @@ -1,24 +1 @@ package benefactorkindboxreqhandler - -// func (h Handler) Update(c echo.Context) error { -// var req param.KindBoxReqUpdateRequest -// if bErr := c.Bind(&req); bErr != nil { -// return echo.NewHTTPError(http.StatusBadRequest) -// } -// if fieldErrors, err := h.benefactorKindBoxReqVld.ValidateUpdateRequest(req); err != nil { -// msg, code := httpmsg.Error(err) -// -// return c.JSON(code, echo.Map{ -// "message": msg, -// "errors": fieldErrors, -// }) -// } -// resp, sErr := h.benefactorKindBoxReqSvc.Update(c.Request().Context(), req) -// if sErr != nil { -// msg, code := httpmsg.Error(sErr) -// -// return echo.NewHTTPError(code, msg) -// } -// -// return c.JSON(http.StatusCreated, resp) -//} diff --git a/repository/mysql/kind_box_req/kind_box_req.go b/repository/mysql/kind_box_req/kind_box_req.go index 9dcc0b1..7605809 100644 --- a/repository/mysql/kind_box_req/kind_box_req.go +++ b/repository/mysql/kind_box_req/kind_box_req.go @@ -4,6 +4,7 @@ import ( "context" "database/sql" "errors" + "git.gocasts.ir/ebhomengo/niki/entity" errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" diff --git a/service/admin/kind_box/delete.go b/service/admin/kind_box/delete.go index 316d7c2..9b0bb5d 100644 --- a/service/admin/kind_box/delete.go +++ b/service/admin/kind_box/delete.go @@ -1,20 +1 @@ package adminkindboxservice - -// import ( -// "context" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) Delete(ctx context.Context, req param.KindBoxDeleteRequest) (param.KindBoxDeleteResponse, error) { -// // TODO: Does business domain need to delete an kindbox ? -// const op = "adminkindboxservice.Delete" -// -// dErr := s.repo.DeleteKindBox(ctx, req.KindBoxID) -// if dErr != nil { -// return param.KindBoxDeleteResponse{}, richerror.New(op).WithErr(dErr).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxDeleteResponse{}, nil -//} diff --git a/service/admin/kind_box/get.go b/service/admin/kind_box/get.go index b86a61a..9b0bb5d 100644 --- a/service/admin/kind_box/get.go +++ b/service/admin/kind_box/get.go @@ -1,19 +1 @@ package adminkindboxservice - -// import ( -// "context" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) Get(ctx context.Context, req param.KindBoxGetRequest) (param.KindBoxGetResponse, error) { -// const op = "adminkindboxservice.Get" -// -// kindBox, err := s.repo.GetKindBox(ctx, req.KindBoxID) -// if err != nil { -// return param.KindBoxGetResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxGetResponse{KindBox: kindBox}, nil -//} diff --git a/service/admin/kind_box/get_all.go b/service/admin/kind_box/get_all.go index 6f0cdc4..9b0bb5d 100644 --- a/service/admin/kind_box/get_all.go +++ b/service/admin/kind_box/get_all.go @@ -1,18 +1 @@ package adminkindboxservice - -// import ( -// "context" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) GetAll(ctx context.Context, _ param.KindBoxGetAllRequest) (param.KindBoxGetAllResponse, error) { -// const op = "adminkindboxservice.GetAll" -// allKindBox, err := s.repo.GetAllKindBox(ctx) -// if err != nil { -// return param.KindBoxGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxGetAllResponse{AllKindBox: allKindBox}, nil -//} diff --git a/service/admin/kind_box/service.go b/service/admin/kind_box/service.go index c11956a..0b072e4 100644 --- a/service/admin/kind_box/service.go +++ b/service/admin/kind_box/service.go @@ -8,21 +8,12 @@ import ( type Repository interface { AddBatchKindBox(ctx context.Context, kindBoxes []entity.KindBox) ([]entity.KindBox, error) - // UpdateKindBox(ctx context.Context, kindBoxID uint, kindBoxInput entity.KindBox) (entity.KindBox, error) - // DeleteKindBox(ctx context.Context, kindBoxID uint) error - // GetAllKindBox(ctx context.Context) ([]entity.KindBox, error) - // GetKindBox(ctx context.Context, kindBox uint) (entity.KindBox, error) } type Service struct { repo Repository } -// TODO: check validation. -// type BenefactorService interface { -// IsBenefactorExist(ctx context.Context, benefactorID uint) (bool, error) -// } - func New(repository Repository) Service { return Service{ repo: repository, diff --git a/service/admin/kind_box/update.go b/service/admin/kind_box/update.go index 1a21d1a..9b0bb5d 100644 --- a/service/admin/kind_box/update.go +++ b/service/admin/kind_box/update.go @@ -1,29 +1 @@ package adminkindboxservice - -// import ( -// "context" -// -// entity "git.gocasts.ir/ebhomengo/niki/entity" -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) Update(ctx context.Context, req param.KindBoxUpdateRequest) (param.KindBoxUpdateResponse, error) { -// // TODO: can benefactor update its Request ? -// // TODO: Is Update Mothod Service Responsible to check which kindboxreqID belongs to benefactorID ? -// // TODO: updating data(s) may have side-effect on other entities by masood-keshvary accepted -> rejected -// const op = "adminkindboxservice.Update" -// -// kindBox, uErr := s.repo.UpdateKindBox(ctx, req.KindBoxID, entity.KindBox{ -// TotalAmount: req.TotalAmount, -// ReceiverID: req.ReceiverID, -// SenderID: req.SenderID, -// SerialNumber: req.SerialNumber, -// Status: req.Status, -// }) -// if uErr != nil { -// return param.KindBoxUpdateResponse{}, richerror.New(op).WithErr(uErr).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxUpdateResponse{KindBox: kindBox}, nil -//} diff --git a/service/admin/kind_box_req/add.go b/service/admin/kind_box_req/add.go index f50fce1..475ca43 100644 --- a/service/admin/kind_box_req/add.go +++ b/service/admin/kind_box_req/add.go @@ -1,17 +1 @@ package adminkindboxreqservice - -// func (s Service) Add(ctx context.Context, req param.KindBoxReqAddRequest) (param.KindBoxReqAddResponse, error) { -// const op = "adminkindboxreqservice.Add" -// -// kindBoxReq, err := s.repo.AddKindBoxReq(ctx, entity.KindBoxReq{ -// BenefactorID: req.BenefactorID, -// KindBoxType: req.TypeID, -// CountRequested: req.CountRequested, -// Status: entity.KindBoxReqPendingStatus, -// }) -// if err != nil { -// return param.KindBoxReqAddResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqAddResponse{KindBoxReq: kindBoxReq}, nil -//} diff --git a/service/admin/kind_box_req/delete.go b/service/admin/kind_box_req/delete.go index bf7481e..475ca43 100644 --- a/service/admin/kind_box_req/delete.go +++ b/service/admin/kind_box_req/delete.go @@ -1,21 +1 @@ package adminkindboxreqservice - -// -// import ( -// "context" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) Delete(ctx context.Context, req param.KindBoxReqDeleteRequest) (param.KindBoxReqDeleteResponse, error) { -// // TODO: Does business domain need to delete an kindboxreq ? -// const op = "adminkindboxreqservice.Delete" -// -// dErr := s.repo.DeleteKindBoxReq(ctx, req.KindBoxReqID) -// if dErr != nil { -// return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(dErr).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqDeleteResponse{}, nil -//} diff --git a/service/admin/kind_box_req/get.go b/service/admin/kind_box_req/get.go index f79f458..475ca43 100644 --- a/service/admin/kind_box_req/get.go +++ b/service/admin/kind_box_req/get.go @@ -1,21 +1 @@ package adminkindboxreqservice - -// -// import ( -// "context" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) Get(ctx context.Context, req param.KindBoxReqGetRequest) (param.KindBoxReqGetResponse, error) { -// const op = "adminkindboxreqservice.Get" -// -// // TODO : ref to service.Update() -// kindBoxReq, err := s.repo.GetKindBoxReq(ctx, req.KindBoxReqID) -// if err != nil { -// return param.KindBoxReqGetResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqGetResponse{KindBoxReq: kindBoxReq}, nil -//} diff --git a/service/admin/kind_box_req/get_all.go b/service/admin/kind_box_req/get_all.go index f16af1b..475ca43 100644 --- a/service/admin/kind_box_req/get_all.go +++ b/service/admin/kind_box_req/get_all.go @@ -1,21 +1 @@ package adminkindboxreqservice - -// -// import ( -// "context" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -//// TODO: Pagination, Filters, Sort. -// func (s Service) GetAll(ctx context.Context, _ param.KindBoxReqGetAllRequest) (param.KindBoxReqGetAllResponse, error) { -// const op = "adminkindboxreqservice.GetAll" -// -// allKindBoxReq, err := s.repo.GetAllKindBoxReq(ctx) -// if err != nil { -// return param.KindBoxReqGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqGetAllResponse{AllKindBoxReq: allKindBoxReq}, nil -//} diff --git a/service/admin/kind_box_req/service.go b/service/admin/kind_box_req/service.go index 10b1788..d419e49 100644 --- a/service/admin/kind_box_req/service.go +++ b/service/admin/kind_box_req/service.go @@ -8,12 +8,6 @@ import ( ) type Repository interface { - // AddKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error) - // UpdateKindBoxReq(ctx context.Context, kindBoxReqID uint, kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error) - // TODO: can benefactor cancel its request ? - // DeleteKindBoxReq(ctx context.Context, kindBoxReqID uint) error - // GetAllKindBoxReq(ctx context.Context) ([]entity.KindBoxReq, error) - // GetKindBoxReq(ctx context.Context, kindBoxReqID uint) (entity.KindBoxReq, error) AcceptKindBoxReq(ctx context.Context, kindBoxReqID uint, countAccepted uint) error GetByID(ctx context.Context, id uint) (entity.KindBoxReq, error) RejectKindBoxReq(ctx context.Context, kindBoxReqID uint, description string) error diff --git a/service/admin/kind_box_req/update.go b/service/admin/kind_box_req/update.go index 72f6998..475ca43 100644 --- a/service/admin/kind_box_req/update.go +++ b/service/admin/kind_box_req/update.go @@ -1,29 +1 @@ package adminkindboxreqservice - -// -// import ( -// "context" -// -// entity "git.gocasts.ir/ebhomengo/niki/entity" -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -//) -// -// func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) (param.KindBoxReqUpdateResponse, error) { -// // TODO: can benefactor update its request ? -// // TODO: Is Update Mothod Service Responsible to check which kindboxreqID belongs to benefactorID ? -// // TODO: updating data(s) may have side-effect on other entities by masood-keshvary accepted -> rejected -// -// const op = "adminkindboxreqservice.Update" -// -// kindBoxReq, uErr := s.repo.UpdateKindBoxReq(ctx, req.KindBoxReqID, entity.KindBoxReq{ -// BenefactorID: req.BenefactorID, -// TypeID: req.TypeID, -// CountRequested: req.CountRequested, -// }) -// if uErr != nil { -// return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(uErr).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqUpdateResponse{KindBoxReq: kindBoxReq}, nil -//} diff --git a/service/benefactor/kind_box_req/delete.go b/service/benefactor/kind_box_req/delete.go index 506f8ad..cf248cf 100644 --- a/service/benefactor/kind_box_req/delete.go +++ b/service/benefactor/kind_box_req/delete.go @@ -1,13 +1 @@ package benefactorkindboxreqservice - -// func (s Service) Delete(ctx context.Context, req param.KindBoxReqDeleteRequest) (param.KindBoxReqDeleteResponse, error) { -// // TODO: Does business domain need to delete an kindboxreq ? -// const op = "userkindboxreqservice.Delete" -// -// dErr := s.repo.DeleteKindBoxReq(ctx, req.KindBoxReqID) -// if dErr != nil { -// return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(dErr).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqDeleteResponse{}, nil -//} diff --git a/service/benefactor/kind_box_req/get.go b/service/benefactor/kind_box_req/get.go index ce50932..cf248cf 100644 --- a/service/benefactor/kind_box_req/get.go +++ b/service/benefactor/kind_box_req/get.go @@ -1,12 +1 @@ package benefactorkindboxreqservice - -// func (s Service) Get(ctx context.Context, req param.KindBoxReqGetRequest) (param.KindBoxReqGetResponse, error) { -// const op = "userkindboxreqservice.Get" -// -// kindBoxReq, err := s.repo.GetKindBoxReq(ctx, req.KindBoxReqID) -// if err != nil { -// return param.KindBoxReqGetResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqGetResponse{KindBoxReq: kindBoxReq}, nil -//} diff --git a/service/benefactor/kind_box_req/get_all.go b/service/benefactor/kind_box_req/get_all.go index fbaf2ba..cf248cf 100644 --- a/service/benefactor/kind_box_req/get_all.go +++ b/service/benefactor/kind_box_req/get_all.go @@ -1,13 +1 @@ package benefactorkindboxreqservice - -//// TODO: Pagination, Filters, Sort. -// func (s Service) GetAll(ctx context.Context, req param.KindBoxReqGetAllRequest) (param.KindBoxReqGetAllResponse, error) { -// const op = "userkindboxreqservice.GetAll" -// -// allKindBoxReq, err := s.repo.GetAllKindBoxReq(ctx, req.BenefactorID) -// if err != nil { -// return param.KindBoxReqGetAllResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqGetAllResponse{AllKindBoxReq: allKindBoxReq}, nil -//} diff --git a/service/benefactor/kind_box_req/service.go b/service/benefactor/kind_box_req/service.go index 1bd63de..1b336f2 100644 --- a/service/benefactor/kind_box_req/service.go +++ b/service/benefactor/kind_box_req/service.go @@ -8,11 +8,6 @@ import ( type Repository interface { AddKindBoxReq(ctx context.Context, kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error) - // UpdateKindBoxReq(ctx context.Context, kindBoxReqID uint, kindBoxReq entity.KindBoxReq) (entity.KindBoxReq, error) - // TODO: can benefactor cancel its request ? - // DeleteKindBoxReq(ctx context.Context, kindBoxReqID uint) error - // GetAllKindBoxReq(ctx context.Context, benefactorID uint) ([]entity.KindBoxReq, error) - // GetKindBoxReq(ctx context.Context, kindBoxReqID uint) (entity.KindBoxReq, error) } type Service struct { diff --git a/service/benefactor/kind_box_req/update.go b/service/benefactor/kind_box_req/update.go index ba84bc3..cf248cf 100644 --- a/service/benefactor/kind_box_req/update.go +++ b/service/benefactor/kind_box_req/update.go @@ -1,18 +1 @@ package benefactorkindboxreqservice - -// func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) (param.KindBoxReqUpdateResponse, error) { -// // TODO: can benefactor update its request ? -// // TODO: Is Update Mothod Service Responsible to check which kindboxreqID belongs to benefactorID ? -// const op = "userkindboxreqservice.Update" -// -// kindBoxReq, uErr := s.repo.UpdateKindBoxReq(ctx, req.KindBoxReqID, entity.KindBoxReq{ -// BenefactorID: req.BenefactorID, -// KindBoxType: req.TypeID, -// CountRequested: req.CountRequested, -// }) -// if uErr != nil { -// return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(uErr).WithKind(richerror.KindUnexpected) -// } -// -// return param.KindBoxReqUpdateResponse{KindBoxReq: kindBoxReq}, nil -//} diff --git a/validator/admin/kind_box/add.go b/validator/admin/kind_box/add.go index 0df010f..7ba0d92 100644 --- a/validator/admin/kind_box/add.go +++ b/validator/admin/kind_box/add.go @@ -1,39 +1 @@ package adminkindboxvalidator - -// func (v Validator) ValidateAddRequest(req param.KindBoxAddRequest) (map[string]string, error) { -// const op = "adminkindboxvalidator.KindBoxAddRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.SerialNumber, validation.Required, is.Alphanumeric), -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.SenderID, -// validation.Required, -// validation.By(v.doesEmployeeExist)), -// -// validation.Field(&req.KindBoxReqID, -// validation.Required, -// validation.By(v.doesKindBoxRequestExist)), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box/delete.go b/validator/admin/kind_box/delete.go index 9c3bf37..7ba0d92 100644 --- a/validator/admin/kind_box/delete.go +++ b/validator/admin/kind_box/delete.go @@ -1,45 +1 @@ package adminkindboxvalidator - -// import ( -// "errors" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateDeleteRequest(req param.KindBoxDeleteRequest) (map[string]string, error) { -// const op = "adminkindboxvalidator.ValidateDeleteRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.KindBoxID, -// validation.Required, -// validation.By(v.hasPendingStatus), -// validation.By(v.doesKindBoxExist), -// validation.By(v.doesKindBoxBelongToBenefactor(req.BenefactorID))), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box/get.go b/validator/admin/kind_box/get.go index 523f026..7ba0d92 100644 --- a/validator/admin/kind_box/get.go +++ b/validator/admin/kind_box/get.go @@ -1,44 +1 @@ package adminkindboxvalidator - -// import ( -// "errors" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateGetRequest(req param.KindBoxGetRequest) (map[string]string, error) { -// const op = "adminkindboxvalidator.ValidateGetRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.KindBoxID, -// validation.Required, -// validation.By(v.doesKindBoxBelongToBenefactor(req.BenefactorID)), -// validation.By(v.doesKindBoxExist)), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box/update.go b/validator/admin/kind_box/update.go index cbf5449..7ba0d92 100644 --- a/validator/admin/kind_box/update.go +++ b/validator/admin/kind_box/update.go @@ -1,59 +1 @@ package adminkindboxvalidator - -// import ( -// "errors" -// -// "git.gocasts.ir/ebhomengo/niki/entity" -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// "github.com/go-ozzo/ozzo-validation/is" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateUpdateRequest(req param.KindBoxUpdateRequest) (map[string]string, error) { -// const op = "adminkindboxvalidator.ValidateUpdateRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.KindBoxID, -// validation.Required, -// validation.By(v.doesKindBoxExist), -// validation.By(v.doesKindBoxBelongToBenefactor(req.BenefactorID))), -// -// validation.Field(&req.SerialNumber, is.Alphanumeric), -// -// validation.Field(&req.TotalAmount, validation.Min(0)), -// -// validation.Field(&req.SenderID, -// validation.By(v.doesEmployeeExist)), -// -// validation.Field(&req.ReceiverID, -// validation.By(v.doesEmployeeExist)), -// -// validation.Field(&req.Status, -// validation.In(entity.AllKindBoxStatus())), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box/validator.go b/validator/admin/kind_box/validator.go index 7d23ca2..b180884 100644 --- a/validator/admin/kind_box/validator.go +++ b/validator/admin/kind_box/validator.go @@ -17,97 +17,3 @@ type Validator struct { func New(repo Repository) Validator { return Validator{repo: repo} } - -// func (v Validator) doesKindBoxRequestExist(value interface{}) error { -// receiverID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.KindBoxRequestExist(receiverID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//} -// -// func (v Validator) doesEmployeeExist(value interface{}) error { -// senderID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.EmployeeExist(senderID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//} -// -// func (v Validator) doesBenefactorExist(value interface{}) error { -// benefactorID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.BenefactorExist(benefactorID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//} -// -// func (v Validator) doesKindBoxExist(value interface{}) error { -// kindboxID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// _, err := v.repo.KindBoxExist(kindboxID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//} -// -// func (v Validator) doesKindBoxBelongToBenefactor(benefactorID uint) validation.RuleFunc { -// return func(value interface{}) error { -// kbID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// _, err := v.repo.KindBoxBelongToBenefactor(benefactorID, kbID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -// } -//} - -// TODO: this temperary to ignore linter error. (unused function) -// func (v Validator) hasCorrectStatus(value interface{}) error { -// status, ok := value.(string) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.CheckStatus(status) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } - -// return nil -// } - -// func (v Validator) hasPendingStatus(value interface{}) error { -// kindboxID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.PendingStatus(kindboxID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//} diff --git a/validator/admin/kind_box_req/add.go b/validator/admin/kind_box_req/add.go index f44c259..7e69606 100644 --- a/validator/admin/kind_box_req/add.go +++ b/validator/admin/kind_box_req/add.go @@ -1,46 +1 @@ package adminkindboxreqvalidator - -// import ( -// "errors" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateAddRequest(req param.KindBoxReqAddRequest) (map[string]string, error) { -// const op = "adminkindboxreqvalidator.ValidateAddRequest" -// -// if err := validation.ValidateStruct(&req, -// -// validation.Field(&req.CountRequested, validation.Required, validation.Min(MinKindBoxReq), validation.Max(MaxKindBoxReq)), -// -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.TypeID, -// validation.Required, -// validation.By(v.doesTypeExist)), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box_req/delete.go b/validator/admin/kind_box_req/delete.go index 72dea66..7e69606 100644 --- a/validator/admin/kind_box_req/delete.go +++ b/validator/admin/kind_box_req/delete.go @@ -1,45 +1 @@ package adminkindboxreqvalidator - -// import ( -// "errors" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateDeleteRequest(req param.KindBoxReqDeleteRequest) (map[string]string, error) { -// const op = "adminkindboxreqvalidator.ValidateDeleteRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.KindBoxReqID, -// validation.Required, -// validation.By(v.hasPendingStatus), -// validation.By(v.doesKindBoxRequestExist), -// validation.By(v.doesKindBoxBelongToBenefactor(req.BenefactorID))), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box_req/get.go b/validator/admin/kind_box_req/get.go index 1ffd8a6..7e69606 100644 --- a/validator/admin/kind_box_req/get.go +++ b/validator/admin/kind_box_req/get.go @@ -1,44 +1 @@ package adminkindboxreqvalidator - -// import ( -// "errors" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateGetRequest(req param.KindBoxReqGetRequest) (map[string]string, error) { -// const op = "adminkindboxreqvalidator.ValidateGetRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.KindBoxReqID, -// validation.Required, -// validation.By(v.doesKindBoxRequestExist), -// validation.By(v.doesKindBoxBelongToBenefactor(req.BenefactorID))), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box_req/update.go b/validator/admin/kind_box_req/update.go index 90ba01f..7e69606 100644 --- a/validator/admin/kind_box_req/update.go +++ b/validator/admin/kind_box_req/update.go @@ -1,50 +1 @@ package adminkindboxreqvalidator - -// import ( -// "errors" -// -// param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" -// errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" -// richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" -// validation "github.com/go-ozzo/ozzo-validation/v4" -//) -// -// func (v Validator) ValidateUpdateRequest(req param.KindBoxReqUpdateRequest) (map[string]string, error) { -// const op = "adminkindboxreqvalidator.ValidateUpdateRequest" -// -// if err := validation.ValidateStruct(&req, -// validation.Field(&req.CountRequested, validation.Min(MinKindBoxReq), validation.Max(MaxKindBoxReq)), -// -// validation.Field(&req.BenefactorID, -// validation.Required, -// validation.By(v.doesBenefactorExist)), -// -// validation.Field(&req.KindBoxReqID, -// validation.Required, -// validation.By(v.doesKindBoxRequestExist), -// validation.By(v.hasPendingStatus), -// validation.By(v.doesKindBoxBelongToBenefactor(req.BenefactorID))), -// -// validation.Field(&req.TypeID, -// validation.By(v.doesTypeExist)), -// ); err != nil { -// fieldErrors := make(map[string]string) -// -// var errV validation.Errors -// if errors.As(err, &errV) { -// for key, value := range errV { -// if value != nil { -// fieldErrors[key] = value.Error() -// } -// } -// } -// -// return fieldErrors, richerror.New(op). -// WithMessage(errmsg.ErrorMsgInvalidInput). -// WithKind(richerror.KindInvalid). -// WithMeta(map[string]interface{}{"req": req}). -// WithErr(err) -// } -// -// return map[string]string{}, nil -//} diff --git a/validator/admin/kind_box_req/validator.go b/validator/admin/kind_box_req/validator.go index 50a2f0d..d9cf678 100644 --- a/validator/admin/kind_box_req/validator.go +++ b/validator/admin/kind_box_req/validator.go @@ -15,11 +15,7 @@ const ( ) type Repository interface { - // BenefactorExist(id int) (bool, error) KindBoxRequestExist(id uint) (bool, error) - // TypeExist(id int) (bool, error) - // KindBoxBelongToBenefactor(benefactorID uint, kindboxID uint) (bool, error) - // PendingStatus(id uint) (bool, error) GetByID(ctx context.Context, id uint) (entity.KindBoxReq, error) } @@ -31,33 +27,6 @@ func New(repo Repository) Validator { return Validator{repo: repo} } -// func (v Validator) doesBenefactorExist(value interface{}) error { -// benefactorID, ok := value.(int) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.BenefactorExist(benefactorID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -// } -// -// func (v Validator) doesKindBoxBelongToBenefactor(benefactorID uint) validation.RuleFunc { -// return func(value interface{}) error { -// kbID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// _, err := v.repo.KindBoxBelongToBenefactor(benefactorID, kbID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -// } -// } func (v Validator) doesKindBoxRequestExist(value interface{}) error { kindboxreqID, ok := value.(uint) if !ok { @@ -106,30 +75,3 @@ func (v Validator) CheckKindBoxReqStatusForRejecting(value interface{}) error { return nil } - -// -// func (v Validator) doesTypeExist(value interface{}) error { -// typeID, ok := value.(int) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.TypeExist(typeID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//} -// -// func (v Validator) hasPendingStatus(value interface{}) error { -// kindboxID, ok := value.(uint) -// if !ok { -// return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) -// } -// _, err := v.repo.PendingStatus(kindboxID) -// if err != nil { -// return fmt.Errorf(errmsg.ErrorMsgNotFound) -// } -// -// return nil -//}