Upstream sync
This commit is contained in:
57
application/applicationservice/plan.go
Normal file
57
application/applicationservice/plan.go
Normal file
@@ -0,0 +1,57 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user