From f7fb18a501a4b4d2df2a46d28c44a47fc296b06a Mon Sep 17 00:00:00 2001 From: imirazimi Date: Thu, 28 Dec 2023 21:08:45 +0330 Subject: [PATCH] fix(niki): fix linter errors --- entity/kind_box_status.go | 63 ---------------------------- service/admin/kind_box/get.go | 1 - service/admin/kind_box/update.go | 1 - service/admin/kind_box_req/update.go | 12 ------ service/benefactor/kind_box/get.go | 2 - 5 files changed, 79 deletions(-) diff --git a/entity/kind_box_status.go b/entity/kind_box_status.go index f745d38..a6d803d 100644 --- a/entity/kind_box_status.go +++ b/entity/kind_box_status.go @@ -10,60 +10,6 @@ const ( KindBoxEnumeratedStatus ) -const ( - kindBoxPendingSendStatus = "pending-send" - kindBoxSentStatus = "sent" - kindBoxPendingReceivedStatus = "pending-received" - kindBoxReceivedStatus = "received" - kindBoxEnumeratedStatus = "enumerated" -) - -func (s KindBoxStatus) String() string { - switch s { - case KindBoxPendingSendStatus: - return kindBoxPendingSendStatus - case KindBoxSentStatus: - return kindBoxSentStatus - case KindBoxPendingReceivedStatus: - return kindBoxPendingReceivedStatus - case KindBoxReceivedStatus: - return kindBoxReceivedStatus - case KindBoxEnumeratedStatus: - return kindBoxEnumeratedStatus - } - - return "" -} - -func MapToKindBoxStatus(statusStr string) KindBoxStatus { - switch statusStr { - case kindBoxPendingSendStatus: - return KindBoxPendingSendStatus - case kindBoxSentStatus: - return KindBoxSentStatus - case kindBoxPendingReceivedStatus: - return KindBoxPendingReceivedStatus - case kindBoxReceivedStatus: - return KindBoxReceivedStatus - case kindBoxEnumeratedStatus: - return KindBoxEnumeratedStatus - } - - return KindBoxStatus(0) -} - -package entity - -type KindBoxStatus uint - -const ( - KindBoxPendingSendStatus KindBoxStatus = iota + 1 - KindBoxSentStatus - KindBoxPendingReceivedStatus - KindBoxReceivedStatus - KindBoxEnumeratedStatus -) - var kindBoxStatusStrings = map[KindBoxStatus]string{ KindBoxPendingSendStatus: "pending-send", KindBoxSentStatus: "sent", @@ -94,12 +40,3 @@ func MapToKindBoxStatus(statusStr string) KindBoxStatus { } return KindBoxStatus(0) } - -// AllKindBoxStatus returns a slice containing all string values of KindBoxStatus. -func AllKindBoxStatus() []string { - statusStrings := make([]string, len(kindBoxStatusStrings)) - for status, str := range kindBoxStatusStrings { - statusStrings[int(status)-1] = str - } - return statusStrings -} \ No newline at end of file diff --git a/service/admin/kind_box/get.go b/service/admin/kind_box/get.go index 380ba3f..a3ff2d9 100644 --- a/service/admin/kind_box/get.go +++ b/service/admin/kind_box/get.go @@ -4,7 +4,6 @@ import ( "context" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" - 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/update.go b/service/admin/kind_box/update.go index 0838264..eba5087 100644 --- a/service/admin/kind_box/update.go +++ b/service/admin/kind_box/update.go @@ -5,7 +5,6 @@ import ( entity "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" ) diff --git a/service/admin/kind_box_req/update.go b/service/admin/kind_box_req/update.go index d3bf686..63ee211 100644 --- a/service/admin/kind_box_req/update.go +++ b/service/admin/kind_box_req/update.go @@ -5,7 +5,6 @@ import ( entity "git.gocasts.ir/ebhomengo/niki/entity" 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" ) @@ -16,17 +15,6 @@ func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest) const op = "adminkindboxreqservice.Update" - kbr, gErr := s.repo.GetKindBoxReq(ctx, req.KindBoxReqID) - if gErr != nil { - return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected) - } - if kbr.BenefactorID != req.BenefactorID { - return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgUserNotAllowed).WithKind(richerror.KindForbidden) - } - if kbr.Status != entity.KindBoxReqPendingStatus { - return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid) - } - kindBoxReq, uErr := s.repo.UpdateKindBoxReq(ctx, req.KindBoxReqID, entity.KindBoxReq{ BenefactorID: req.BenefactorID, TypeID: req.TypeID, diff --git a/service/benefactor/kind_box/get.go b/service/benefactor/kind_box/get.go index e33ae93..19ee41a 100644 --- a/service/benefactor/kind_box/get.go +++ b/service/benefactor/kind_box/get.go @@ -4,7 +4,6 @@ import ( "context" param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box" - errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg" richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error" ) @@ -15,7 +14,6 @@ func (s Service) Get(ctx context.Context, req param.KindBoxGetRequest) (param.Ki if err != nil { return param.KindBoxGetResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected) } - return param.KindBoxGetResponse{KindBox: kindBox}, nil }