package adminkindboxreqservice import ( "context" 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" ) 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" kbr, gErr := s.repo.GetKindBoxReq(ctx, req.KindBoxReqID) if gErr != nil { return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected) } if kbr.BenefactorID != req.BenefactorID { return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgUserNotAllowed).WithKind(richerror.KindForbidden) } if kbr.Status != entity.KindBoxReqPendingStatus { return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid) } 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 }