From 7e5f49e63e17e637e13e07957369c064d9db995c Mon Sep 17 00:00:00 2001 From: Iman Mirazimi Date: Tue, 2 Jan 2024 17:34:16 +0330 Subject: [PATCH] feat(niki): add handlers for kind_box and kind_box_req domains --- delivery/http_server/admin/kind_box/add.go | 30 ++++++++++++++++ delivery/http_server/admin/kind_box/get.go | 30 ++++++++++++++++ .../http_server/admin/kind_box/get_all.go | 24 +++++++++++++ .../http_server/admin/kind_box/handler.go | 25 ++++++++++++++ delivery/http_server/admin/kind_box/route.go | 15 ++++++++ delivery/http_server/admin/kind_box/update.go | 30 ++++++++++++++++ .../http_server/admin/kind_box_req/add.go | 30 ++++++++++++++++ .../http_server/admin/kind_box_req/get.go | 30 ++++++++++++++++ .../http_server/admin/kind_box_req/get_all.go | 24 +++++++++++++ .../http_server/admin/kind_box_req/handler.go | 25 ++++++++++++++ .../http_server/admin/kind_box_req/route.go | 15 ++++++++ .../http_server/admin/kind_box_req/update.go | 30 ++++++++++++++++ .../http_server/benefactor/kind_box/add.go | 30 ++++++++++++++++ .../http_server/benefactor/kind_box/get.go | 30 ++++++++++++++++ .../benefactor/kind_box/get_all.go | 24 +++++++++++++ .../benefactor/kind_box/handler.go | 25 ++++++++++++++ .../http_server/benefactor/kind_box/route.go | 15 ++++++++ .../http_server/benefactor/kind_box/update.go | 30 ++++++++++++++++ .../benefactor/kind_box_req/add.go | 30 ++++++++++++++++ .../benefactor/kind_box_req/get.go | 30 ++++++++++++++++ .../benefactor/kind_box_req/get_all.go | 24 +++++++++++++ .../benefactor/kind_box_req/handler.go | 25 ++++++++++++++ .../benefactor/kind_box_req/route.go | 15 ++++++++ .../benefactor/kind_box_req/update.go | 30 ++++++++++++++++ delivery/http_server/health_check.go | 13 +++++++ delivery/http_server/server.go | 25 ++++++++++++-- entity/kind_box.go | 2 +- entity/kind_box_req.go | 2 +- entity/kind_box_req_status.go | 34 +++++++++---------- param/benefactor/kind_box/get.go | 2 +- param/benefactor/kind_box/get_all.go | 2 +- param/benefactor/kind_box_req/add.go | 2 +- param/benefactor/kind_box_req/delete.go | 2 +- param/benefactor/kind_box_req/get.go | 2 +- param/benefactor/kind_box_req/get_all.go | 2 +- param/benefactor/kind_box_req/update.go | 2 +- service/admin/kind_box/get_all.go | 2 +- service/admin/kind_box_req/get_all.go | 2 +- service/benefactor/kind_box/get.go | 2 +- service/benefactor/kind_box/get_all.go | 2 +- service/benefactor/kind_box/service.go | 2 +- service/benefactor/kind_box_req/add.go | 2 +- service/benefactor/kind_box_req/delete.go | 2 +- service/benefactor/kind_box_req/get.go | 2 +- service/benefactor/kind_box_req/get_all.go | 2 +- service/benefactor/kind_box_req/service.go | 2 +- service/benefactor/kind_box_req/update.go | 2 +- validator/admin/kind_box/add.go | 3 +- validator/admin/kind_box/delete.go | 3 +- validator/admin/kind_box/get.go | 3 +- validator/admin/kind_box/update.go | 2 +- validator/admin/kind_box_req/add.go | 3 +- validator/admin/kind_box_req/delete.go | 3 +- validator/admin/kind_box_req/get.go | 3 +- validator/admin/kind_box_req/update.go | 3 +- validator/benefactor/kind_box/get.go | 5 +-- validator/benefactor/kind_box/get_all.go | 5 +-- validator/benefactor/kind_box/validator.go | 2 +- validator/benefactor/kind_box_req/add.go | 5 +-- validator/benefactor/kind_box_req/delete.go | 5 +-- validator/benefactor/kind_box_req/get.go | 4 +-- validator/benefactor/kind_box_req/get_all.go | 5 +-- validator/benefactor/kind_box_req/update.go | 5 +-- .../benefactor/kind_box_req/validator.go | 2 +- 64 files changed, 726 insertions(+), 63 deletions(-) create mode 100644 delivery/http_server/admin/kind_box/add.go create mode 100644 delivery/http_server/admin/kind_box/get.go create mode 100644 delivery/http_server/admin/kind_box/get_all.go create mode 100644 delivery/http_server/admin/kind_box/handler.go create mode 100644 delivery/http_server/admin/kind_box/route.go create mode 100644 delivery/http_server/admin/kind_box/update.go create mode 100644 delivery/http_server/admin/kind_box_req/add.go create mode 100644 delivery/http_server/admin/kind_box_req/get.go create mode 100644 delivery/http_server/admin/kind_box_req/get_all.go create mode 100644 delivery/http_server/admin/kind_box_req/handler.go create mode 100644 delivery/http_server/admin/kind_box_req/route.go create mode 100644 delivery/http_server/admin/kind_box_req/update.go create mode 100644 delivery/http_server/benefactor/kind_box/add.go create mode 100644 delivery/http_server/benefactor/kind_box/get.go create mode 100644 delivery/http_server/benefactor/kind_box/get_all.go create mode 100644 delivery/http_server/benefactor/kind_box/handler.go create mode 100644 delivery/http_server/benefactor/kind_box/route.go create mode 100644 delivery/http_server/benefactor/kind_box/update.go create mode 100644 delivery/http_server/benefactor/kind_box_req/add.go create mode 100644 delivery/http_server/benefactor/kind_box_req/get.go create mode 100644 delivery/http_server/benefactor/kind_box_req/get_all.go create mode 100644 delivery/http_server/benefactor/kind_box_req/handler.go create mode 100644 delivery/http_server/benefactor/kind_box_req/route.go create mode 100644 delivery/http_server/benefactor/kind_box_req/update.go create mode 100644 delivery/http_server/health_check.go diff --git a/delivery/http_server/admin/kind_box/add.go b/delivery/http_server/admin/kind_box/add.go new file mode 100644 index 0000000..df5153a --- /dev/null +++ b/delivery/http_server/admin/kind_box/add.go @@ -0,0 +1,30 @@ +package adminkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + "github.com/labstack/echo/v4" +) + +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.ValidateAdminAddRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.adminKindBoxSvc.Add(c, 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 new file mode 100644 index 0000000..9ab604d --- /dev/null +++ b/delivery/http_server/admin/kind_box/get.go @@ -0,0 +1,30 @@ +package adminkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + "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.ValidateAdminGetRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.adminKindBoxSvc.Get(c, 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 new file mode 100644 index 0000000..c2c9b89 --- /dev/null +++ b/delivery/http_server/admin/kind_box/get_all.go @@ -0,0 +1,24 @@ +package adminkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + "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, 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/handler.go b/delivery/http_server/admin/kind_box/handler.go new file mode 100644 index 0000000..df616d4 --- /dev/null +++ b/delivery/http_server/admin/kind_box/handler.go @@ -0,0 +1,25 @@ +package adminkindboxhandler + +import ( + adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box" + authservice "git.gocasts.ir/ebhomengo/niki/service/auth" + adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box" +) + +type Handler struct { + authConfig authservice.Config + authSvc authservice.Service + adminKindBoxSvc adminkindboxservice.Service + adminKindBoxVld adminkindboxvalidator.Validator +} + +func New(authConfig authservice.Config, authSvc authservice.Service, + adminKindBoxSvc adminkindboxservice.Service, adminKindBoxVld adminkindboxvalidator.Validator, +) Handler { + return Handler{ + authConfig: authConfig, + authSvc: authSvc, + adminKindBoxSvc: adminKindBoxSvc, + adminKindBoxVld: adminKindBoxVld, + } +} diff --git a/delivery/http_server/admin/kind_box/route.go b/delivery/http_server/admin/kind_box/route.go new file mode 100644 index 0000000..48a78fe --- /dev/null +++ b/delivery/http_server/admin/kind_box/route.go @@ -0,0 +1,15 @@ +package adminkindboxhandler + +import ( + "github.com/labstack/echo/v4" +) + +func (h Handler) SetRoutes(e *echo.Echo) { + r := e.Group("/admin/kindboxes") + + 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" + // r.DELETE("/:id",h.Delete).Name = "admin-deletekindbox" +} diff --git a/delivery/http_server/admin/kind_box/update.go b/delivery/http_server/admin/kind_box/update.go new file mode 100644 index 0000000..3642d01 --- /dev/null +++ b/delivery/http_server/admin/kind_box/update.go @@ -0,0 +1,30 @@ +package adminkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + "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.ValidateAdminUpdateRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.adminKindBoxSvc.Update(c, 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 new file mode 100644 index 0000000..20ceef6 --- /dev/null +++ b/delivery/http_server/admin/kind_box_req/add.go @@ -0,0 +1,30 @@ +package adminkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + "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.ValidateAdminAddRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.adminKindBoxReqSvc.Add(c, 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 new file mode 100644 index 0000000..b56e074 --- /dev/null +++ b/delivery/http_server/admin/kind_box_req/get.go @@ -0,0 +1,30 @@ +package adminkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + "github.com/labstack/echo/v4" +) + +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.ValidateAdminGetRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.adminKindBoxReqSvc.Get(c, 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 new file mode 100644 index 0000000..0e62183 --- /dev/null +++ b/delivery/http_server/admin/kind_box_req/get_all.go @@ -0,0 +1,24 @@ +package adminkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + "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, 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/handler.go b/delivery/http_server/admin/kind_box_req/handler.go new file mode 100644 index 0000000..0959709 --- /dev/null +++ b/delivery/http_server/admin/kind_box_req/handler.go @@ -0,0 +1,25 @@ +package adminkindboxreqhandler + +import ( + adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req" + authservice "git.gocasts.ir/ebhomengo/niki/service/auth" + adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req" +) + +type Handler struct { + authConfig authservice.Config + authSvc authservice.Service + adminKindBoxReqSvc adminkindboxreqservice.Service + adminKindBoxReqVld adminkindboxreqvalidator.Validator +} + +func New(authConfig authservice.Config, authSvc authservice.Service, + adminKindBoxReqSvc adminkindboxreqservice.Service, adminKindBoxReqVld adminkindboxvalidator.Validator, +) Handler { + return Handler{ + authConfig: authConfig, + authSvc: authSvc, + adminKindBoxReqSvc: adminKindBoxReqSvc, + adminKindBoxReqVld: adminKindBoxReqVld, + } +} diff --git a/delivery/http_server/admin/kind_box_req/route.go b/delivery/http_server/admin/kind_box_req/route.go new file mode 100644 index 0000000..7b465c0 --- /dev/null +++ b/delivery/http_server/admin/kind_box_req/route.go @@ -0,0 +1,15 @@ +package adminkindboxreqhandler + +import ( + "github.com/labstack/echo/v4" +) + +func (h Handler) SetRoutes(e *echo.Echo) { + r := e.Group("/admin/kindboxreqs") + + r.POST("/").Name = "admin-addkindboxreq" + r.GET("/:id").Name = "admin-getkindboxreqbyid" + r.GET("/").Name = "admin-getallkindboxreq" + r.PUT("/:id").Name = "admin-updatekindboxreq" + // r.DELETE("/:id").Name = "admin-deletekindbox" +} diff --git a/delivery/http_server/admin/kind_box_req/update.go b/delivery/http_server/admin/kind_box_req/update.go new file mode 100644 index 0000000..196b902 --- /dev/null +++ b/delivery/http_server/admin/kind_box_req/update.go @@ -0,0 +1,30 @@ +package adminkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" + "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.ValidateAdminUpdateRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.adminKindBoxReqSvc.Update(c, 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/add.go b/delivery/http_server/benefactor/kind_box/add.go new file mode 100644 index 0000000..8563053 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box/add.go @@ -0,0 +1,30 @@ +package benefactorkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + "github.com/labstack/echo/v4" +) + +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.benefactorKindBoxVld.ValidateBenefactorAddRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.benefactorKindBoxSvc.Add(c, 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/get.go b/delivery/http_server/benefactor/kind_box/get.go new file mode 100644 index 0000000..8631c0b --- /dev/null +++ b/delivery/http_server/benefactor/kind_box/get.go @@ -0,0 +1,30 @@ +package benefactorkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + "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.benefactorKindBoxVld.ValidateBenefactorGetRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.benefactorKindBoxSvc.Get(c, 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/get_all.go b/delivery/http_server/benefactor/kind_box/get_all.go new file mode 100644 index 0000000..b85c5f0 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box/get_all.go @@ -0,0 +1,24 @@ +package benefactorkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + "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.benefactorKindBoxSvc.GetAll(c, 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/handler.go b/delivery/http_server/benefactor/kind_box/handler.go new file mode 100644 index 0000000..0808277 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box/handler.go @@ -0,0 +1,25 @@ +package benefactorkindboxhandler + +import ( + authservice "git.gocasts.ir/ebhomengo/niki/service/auth" + benefactorkindboxservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box" + benefactorkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box" +) + +type Handler struct { + authConfig authservice.Config + authSvc authservice.Service + benefactorKindBoxSvc benefactorkindboxservice.Service + benefactorKindBoxVld benefactorkindboxvalidator.Validator +} + +func New(authConfig authservice.Config, authSvc authservice.Service, + benefactorKindBoxSvc benefactorkindboxservice.Service, benefactorKindBoxVld benefactorkindboxvalidator.Validator, +) Handler { + return Handler{ + authConfig: authConfig, + authSvc: authSvc, + benefactorKindBoxSvc: benefactorKindBoxSvc, + benefactorKindBoxVld: benefactorKindBoxVld, + } +} diff --git a/delivery/http_server/benefactor/kind_box/route.go b/delivery/http_server/benefactor/kind_box/route.go new file mode 100644 index 0000000..c336d9e --- /dev/null +++ b/delivery/http_server/benefactor/kind_box/route.go @@ -0,0 +1,15 @@ +package benefactorkindboxhandler + +import ( + "github.com/labstack/echo/v4" +) + +func (h Handler) SetRoutes(e *echo.Echo) { + r := e.Group("/benefactor/kindboxes") + + r.POST("/").Name = "benefactor-addkindbox" + r.GET("/:id").Name = "benefactor-getkindboxbyid" + r.GET("/").Name = "benefactor-getallkindbox" + r.PUT("/:id").Name = "benefactor-updatekindbox" + // r.DELETE("/:id").Name = "benefactor-deletekindbox" +} diff --git a/delivery/http_server/benefactor/kind_box/update.go b/delivery/http_server/benefactor/kind_box/update.go new file mode 100644 index 0000000..b731f40 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box/update.go @@ -0,0 +1,30 @@ +package benefactorkindboxhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" + "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.benefactorKindBoxVld.ValidateBenefactorUpdateRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.benefactorKindBoxSvc.Update(c, 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/add.go b/delivery/http_server/benefactor/kind_box_req/add.go new file mode 100644 index 0000000..02c8415 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box_req/add.go @@ -0,0 +1,30 @@ +package benefactorkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + "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.benefactorKindBoxReqVld.ValidateBenefactorAddRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.benefactorKindBoxReqSvc.Add(c, 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 new file mode 100644 index 0000000..0b8f4ac --- /dev/null +++ b/delivery/http_server/benefactor/kind_box_req/get.go @@ -0,0 +1,30 @@ +package benefactorkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + "github.com/labstack/echo/v4" +) + +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.ValidateBenefactorGetRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.benefactorKindBoxReqSvc.Get(c, 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 new file mode 100644 index 0000000..1ebe763 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box_req/get_all.go @@ -0,0 +1,24 @@ +package benefactorkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + "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.benefactorKindBoxReqSvc.GetAll(c, 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/handler.go b/delivery/http_server/benefactor/kind_box_req/handler.go new file mode 100644 index 0000000..eab52f5 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box_req/handler.go @@ -0,0 +1,25 @@ +package benefactorkindboxreqhandler + +import ( + authservice "git.gocasts.ir/ebhomengo/niki/service/auth" + benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req" + benefactorkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/kind_box_req" +) + +type Handler struct { + authConfig authservice.Config + authSvc authservice.Service + benefactorKindBoxReqSvc benefactorkindboxreqservice.Service + benefactorKindBoxReqVld benefactorkindboxreqvalidator.Validator +} + +func New(authConfig authservice.Config, authSvc authservice.Service, + benefactorKindBoxReqSvc benefactorkindboxreqservice.Service, benefactorKindBoxReqVld benefactorkindboxvalidator.Validator, +) Handler { + return Handler{ + authConfig: authConfig, + authSvc: authSvc, + benefactorKindBoxReqSvc: benefactorKindBoxReqSvc, + benefactorKindBoxReqVld: benefactorKindBoxReqVld, + } +} diff --git a/delivery/http_server/benefactor/kind_box_req/route.go b/delivery/http_server/benefactor/kind_box_req/route.go new file mode 100644 index 0000000..0407071 --- /dev/null +++ b/delivery/http_server/benefactor/kind_box_req/route.go @@ -0,0 +1,15 @@ +package benefactorkindboxreqhandler + +import ( + "github.com/labstack/echo/v4" +) + +func (h Handler) SetRoutes(e *echo.Echo) { + r := e.Group("/benefactor/kindboxreqs") + + r.POST("/").Name = "benefactor-addkindboxreq" + r.GET("/:id").Name = "benefactor-get-kindboxreqbyid" + r.GET("/").Name = "benefactor-getallkindboxreq" + r.PUT("/:id").Name = "benefactor-updatekindboxreq" + // r.DELETE("/:id").Name = "benefactor-deletekindreqbox" +} diff --git a/delivery/http_server/benefactor/kind_box_req/update.go b/delivery/http_server/benefactor/kind_box_req/update.go new file mode 100644 index 0000000..79350fc --- /dev/null +++ b/delivery/http_server/benefactor/kind_box_req/update.go @@ -0,0 +1,30 @@ +package benefactorkindboxreqhandler + +import ( + "net/http" + + httpmsg "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" + "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.benefactorKindBoxReqVld.ValidateBenefactorUpdateRequest(c, req); err != nil { + msg, code := httpmsg.Error(err) + return c.JSON(code, echo.Map{ + "message": msg, + "errors": fieldErrors, + }) + } + resp, sErr := h.benefactorKindBoxReqSvc.Update(c, 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/health_check.go b/delivery/http_server/health_check.go new file mode 100644 index 0000000..487e7ae --- /dev/null +++ b/delivery/http_server/health_check.go @@ -0,0 +1,13 @@ +package httpserver + +import ( + "net/http" + + "github.com/labstack/echo/v4" +) + +func (s Server) healthCheck(c echo.Context) error { + return c.JSON(http.StatusOK, echo.Map{ + "message": "everything is good!", + }) +} diff --git a/delivery/http_server/server.go b/delivery/http_server/server.go index 8805d70..87b426b 100644 --- a/delivery/http_server/server.go +++ b/delivery/http_server/server.go @@ -1,16 +1,37 @@ package httpserver -import "git.gocasts.ir/ebhomengo/niki/config" +import ( + "fmt" + + "git.gocasts.ir/ebhomengo/niki/config" + "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" +) type Server struct { config config.Config + Router *echo.Echo } -func New(cfg config.Config) Server { +func New(cfg Config) Server { return Server{ + Router: echo.New(), config: cfg, } } func (s Server) Serve() { + s.Router.Use(middleware.RequestID()) + + s.Router.Use(middleware.Recover()) + + // Routes + s.Router.GET("/health-check", s.healthCheck) + + // Start server + address := fmt.Sprintf(":%d", s.config.HTTPServer.Port) + fmt.Printf("start echo server on %s\n", address) + if err := s.Router.Start(address); err != nil { + fmt.Println("router start error", err) + } } diff --git a/entity/kind_box.go b/entity/kind_box.go index 589dcc5..6656fbf 100644 --- a/entity/kind_box.go +++ b/entity/kind_box.go @@ -11,5 +11,5 @@ type KindBox struct { SenderID uint SerialNumber string Status KindBoxStatus - StatusChangedAt *time.Time + StatusChangedAt time.Time } diff --git a/entity/kind_box_req.go b/entity/kind_box_req.go index dfdd93a..6336109 100644 --- a/entity/kind_box_req.go +++ b/entity/kind_box_req.go @@ -10,5 +10,5 @@ type KindBoxReq struct { BenefactorID uint Status KindBoxReqStatus Description string - StatusChangedAt *time.Time + StatusChangedAt time.Time } diff --git a/entity/kind_box_req_status.go b/entity/kind_box_req_status.go index a6cc795..61c5d9d 100644 --- a/entity/kind_box_req_status.go +++ b/entity/kind_box_req_status.go @@ -14,27 +14,27 @@ const ( kindBoxReqRejectedStatusStr = "rejected" ) -func (s KindBoxReqStatus) String() string { - switch s { - case KindBoxReqPendingStatus: - return kindBoxReqPendingStatusStr - case KindBoxReqAcceptedStatus: - return kindBoxReqAcceptedStatusStr - case KindBoxReqRejectedStatus: - return kindBoxReqRejectedStatusStr - } - return "" +func (s KindBoxReqStatus) String() string { + return KindBoxReqStatusStrings[s] } +// AllKindBoxReqStatus returns a slice containing all string values of KindBoxReqStatus. +func AllKindBoxReqStatus() []string { + statusStrings := make([]string, len(KindBoxReqStatusStrings)) + for status, str := range KindBoxReqStatusStrings { + statusStrings[int(status)-1] = str + } + + return statusStrings +} + +// MapToKindBoxReqStatus converts a string to the corresponding KindBoxReqStatus value. func MapToKindBoxReqStatus(statusStr string) KindBoxReqStatus { - switch statusStr { - case kindBoxReqPendingStatusStr: - return KindBoxReqPendingStatus - case kindBoxReqAcceptedStatusStr: - return KindBoxReqAcceptedStatus - case kindBoxReqRejectedStatusStr: - return KindBoxReqRejectedStatus + for status, str := range KindBoxReqStatusStrings { + if str == statusStr { + return status + } } return KindBoxReqStatus(0) diff --git a/param/benefactor/kind_box/get.go b/param/benefactor/kind_box/get.go index c4ced5b..0846894 100644 --- a/param/benefactor/kind_box/get.go +++ b/param/benefactor/kind_box/get.go @@ -1,4 +1,4 @@ -package userkindboxparam +package benefactorkindboxparam import entity "git.gocasts.ir/ebhomengo/niki/entity" diff --git a/param/benefactor/kind_box/get_all.go b/param/benefactor/kind_box/get_all.go index 35d7775..44ffd7a 100644 --- a/param/benefactor/kind_box/get_all.go +++ b/param/benefactor/kind_box/get_all.go @@ -1,4 +1,4 @@ -package userkindboxparam +package benefactorkindboxparam import entity "git.gocasts.ir/ebhomengo/niki/entity" diff --git a/param/benefactor/kind_box_req/add.go b/param/benefactor/kind_box_req/add.go index 1e5b85a..fef7326 100644 --- a/param/benefactor/kind_box_req/add.go +++ b/param/benefactor/kind_box_req/add.go @@ -1,4 +1,4 @@ -package userkindboxreqparam +package benefactorkindboxreqparam import entity "git.gocasts.ir/ebhomengo/niki/entity" diff --git a/param/benefactor/kind_box_req/delete.go b/param/benefactor/kind_box_req/delete.go index d8dd89f..2ecea4e 100644 --- a/param/benefactor/kind_box_req/delete.go +++ b/param/benefactor/kind_box_req/delete.go @@ -1,4 +1,4 @@ -package userkindboxreqparam +package benefactorkindboxreqparam type KindBoxReqDeleteRequest struct { BenefactorID uint diff --git a/param/benefactor/kind_box_req/get.go b/param/benefactor/kind_box_req/get.go index 3feb856..14fbc3c 100644 --- a/param/benefactor/kind_box_req/get.go +++ b/param/benefactor/kind_box_req/get.go @@ -1,4 +1,4 @@ -package userkindboxreqparam +package benefactorkindboxreqparam import entity "git.gocasts.ir/ebhomengo/niki/entity" diff --git a/param/benefactor/kind_box_req/get_all.go b/param/benefactor/kind_box_req/get_all.go index be4b653..1cfdea7 100644 --- a/param/benefactor/kind_box_req/get_all.go +++ b/param/benefactor/kind_box_req/get_all.go @@ -1,4 +1,4 @@ -package userkindboxreqparam +package benefactorkindboxreqparam import entity "git.gocasts.ir/ebhomengo/niki/entity" diff --git a/param/benefactor/kind_box_req/update.go b/param/benefactor/kind_box_req/update.go index d587a56..e3d0df4 100644 --- a/param/benefactor/kind_box_req/update.go +++ b/param/benefactor/kind_box_req/update.go @@ -1,4 +1,4 @@ -package userkindboxreqparam +package benefactorkindboxreqparam import entity "git.gocasts.ir/ebhomengo/niki/entity" diff --git a/service/admin/kind_box/get_all.go b/service/admin/kind_box/get_all.go index 446d3a6..4030d34 100644 --- a/service/admin/kind_box/get_all.go +++ b/service/admin/kind_box/get_all.go @@ -7,7 +7,7 @@ import ( richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" ) -func (s Service) GetAll(ctx context.Context) (param.KindBoxGetAllResponse, 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 { diff --git a/service/admin/kind_box_req/get_all.go b/service/admin/kind_box_req/get_all.go index 6c9e85d..a7d4061 100644 --- a/service/admin/kind_box_req/get_all.go +++ b/service/admin/kind_box_req/get_all.go @@ -8,7 +8,7 @@ import ( ) // TODO: Pagination, Filters, Sort. -func (s Service) GetAll(ctx context.Context) (param.KindBoxReqGetAllResponse, error) { +func (s Service) GetAll(ctx context.Context, _ param.KindBoxReqGetAllRequest) (param.KindBoxReqGetAllResponse, error) { const op = "adminkindboxreqservice.GetAll" allKindBoxReq, err := s.repo.GetAllKindBoxReq(ctx) diff --git a/service/benefactor/kind_box/get.go b/service/benefactor/kind_box/get.go index 19ee41a..b43d65f 100644 --- a/service/benefactor/kind_box/get.go +++ b/service/benefactor/kind_box/get.go @@ -1,4 +1,4 @@ -package userkindboxservice +package benefactorkindboxservice import ( "context" diff --git a/service/benefactor/kind_box/get_all.go b/service/benefactor/kind_box/get_all.go index 9ed7b0e..9d93fa5 100644 --- a/service/benefactor/kind_box/get_all.go +++ b/service/benefactor/kind_box/get_all.go @@ -1,4 +1,4 @@ -package userkindboxservice +package benefactorkindboxservice import ( "context" diff --git a/service/benefactor/kind_box/service.go b/service/benefactor/kind_box/service.go index 35d78e1..0970f9e 100644 --- a/service/benefactor/kind_box/service.go +++ b/service/benefactor/kind_box/service.go @@ -1,4 +1,4 @@ -package userkindboxservice +package benefactorkindboxservice import ( "context" diff --git a/service/benefactor/kind_box_req/add.go b/service/benefactor/kind_box_req/add.go index adf424c..3bd2c26 100644 --- a/service/benefactor/kind_box_req/add.go +++ b/service/benefactor/kind_box_req/add.go @@ -1,4 +1,4 @@ -package userkindboxreqservice +package benefactorkindboxreqservice import ( "context" diff --git a/service/benefactor/kind_box_req/delete.go b/service/benefactor/kind_box_req/delete.go index a85ebdb..20f9b30 100644 --- a/service/benefactor/kind_box_req/delete.go +++ b/service/benefactor/kind_box_req/delete.go @@ -1,4 +1,4 @@ -package userkindboxreqservice +package benefactorkindboxreqservice import ( "context" diff --git a/service/benefactor/kind_box_req/get.go b/service/benefactor/kind_box_req/get.go index 9053f84..0891acc 100644 --- a/service/benefactor/kind_box_req/get.go +++ b/service/benefactor/kind_box_req/get.go @@ -1,4 +1,4 @@ -package userkindboxreqservice +package benefactorkindboxreqservice import ( "context" diff --git a/service/benefactor/kind_box_req/get_all.go b/service/benefactor/kind_box_req/get_all.go index 9b7ce79..6a40a01 100644 --- a/service/benefactor/kind_box_req/get_all.go +++ b/service/benefactor/kind_box_req/get_all.go @@ -1,4 +1,4 @@ -package userkindboxreqservice +package benefactorkindboxreqservice import ( "context" diff --git a/service/benefactor/kind_box_req/service.go b/service/benefactor/kind_box_req/service.go index f552c9d..dfa81c1 100644 --- a/service/benefactor/kind_box_req/service.go +++ b/service/benefactor/kind_box_req/service.go @@ -1,4 +1,4 @@ -package userkindboxreqservice +package benefactorkindboxreqservice import ( "context" diff --git a/service/benefactor/kind_box_req/update.go b/service/benefactor/kind_box_req/update.go index e3cadbe..a8117d9 100644 --- a/service/benefactor/kind_box_req/update.go +++ b/service/benefactor/kind_box_req/update.go @@ -1,4 +1,4 @@ -package userkindboxreqservice +package benefactorkindboxreqservice import ( "context" diff --git a/validator/admin/kind_box/add.go b/validator/admin/kind_box/add.go index 42a8abd..30ccc8e 100644 --- a/validator/admin/kind_box/add.go +++ b/validator/admin/kind_box/add.go @@ -1,6 +1,7 @@ package adminkindboxvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" @@ -10,7 +11,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateAdminAddRequest(req param.KindBoxAddRequest) (map[string]string, error) { +func (v Validator) ValidateAdminAddRequest(ctx context.Context, req param.KindBoxAddRequest) (map[string]string, error) { const op = "adminkindboxvalidator.KindBoxAddRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box/delete.go b/validator/admin/kind_box/delete.go index 528ec31..206b0bf 100644 --- a/validator/admin/kind_box/delete.go +++ b/validator/admin/kind_box/delete.go @@ -1,6 +1,7 @@ package adminkindboxvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateDeleteRequest(req param.KindBoxDeleteRequest) (map[string]string, error) { +func (v Validator) ValidateDeleteRequest(ctx context.Context, req param.KindBoxDeleteRequest) (map[string]string, error) { const op = "adminkindboxvalidator.ValidateDeleteRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box/get.go b/validator/admin/kind_box/get.go index 5c38bb1..6b22716 100644 --- a/validator/admin/kind_box/get.go +++ b/validator/admin/kind_box/get.go @@ -1,6 +1,7 @@ package adminkindboxvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateGetByIDRequest(req param.KindBoxGetRequest) (map[string]string, error) { +func (v Validator) ValidateGetByIDRequest(ctx context.Context, req param.KindBoxGetRequest) (map[string]string, error) { const op = "adminkindboxvalidator.ValidateGetRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box/update.go b/validator/admin/kind_box/update.go index 0845b90..643e281 100644 --- a/validator/admin/kind_box/update.go +++ b/validator/admin/kind_box/update.go @@ -11,7 +11,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateUpdateRequest(req param.KindBoxUpdateRequest) (map[string]string, error) { +func (v Validator) ValidateUpdateRequest(ctx context.Context, req param.KindBoxUpdateRequest) (map[string]string, error) { const op = "adminkindboxvalidator.ValidateUpdateRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box_req/add.go b/validator/admin/kind_box_req/add.go index 9384e64..a52abab 100644 --- a/validator/admin/kind_box_req/add.go +++ b/validator/admin/kind_box_req/add.go @@ -1,6 +1,7 @@ package adminkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateAddRequest(req param.KindBoxReqAddRequest) (map[string]string, error) { +func (v Validator) ValidateAddRequest(ctx context.Context, req param.KindBoxReqAddRequest) (map[string]string, error) { const op = "adminkindboxreqvalidator.ValidateAddRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box_req/delete.go b/validator/admin/kind_box_req/delete.go index 1f42214..aeae497 100644 --- a/validator/admin/kind_box_req/delete.go +++ b/validator/admin/kind_box_req/delete.go @@ -1,6 +1,7 @@ package adminkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateDeleteRequest(req param.KindBoxReqDeleteRequest) (map[string]string, error) { +func (v Validator) ValidateDeleteRequest(ctx context.Context, req param.KindBoxReqDeleteRequest) (map[string]string, error) { const op = "adminkindboxreqvalidator.ValidateDeleteRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box_req/get.go b/validator/admin/kind_box_req/get.go index 89c09f5..7ff74f6 100644 --- a/validator/admin/kind_box_req/get.go +++ b/validator/admin/kind_box_req/get.go @@ -1,6 +1,7 @@ package adminkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateGetByIDRequest(req param.KindBoxReqGetRequest) (map[string]string, error) { +func (v Validator) ValidateGetByIDRequest(ctx context.Context, req param.KindBoxReqGetRequest) (map[string]string, error) { const op = "adminkindboxreqvalidator.ValidateGetRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/admin/kind_box_req/update.go b/validator/admin/kind_box_req/update.go index f75f620..37472a1 100644 --- a/validator/admin/kind_box_req/update.go +++ b/validator/admin/kind_box_req/update.go @@ -1,6 +1,7 @@ package adminkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateUpdateRequest(req param.KindBoxReqUpdateRequest) (map[string]string, error) { +func (v Validator) ValidateUpdateRequest(ctx context.Context, req param.KindBoxReqUpdateRequest) (map[string]string, error) { const op = "adminkindboxreqvalidator.ValidateUpdateRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box/get.go b/validator/benefactor/kind_box/get.go index ed251e0..bf4fa3c 100644 --- a/validator/benefactor/kind_box/get.go +++ b/validator/benefactor/kind_box/get.go @@ -1,6 +1,7 @@ -package userkindboxvalidator +package benefactorkindboxvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateGetByIDRequest(req param.KindBoxGetRequest) (map[string]string, error) { +func (v Validator) ValidateGetByIDRequest(ctx context.Context, req param.KindBoxGetRequest) (map[string]string, error) { const op = "userkindboxvalidator.ValidateGetRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box/get_all.go b/validator/benefactor/kind_box/get_all.go index 7b2808c..2c0503c 100644 --- a/validator/benefactor/kind_box/get_all.go +++ b/validator/benefactor/kind_box/get_all.go @@ -1,6 +1,7 @@ -package userkindboxvalidator +package benefactorkindboxvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateUpdateRequest(req param.KindBoxGetAllRequest) (map[string]string, error) { +func (v Validator) ValidateUpdateRequest(ctx context.Context, req param.KindBoxGetAllRequest) (map[string]string, error) { const op = "userkindboxvalidator.ValidateGetAllRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box/validator.go b/validator/benefactor/kind_box/validator.go index 7ea99f9..6d26bd4 100644 --- a/validator/benefactor/kind_box/validator.go +++ b/validator/benefactor/kind_box/validator.go @@ -1,4 +1,4 @@ -package userkindboxvalidator +package benefactorkindboxvalidator import ( "fmt" diff --git a/validator/benefactor/kind_box_req/add.go b/validator/benefactor/kind_box_req/add.go index 3ae12a7..c7514a2 100644 --- a/validator/benefactor/kind_box_req/add.go +++ b/validator/benefactor/kind_box_req/add.go @@ -1,6 +1,7 @@ -package userkindboxreqvalidator +package benefactorkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateAddRequest(req param.KindBoxReqAddRequest) (map[string]string, error) { +func (v Validator) ValidateAddRequest(ctx context.Context, req param.KindBoxReqAddRequest) (map[string]string, error) { const op = "userkindboxreqvalidator.ValidateAddRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box_req/delete.go b/validator/benefactor/kind_box_req/delete.go index 600088e..3e3486c 100644 --- a/validator/benefactor/kind_box_req/delete.go +++ b/validator/benefactor/kind_box_req/delete.go @@ -1,6 +1,7 @@ -package userkindboxreqvalidator +package benefactorkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateDeleteRequest(req param.KindBoxReqDeleteRequest) (map[string]string, error) { +func (v Validator) ValidateDeleteRequest(ctx context.Context, req param.KindBoxReqDeleteRequest) (map[string]string, error) { const op = "userkindboxreqvalidator.ValidateDeleteRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box_req/get.go b/validator/benefactor/kind_box_req/get.go index ae08f30..3e0f773 100644 --- a/validator/benefactor/kind_box_req/get.go +++ b/validator/benefactor/kind_box_req/get.go @@ -1,4 +1,4 @@ -package userkindboxreqvalidator +package benefactorkindboxreqvalidator import ( "errors" @@ -9,7 +9,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateGetRequest(req param.KindBoxReqGetRequest) (map[string]string, error) { +func (v Validator) ValidateGetRequest(ctx context.Context, req param.KindBoxReqGetRequest) (map[string]string, error) { const op = "userkindboxreqvalidator.ValidateGetRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box_req/get_all.go b/validator/benefactor/kind_box_req/get_all.go index 2a8929f..29bdabf 100644 --- a/validator/benefactor/kind_box_req/get_all.go +++ b/validator/benefactor/kind_box_req/get_all.go @@ -1,6 +1,7 @@ -package userkindboxreqvalidator +package benefactorkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateGetAllRequest(req param.KindBoxReqGetAllRequest) (map[string]string, error) { +func (v Validator) ValidateGetAllRequest(ctx context.Context, req param.KindBoxReqGetAllRequest) (map[string]string, error) { const op = "userkindboxreqvalidator.ValidateGetAllRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box_req/update.go b/validator/benefactor/kind_box_req/update.go index c951ab8..acfc4d4 100644 --- a/validator/benefactor/kind_box_req/update.go +++ b/validator/benefactor/kind_box_req/update.go @@ -1,6 +1,7 @@ -package userkindboxreqvalidator +package benefactorkindboxreqvalidator import ( + "context" "errors" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req" @@ -9,7 +10,7 @@ import ( validation "github.com/go-ozzo/ozzo-validation/v4" ) -func (v Validator) ValidateUpdateRequest(req param.KindBoxReqUpdateRequest) (map[string]string, error) { +func (v Validator) ValidateUpdateRequest(ctx context.Context, req param.KindBoxReqUpdateRequest) (map[string]string, error) { const op = "userkindboxreqvalidator.ValidateUpdateRequest" if err := validation.ValidateStruct(&req, diff --git a/validator/benefactor/kind_box_req/validator.go b/validator/benefactor/kind_box_req/validator.go index 986ae8e..d303035 100644 --- a/validator/benefactor/kind_box_req/validator.go +++ b/validator/benefactor/kind_box_req/validator.go @@ -1,4 +1,4 @@ -package userkindboxreqvalidator +package benefactorkindboxreqvalidator import ( "fmt"