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-06-21 06:57:35 +00:00
|
|
|
param "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
|
2024-07-27 16:17:13 +00:00
|
|
|
params "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-07-27 16:17:13 +00:00
|
|
|
func (s Service) GetByID(ctx context.Context, req params.GetBenefactorByIDRequest) (params.GetBenefactorByIDResponse, error) {
|
2024-07-30 14:20:49 +00:00
|
|
|
const op = "adminbenefactorservice.GetByID"
|
|
|
|
|
|
|
|
bnf, gErr := s.benefactorService.GetByID(ctx, req)
|
2024-07-27 16:17:13 +00:00
|
|
|
if gErr != nil {
|
|
|
|
return params.GetBenefactorByIDResponse{}, richerror.New(op).WithErr(gErr)
|
|
|
|
}
|
2024-07-30 14:20:49 +00:00
|
|
|
|
|
|
|
return params.GetBenefactorByIDResponse{Benefactor: bnf.Benefactor}, 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
|
|
|
|
}
|