From 8a66e43789ca73652ca36e8a6d91b33331c14c10 Mon Sep 17 00:00:00 2001 From: ErfanTech Date: Mon, 1 Jul 2024 20:43:28 +0330 Subject: [PATCH] feat(niki): admin get kindbox --- delivery/http_server/admin/kind_box/get.go | 43 +++++++++ delivery/http_server/admin/kind_box/route.go | 11 ++- delivery/http_server/server.go | 8 ++ docs/docs.go | 96 +++++++++++++++++++ docs/swagger.json | 96 +++++++++++++++++++ docs/swagger.yaml | 62 ++++++++++++ entity/admin_permission.go | 1 + internal/initial/validator.go | 6 ++ main.go | 4 +- param/admin/kind_box/get.go | 3 +- repository/mysql/kind_box/exist_kindbox.go | 13 +++ ...s_controls_table_permission_enum_field.sql | 3 +- ...565_insert_admin_access_controls_table.sql | 4 +- service/admin/kind_box/get.go | 19 ++++ service/admin/kind_box/service.go | 1 + validator/admin/kind_box/get.go | 39 ++++++++ validator/admin/kind_box/validator.go | 31 ++++-- 17 files changed, 426 insertions(+), 14 deletions(-) create mode 100644 delivery/http_server/admin/kind_box/get.go create mode 100644 service/admin/kind_box/get.go create mode 100644 validator/admin/kind_box/get.go 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..3003e96 --- /dev/null +++ b/delivery/http_server/admin/kind_box/get.go @@ -0,0 +1,43 @@ +package adminkindboxhandler + +import ( + "net/http" + + param "git.gocasts.ir/ebhomengo/niki/param/admin/kind_box" + httpmsg "git.gocasts.ir/ebhomengo/niki/pkg/http_msg" + "github.com/labstack/echo/v4" +) + +// Get godoc +// @Summary Get a specific kind box by admin +// @Description This endpoint retrieves a specific kind box by admin +// @Tags KindBox +// @Accept json +// @Produce json +// @Param id path int true "Kind box ID" +// @Success 200 {object} param.KindBoxGetResponse +// @Failure 400 {string} "Bad request" +// @Security AuthBearerAdmin +// @Router /admin/kindboxes/{id} [get]. +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.StatusOK, resp) +} diff --git a/delivery/http_server/admin/kind_box/route.go b/delivery/http_server/admin/kind_box/route.go index ef9bd24..6504856 100644 --- a/delivery/http_server/admin/kind_box/route.go +++ b/delivery/http_server/admin/kind_box/route.go @@ -1,8 +1,15 @@ package adminkindboxhandler import ( - echo "github.com/labstack/echo/v4" + "git.gocasts.ir/ebhomengo/niki/delivery/http_server/middleware" + "git.gocasts.ir/ebhomengo/niki/entity" + "github.com/labstack/echo/v4" ) -func (h Handler) SetRoutes(_ *echo.Echo) { +func (h Handler) SetRoutes(e *echo.Echo) { + r := e.Group("/admin/kindboxes") + + r.Use(middleware.Auth(h.authSvc, h.authConfig)) + + r.GET("/:id", h.Get, middleware.AdminAuthorization(h.adminAuthorizeSvc, entity.AdminKindBoxGetPermission)) } diff --git a/delivery/http_server/server.go b/delivery/http_server/server.go index 0ba982b..677d70d 100644 --- a/delivery/http_server/server.go +++ b/delivery/http_server/server.go @@ -5,6 +5,7 @@ import ( config "git.gocasts.ir/ebhomengo/niki/config" adminhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/admin" + adminKindBoxHandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/kind_box" adminkindboxreqhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/admin/kind_box_req" benefactoraddresshandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/benefactor/address" benefactorhandler "git.gocasts.ir/ebhomengo/niki/delivery/http_server/benefactor/benefactor" @@ -13,6 +14,7 @@ import ( "git.gocasts.ir/ebhomengo/niki/docs" adminservice "git.gocasts.ir/ebhomengo/niki/service/admin/admin" adminauthorizationservice "git.gocasts.ir/ebhomengo/niki/service/admin/authorization" + adminkindboxservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box" adminkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/admin/kind_box_req" authservice "git.gocasts.ir/ebhomengo/niki/service/auth" benefactoraddressservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/address" @@ -20,6 +22,7 @@ import ( benefactorkindboxservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box" benefactorkindboxreqservice "git.gocasts.ir/ebhomengo/niki/service/benefactor/kind_box_req" adminvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/admin" + adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box" adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req" benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address" benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor" @@ -39,6 +42,7 @@ type Server struct { benefactorKindBoxHandler benefactorkindboxhandler.Handler adminHandler adminhandler.Handler adminKindBoxReqHandler adminkindboxreqhandler.Handler + adminKindBoxHandler adminKindBoxHandler.Handler } func New( @@ -58,6 +62,8 @@ func New( adminKinBoxReqSvc adminkindboxreqservice.Service, adminKinBoxReqVld adminkindboxreqvalidator.Validator, adminAuthorizeSvc adminauthorizationservice.Service, + adminKindBoxSvc adminkindboxservice.Service, + adminKindBoxVld adminkindboxvalidator.Validator, ) Server { return Server{ Router: echo.New(), @@ -68,6 +74,7 @@ func New( benefactorKindBoxHandler: benefactorkindboxhandler.New(cfg.Auth, benefactorAuthSvc, benefactorKindBoxSvc, benefactorKindBoxVld), adminHandler: adminhandler.New(cfg.AdminAuth, adminAuthSvc, adminSvc, adminVld, adminAuthorizeSvc), adminKindBoxReqHandler: adminkindboxreqhandler.New(cfg.Auth, adminAuthSvc, adminKinBoxReqSvc, adminKinBoxReqVld, adminAuthorizeSvc), + adminKindBoxHandler: adminKindBoxHandler.New(cfg.Auth, adminAuthSvc, adminKindBoxSvc, adminKindBoxVld, adminAuthorizeSvc), } } @@ -84,6 +91,7 @@ func (s Server) Serve() { s.benefactorKindBoxHandler.SetRoutes(s.Router) s.adminHandler.SetRoutes(s.Router) s.adminKindBoxReqHandler.SetRoutes(s.Router) + s.adminKindBoxHandler.SetRoutes(s.Router) // Start server address := fmt.Sprintf(":%d", s.config.HTTPServer.Port) fmt.Printf("start echo server on %s\n", address) diff --git a/docs/docs.go b/docs/docs.go index 86a1f24..dc65d07 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -267,6 +267,49 @@ const docTemplate = `{ } } }, + "/admin/kindboxes/{id}": { + "get": { + "security": [ + { + "AuthBearerAdmin": [] + } + ], + "description": "This endpoint retrieves a specific kind box by admin", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "KindBox" + ], + "summary": "Get a specific kind box by admin", + "parameters": [ + { + "type": "integer", + "description": "Kind box ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/adminkindboxparam.KindBoxGetResponse" + } + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + } + } + } + } + }, "/admin/kindboxreqs": { "get": { "security": [ @@ -1281,6 +1324,59 @@ const docTemplate = `{ } } }, + "adminkindboxparam.KindBoxGetResponse": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactorID": { + "type": "integer" + }, + "deliverAddressID": { + "type": "integer" + }, + "deliverReferDate": { + "type": "string" + }, + "deliveredAt": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kindBoxReqID": { + "type": "integer" + }, + "receiverAgentID": { + "type": "integer" + }, + "returnAddressID": { + "type": "integer" + }, + "returnReferDate": { + "type": "string" + }, + "returnReferTimeID": { + "type": "integer" + }, + "returnedAt": { + "type": "string" + }, + "senderAgentID": { + "type": "integer" + }, + "serialNumber": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + }, + "type": { + "$ref": "#/definitions/entity.KindBoxType" + } + } + }, "adminkindboxreqparam.AssignSenderRequest": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index d7159d8..87ebdf6 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -256,6 +256,49 @@ } } }, + "/admin/kindboxes/{id}": { + "get": { + "security": [ + { + "AuthBearerAdmin": [] + } + ], + "description": "This endpoint retrieves a specific kind box by admin", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "KindBox" + ], + "summary": "Get a specific kind box by admin", + "parameters": [ + { + "type": "integer", + "description": "Kind box ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/adminkindboxparam.KindBoxGetResponse" + } + }, + "400": { + "description": "Bad request", + "schema": { + "type": "string" + } + } + } + } + }, "/admin/kindboxreqs": { "get": { "security": [ @@ -1270,6 +1313,59 @@ } } }, + "adminkindboxparam.KindBoxGetResponse": { + "type": "object", + "properties": { + "amount": { + "type": "integer" + }, + "benefactorID": { + "type": "integer" + }, + "deliverAddressID": { + "type": "integer" + }, + "deliverReferDate": { + "type": "string" + }, + "deliveredAt": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "kindBoxReqID": { + "type": "integer" + }, + "receiverAgentID": { + "type": "integer" + }, + "returnAddressID": { + "type": "integer" + }, + "returnReferDate": { + "type": "string" + }, + "returnReferTimeID": { + "type": "integer" + }, + "returnedAt": { + "type": "string" + }, + "senderAgentID": { + "type": "integer" + }, + "serialNumber": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/entity.KindBoxStatus" + }, + "type": { + "$ref": "#/definitions/entity.KindBoxType" + } + } + }, "adminkindboxreqparam.AssignSenderRequest": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 48ef561..b3981e5 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -72,6 +72,41 @@ definitions: example: "1234567890" type: string type: object + adminkindboxparam.KindBoxGetResponse: + properties: + amount: + type: integer + benefactorID: + type: integer + deliverAddressID: + type: integer + deliverReferDate: + type: string + deliveredAt: + type: string + id: + type: integer + kindBoxReqID: + type: integer + receiverAgentID: + type: integer + returnAddressID: + type: integer + returnReferDate: + type: string + returnReferTimeID: + type: integer + returnedAt: + type: string + senderAgentID: + type: integer + serialNumber: + type: string + status: + $ref: '#/definitions/entity.KindBoxStatus' + type: + $ref: '#/definitions/entity.KindBoxType' + type: object adminkindboxreqparam.AssignSenderRequest: properties: sender_agent_id: @@ -780,6 +815,33 @@ paths: summary: Get all provinces tags: - Address + /admin/kindboxes/{id}: + get: + consumes: + - application/json + description: This endpoint retrieves a specific kind box by admin + parameters: + - description: Kind box ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/adminkindboxparam.KindBoxGetResponse' + "400": + description: Bad request + schema: + type: string + security: + - AuthBearerAdmin: [] + summary: Get a specific kind box by admin + tags: + - KindBox /admin/kindboxreqs: get: consumes: diff --git a/entity/admin_permission.go b/entity/admin_permission.go index 7adc164..45f1b5c 100644 --- a/entity/admin_permission.go +++ b/entity/admin_permission.go @@ -12,4 +12,5 @@ const ( AdminKindBoxReqAssignSenderAgentPermission = AdminPermission("kindboxreq-assign_sender_agent") AdminAdminGetAllAgentPermission = AdminPermission("admin-getall_agent") AdminKindBoxReqGetAwaitingDeliveryPermission = AdminPermission("kindboxreq-get_awaiting_delivery") + AdminKindBoxGetPermission = AdminPermission("kindbox-get") ) diff --git a/internal/initial/validator.go b/internal/initial/validator.go index 7c5d53c..bdcad23 100644 --- a/internal/initial/validator.go +++ b/internal/initial/validator.go @@ -5,6 +5,7 @@ import ( "git.gocasts.ir/ebhomengo/niki/config" "git.gocasts.ir/ebhomengo/niki/repository/mysql" adminvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/admin" + adminkindboxvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box" adminkindboxreqvalidator "git.gocasts.ir/ebhomengo/niki/validator/admin/kind_box_req" benefactoraddressvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/address" benefactorvalidator "git.gocasts.ir/ebhomengo/niki/validator/benefactor/benefactor" @@ -19,6 +20,7 @@ type Validators struct { BenefactorKindBoxVld benefactorkindboxvalidator.Validator AdminKindBoxReqVld adminkindboxreqvalidator.Validator AdminVld adminvalidator.Validator + AdminKindBoxVld adminkindboxvalidator.Validator } func InitAdminKindBoxReqValidator(db *mysql.DB, cfg config.Config) adminkindboxreqvalidator.Validator { @@ -49,6 +51,10 @@ func InitBenefactorAddressValidator(cfg config.Config, redisAdapter redis.Adapte ) } +func InitAdminKindBoxValidator(db *mysql.DB) adminkindboxvalidator.Validator { + return adminkindboxvalidator.New(InitKindBoxRepo(db)) +} + func InitBenefactorKindBoxValidator(cfg config.Config, redisAdapter redis.Adapter, db *mysql.DB) benefactorkindboxvalidator.Validator { return benefactorkindboxvalidator.New( InitKindBoxRepo(db), diff --git a/main.go b/main.go index 7613137..df662ae 100644 --- a/main.go +++ b/main.go @@ -65,6 +65,7 @@ func initDependencies(cfg config.Config, redisAdapter redis.Adapter, db *mysql.D BenefactorKindBoxVld: initial.InitBenefactorKindBoxValidator(cfg, redisAdapter, db), AdminKindBoxReqVld: initial.InitAdminKindBoxReqValidator(db, cfg), AdminVld: initial.InitAdminValidator(db), + AdminKindBoxVld: initial.InitAdminKindBoxValidator(db), }, initial.Services{ BenefactorSvc: initial.InitBenefactorService(cfg, redisAdapter, db), @@ -89,7 +90,8 @@ func initAndRunServer(cfg config.Config, dependencies *Dependencies) { dependencies.BenefactorAddressSvc, dependencies.BenefactorAddressVld, dependencies.BenefactorKindBoxSvc, dependencies.BenefactorKindBoxVld, dependencies.AdminSvc, dependencies.AdminVld, dependencies.AdminAuthSvc, - dependencies.AdminKindBoxReqSvc, dependencies.AdminKindBoxReqVld, dependencies.AdminAuthorizationSvc) + dependencies.AdminKindBoxReqSvc, dependencies.AdminKindBoxReqVld, dependencies.AdminAuthorizationSvc, + dependencies.AdminKindBoxSvc, dependencies.AdminKindBoxVld) server.Serve() } diff --git a/param/admin/kind_box/get.go b/param/admin/kind_box/get.go index 3893ad0..c103292 100644 --- a/param/admin/kind_box/get.go +++ b/param/admin/kind_box/get.go @@ -3,8 +3,7 @@ package adminkindboxparam import entity "git.gocasts.ir/ebhomengo/niki/entity" type KindBoxGetRequest struct { - BenefactorID uint - KindBoxID uint + KindBoxID uint `param:"id"` } type KindBoxGetResponse struct { diff --git a/repository/mysql/kind_box/exist_kindbox.go b/repository/mysql/kind_box/exist_kindbox.go index 4276f85..95b417c 100644 --- a/repository/mysql/kind_box/exist_kindbox.go +++ b/repository/mysql/kind_box/exist_kindbox.go @@ -19,3 +19,16 @@ func (d DB) BenefactorKindBoxExist(ctx context.Context, benefactorID, kindBoxID return count > 0, nil } + +func (d DB) KindBoxExist(ctx context.Context, kindBoxID uint) (bool, error) { + const op = "mysqlkindbox.KindBoxExist" + + var count int + if err := d.conn.Conn().QueryRowContext(ctx, `SELECT COUNT(*) FROM kind_boxes WHERE id = ?`, kindBoxID).Scan(&count); err != nil { + + return false, richerror.New(op).WithErr(err). + WithMessage(errmsg.ErrorMsgSomethingWentWrong).WithKind(richerror.KindUnexpected) + } + + return count > 0, nil +} diff --git a/repository/mysql/migration/1708712564_alter_admin_access_controls_table_permission_enum_field.sql b/repository/mysql/migration/1708712564_alter_admin_access_controls_table_permission_enum_field.sql index a40a8bf..9ebd6a0 100644 --- a/repository/mysql/migration/1708712564_alter_admin_access_controls_table_permission_enum_field.sql +++ b/repository/mysql/migration/1708712564_alter_admin_access_controls_table_permission_enum_field.sql @@ -8,7 +8,8 @@ ALTER TABLE `admin_access_controls` MODIFY COLUMN `permission` 'kindboxreq-deliver', 'kindboxreq-assign_sender_agent', 'admin-getall_agent', - 'kindboxreq-get_awaiting_delivery' + 'kindboxreq-get_awaiting_delivery', + 'kindbox-get' ) NOT NULL; -- +migrate Down \ No newline at end of file diff --git a/repository/mysql/migration/1708712565_insert_admin_access_controls_table.sql b/repository/mysql/migration/1708712565_insert_admin_access_controls_table.sql index f8636ef..63822ac 100644 --- a/repository/mysql/migration/1708712565_insert_admin_access_controls_table.sql +++ b/repository/mysql/migration/1708712565_insert_admin_access_controls_table.sql @@ -15,7 +15,9 @@ INSERT INTO `admin_access_controls` (`id`, `actor_id`, `actor_type`,`permission` (13, 1 , 'role','admin-getall_agent'), (14, 2 , 'role','admin-getall_agent'), (15, 1 , 'role','kindboxreq-get_awaiting_delivery'), - (16, 3 , 'role','kindboxreq-get_awaiting_delivery'); + (16, 3 , 'role','kindboxreq-get_awaiting_delivery'), + (17, 1 , 'role','kindbox-get'), + (18, 2 , 'role','kindbox-get'); -- +migrate Down diff --git a/service/admin/kind_box/get.go b/service/admin/kind_box/get.go new file mode 100644 index 0000000..995e73c --- /dev/null +++ b/service/admin/kind_box/get.go @@ -0,0 +1,19 @@ +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, request param.KindBoxGetRequest) (param.KindBoxGetResponse, error) { + const op = "adminkindboxservice.Get" + + kindBox, err := s.repo.GetKindBox(ctx, request.KindBoxID) + if err != nil { + return param.KindBoxGetResponse{}, richerror.New(op).WithErr(err) + } + + return param.KindBoxGetResponse{KindBox: kindBox}, nil +} diff --git a/service/admin/kind_box/service.go b/service/admin/kind_box/service.go index 20e96a1..f8cdf7a 100644 --- a/service/admin/kind_box/service.go +++ b/service/admin/kind_box/service.go @@ -9,6 +9,7 @@ import ( type Repository interface { AddBatchKindBox(ctx context.Context, kindBoxes []entity.KindBox) error AddKindBox(ctx context.Context, kindBox entity.KindBox) error + GetKindBox(ctx context.Context, kindBoxID uint) (entity.KindBox, error) } type Service struct { diff --git a/validator/admin/kind_box/get.go b/validator/admin/kind_box/get.go new file mode 100644 index 0000000..e8d58b3 --- /dev/null +++ b/validator/admin/kind_box/get.go @@ -0,0 +1,39 @@ +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.KindBoxID, + validation.Required, + 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/validator.go b/validator/admin/kind_box/validator.go index b180884..ba391af 100644 --- a/validator/admin/kind_box/validator.go +++ b/validator/admin/kind_box/validator.go @@ -1,13 +1,14 @@ package adminkindboxvalidator +import ( + "context" + "fmt" + + errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" +) + type Repository interface { - KindBoxRequestExist(id uint) (bool, error) - EmployeeExist(id uint) (bool, error) - BenefactorExist(id uint) (bool, error) - KindBoxExist(id uint) (bool, error) - KindBoxBelongToBenefactor(benefactorID uint, kindboxID uint) (bool, error) - PendingStatus(id uint) (bool, error) - CheckStatus(status string) (bool, error) + KindBoxExist(ctx context.Context, kindBoxID uint) (bool, error) } type Validator struct { @@ -17,3 +18,19 @@ type Validator struct { func New(repo Repository) Validator { return Validator{repo: repo} } + +func (v Validator) doesKindBoxExist(value interface{}) error { + kindBoxID, ok := value.(uint) + if !ok { + return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) + } + exists, err := v.repo.KindBoxExist(context.Background(), kindBoxID) + if err != nil { + return fmt.Errorf(errmsg.ErrorMsgSomethingWentWrong) + } + if !exists { + return fmt.Errorf(errmsg.ErrorMsgNotFound) + } + + return nil +}