forked from ebhomengo/niki
				
			fix(Benefactor&Admin kind_box_req): refactor some code error (listed in body)
Benefactor: - delete.go -> dErr instead of err - get.go -> import errmsg - update.go -> entity.KindBoxReqPendingStatus instead of KindBoxReqPendingStatus Admin: - delete.go -> dErr instead of err - update.go -> entity.KindBoxReqPendingStatus instead of KindBoxReqPendingStatus
This commit is contained in:
		
							parent
							
								
									1a093a6d69
								
							
						
					
					
						commit
						3e0e8567eb
					
				| 
						 | 
					@ -3,7 +3,6 @@ package adminkindboxreqservice
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entity "git.gocasts.ir/ebhomengo/niki/entity"
 | 
					 | 
				
			||||||
	param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
						param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
				
			||||||
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
						richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -14,8 +13,8 @@ func (s Service) Delete(ctx context.Context, req param.KindBoxReqDeleteRequest)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dErr := s.repo.DeleteKindBoxReq(ctx, req.KindBoxReqID)
 | 
						dErr := s.repo.DeleteKindBoxReq(ctx, req.KindBoxReqID)
 | 
				
			||||||
	if dErr != nil {
 | 
						if dErr != nil {
 | 
				
			||||||
		return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
 | 
							return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(dErr).WithKind(richerror.KindUnexpected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return param.KindBoxReqDeleteResponse{KindBoxReq: kindBoxReq}, nil
 | 
						return param.KindBoxReqDeleteResponse{}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ package adminkindboxreqservice
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entity "git.gocasts.ir/ebhomengo/niki/entity"
 | 
					 | 
				
			||||||
	param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
						param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
				
			||||||
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
						richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@ func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest)
 | 
				
			||||||
	if gErr != nil {
 | 
						if gErr != nil {
 | 
				
			||||||
		return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
 | 
							return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if kbr.Status != KindBoxReqPendingStatus {
 | 
						if kbr.Status != entity.KindBoxReqPendingStatus {
 | 
				
			||||||
		return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid)
 | 
							return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,8 +2,9 @@ package userkindboxreqservice
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
						"git.gocasts.ir/ebhomengo/niki/entity"
 | 
				
			||||||
 | 
						errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entity "git.gocasts.ir/ebhomengo/niki/entity"
 | 
					 | 
				
			||||||
	param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
						param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
				
			||||||
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
						richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
| 
						 | 
					@ -14,19 +15,19 @@ func (s Service) Delete(ctx context.Context, req param.KindBoxReqDeleteRequest)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kbr, gErr := s.repo.GetKindBoxReq(ctx, req.KindBoxReqID)
 | 
						kbr, gErr := s.repo.GetKindBoxReq(ctx, req.KindBoxReqID)
 | 
				
			||||||
	if gErr != nil {
 | 
						if gErr != nil {
 | 
				
			||||||
		return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
 | 
							return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if kbr.Status != KindBoxReqPendingStatus {
 | 
						if kbr.Status != entity.KindBoxReqPendingStatus {
 | 
				
			||||||
		return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid)
 | 
							return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if kbr.BenefactorID != req.BenefactorID {
 | 
						if kbr.BenefactorID != req.BenfactorID {
 | 
				
			||||||
		return param.KindBoxReqGetResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgUserNotAllowed).WithKind(richerror.KindForbidden)
 | 
							return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgUserNotAllowed).WithKind(richerror.KindForbidden)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dErr := s.repo.DeleteKindBoxReq(ctx, req.KindBoxReqID)
 | 
						dErr := s.repo.DeleteKindBoxReq(ctx, req.KindBoxReqID)
 | 
				
			||||||
	if dErr != nil {
 | 
						if dErr != nil {
 | 
				
			||||||
		return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
 | 
							return param.KindBoxReqDeleteResponse{}, richerror.New(op).WithErr(dErr).WithKind(richerror.KindUnexpected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return param.KindBoxReqDeleteResponse{KindBoxReq: kindBoxReq}, nil
 | 
						return param.KindBoxReqDeleteResponse{}, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,8 +3,8 @@ package userkindboxreqservice
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entity "git.gocasts.ir/ebhomengo/niki/entity"
 | 
					 | 
				
			||||||
	param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
						param "git.gocasts.ir/ebhomengo/niki/param/benefactor/kind_box_req"
 | 
				
			||||||
 | 
						errmsg "git.gocasts.ir/ebhomengo/niki/pkg/err_msg"
 | 
				
			||||||
	richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
						richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@ import (
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Pagination, Filters, Sort
 | 
					// TODO: Pagination, Filters, Sort
 | 
				
			||||||
func (s Service) GetAll(ctx context.Context) (param.KindBoxReqGetAllResponse, error) {
 | 
					func (s Service) GetAll(ctx context.Context, req param.KindBoxReqGetAllRequest) (param.KindBoxReqGetAllResponse, error) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const op = "userkindboxreqservice.GetAll"
 | 
						const op = "userkindboxreqservice.GetAll"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@ func (s Service) Update(ctx context.Context, req param.KindBoxReqUpdateRequest)
 | 
				
			||||||
	if gErr != nil {
 | 
						if gErr != nil {
 | 
				
			||||||
		return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
 | 
							return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithErr(gErr).WithKind(richerror.KindUnexpected)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if kbr.Status != KindBoxReqPendingStatus {
 | 
						if kbr.Status != entity.KindBoxReqPendingStatus {
 | 
				
			||||||
		return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid)
 | 
							return param.KindBoxReqUpdateResponse{}, richerror.New(op).WithMessage(errmsg.ErrorMsgInvalidStatus).WithKind(richerror.KindInvalid)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue