30 lines
659 B
Go
30 lines
659 B
Go
package poli
|
|
|
|
import (
|
|
"context"
|
|
"service/pkg/errors"
|
|
)
|
|
|
|
type Service interface {
|
|
GetPoli(ctx context.Context, param string) ([]PoliData, error)
|
|
}
|
|
|
|
type service struct {
|
|
repo Repository
|
|
}
|
|
|
|
func NewService(repo Repository) Service {
|
|
return &service{repo: repo}
|
|
}
|
|
|
|
func (s *service) GetPoli(ctx context.Context, param string) ([]PoliData, error) {
|
|
if param == "" {
|
|
return nil, errors.NewValidationError().Message("Parameter pencarian Poli wajib diisi").Build()
|
|
}
|
|
res, err := s.repo.GetPoli(ctx, param)
|
|
if err != nil {
|
|
return nil, errors.ExternalError().Message("Gagal mengambil referensi Poli Apotek BPJS").Cause(err).Build()
|
|
}
|
|
return res, nil
|
|
}
|