forked from ebhomengo/niki
1
0
Fork 0
niki/service/admin/benefactor/get.go

32 lines
1.1 KiB
Go
Raw Normal View History

package adminbenefactorservice
import (
"context"
param "git.gocasts.ir/ebhomengo/niki/param/admin/admin"
params "git.gocasts.ir/ebhomengo/niki/param/admin/benefactor"
richerror "git.gocasts.ir/ebhomengo/niki/pkg/rich_error"
)
func (s Service) GetByID(ctx context.Context, req params.GetBenefactorByIDRequest) (params.GetBenefactorByIDResponse, error) {
const op = "adminbenefactorservice.GetByID"
bnf, gErr := s.benefactorService.GetByID(ctx, req)
if gErr != nil {
return params.GetBenefactorByIDResponse{}, richerror.New(op).WithErr(gErr)
}
return params.GetBenefactorByIDResponse{Benefactor: bnf.Benefactor}, nil
}
func (s Service) BenefactorExistByID(ctx context.Context, req param.BenefactorExistByIDRequest) (param.BenefactorExistByIDResponse, error) {
const op = "adminbenefactorservice.BenefactorExistByID"
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
}