58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package applicationservice
|
|
|
|
import (
|
|
"bitbucket.org/nemt/nemt-portal-api/application/entitymapping"
|
|
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
|
"bitbucket.org/nemt/nemt-portal-api/domain/service"
|
|
)
|
|
|
|
// providerService holds methods to provider application service
|
|
type planService struct {
|
|
svc *service.Service
|
|
mapEntity *entitymapping.Mapper
|
|
}
|
|
|
|
// newProviderService returns a providerService instance
|
|
func newPlanService(svc *service.Service, mapper *entitymapping.Mapper) *planService {
|
|
return &planService{
|
|
svc: svc,
|
|
mapEntity: mapper,
|
|
}
|
|
}
|
|
|
|
func (s *planService) GetByAlphaPrefix(alphaPrefix string) (viewmodel.Plan, error) {
|
|
plan, err := s.svc.Plans.GetByAlphaPrefix(alphaPrefix)
|
|
if err != nil {
|
|
return viewmodel.Plan{}, err
|
|
}
|
|
|
|
return s.mapEntity.Plan.ToPlanModel(plan), nil
|
|
}
|
|
|
|
func (s *planService) GetByUUID(planUUID string) ([]viewmodel.Plan, error) {
|
|
plans, err := s.svc.Plans.GetByUUID(planUUID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return s.mapEntity.Plan.ToPlanModelSlice(plans), nil
|
|
}
|
|
|
|
func (s *planService) GetByID(planID int64) ([]viewmodel.Plan, error) {
|
|
plans, err := s.svc.Plans.GetByID(planID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return s.mapEntity.Plan.ToPlanModelSlice(plans), nil
|
|
}
|
|
|
|
func (s *planService) GetByPrefixUUID(prefixUUID string) (viewmodel.Plan, error) {
|
|
plan, err := s.svc.Plans.GetByPrefixUUID(prefixUUID)
|
|
if err != nil {
|
|
return viewmodel.Plan{}, err
|
|
}
|
|
|
|
return s.mapEntity.Plan.ToPlanModel(plan), nil
|
|
}
|