2024-07-30 14:20:49 +00:00
|
|
|
package adminbenefactorservice
|
2024-06-21 06:57:35 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-07-30 14:20:49 +00:00
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
|
2024-06-21 06:57:35 +00:00
|
|
|
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
|
|
|
|
)
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
func (s Service) GetByID(ctx context.Context, req param.GetBenefactorByIDRequest) (param.GetBenefactorByIDResponse, error) {
|
2024-07-30 14:20:49 +00:00
|
|
|
const op = "adminbenefactorservice.GetByID"
|
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
bnf, gErr := s.repo.GetByID(ctx, req.BenefactorID)
|
2024-07-27 16:17:13 +00:00
|
|
|
if gErr != nil {
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.GetBenefactorByIDResponse{}, richerror.New(op).WithErr(gErr)
|
2024-07-27 16:17:13 +00:00
|
|
|
}
|
2024-07-30 14:20:49 +00:00
|
|
|
|
2024-08-01 10:20:18 +00:00
|
|
|
return param.GetBenefactorByIDResponse{Benefactor: bnf}, nil
|
2024-07-27 16:17:13 +00:00
|
|
|
}
|
|
|
|
|
2024-06-21 06:57:35 +00:00
|
|
|
func (s Service) BenefactorExistByID(ctx context.Context, req param.BenefactorExistByIDRequest) (param.BenefactorExistByIDResponse, error) {
|
2024-07-30 14:20:49 +00:00
|
|
|
const op = "adminbenefactorservice.BenefactorExistByID"
|
2024-06-21 06:57:35 +00:00
|
|
|
|
|
|
|
isExisted, err := s.repo.IsExistBenefactorByID(ctx, req.ID)
|
|
|
|
if err != nil {
|
|
|
|
return param.BenefactorExistByIDResponse{}, richerror.New(op).WithErr(err).WithKind(richerror.KindUnexpected)
|
|
|
|
}
|
|
|
|
|
|
|
|
return param.BenefactorExistByIDResponse{Existed: isExisted}, nil
|
|
|
|
}
|