package peserta import ( "context" "service/pkg/errors" ) type Service interface { GetPesertaByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error) GetPesertaByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error) } type service struct { repo Repository } func NewService(repo Repository) Service { return &service{repo: repo} } func (s *service) GetPesertaByNoKartu(ctx context.Context, noKartu, tglSEP string) (*PesertaData, error) { if noKartu == "" || tglSEP == "" { return nil, errors.NewValidationError().Message("Nomor Kartu dan Tanggal SEP wajib diisi").Build() } res, err := s.repo.GetByNoKartu(ctx, noKartu, tglSEP) if err != nil { return nil, errors.ExternalError().Message("Gagal mengambil data peserta BPJS berdasarkan No Kartu").Cause(err).Build() } return res, nil } func (s *service) GetPesertaByNIK(ctx context.Context, nik, tglSEP string) (*PesertaData, error) { if nik == "" || tglSEP == "" { return nil, errors.NewValidationError().Message("NIK dan Tanggal SEP wajib diisi").Build() } res, err := s.repo.GetByNIK(ctx, nik, tglSEP) if err != nil { return nil, errors.ExternalError().Message("Gagal mengambil data peserta BPJS berdasarkan NIK").Cause(err).Build() } return res, nil }