Upstream sync
This commit is contained in:
37
application/applicationservice/zipcode.go
Normal file
37
application/applicationservice/zipcode.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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"
|
||||
)
|
||||
|
||||
// zipcodeService holds methods to participating zipcode application service
|
||||
type zipcodeService struct {
|
||||
svc *service.Service
|
||||
mapEntity *entitymapping.Mapper
|
||||
}
|
||||
|
||||
// newZipcodeService returns a zipcodeService instance
|
||||
func newZipcodeService(svc *service.Service, mapper *entitymapping.Mapper) *zipcodeService {
|
||||
return &zipcodeService{
|
||||
svc: svc,
|
||||
mapEntity: mapper,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *zipcodeService) GetAll() ([]viewmodel.Zipcode, error) {
|
||||
result, err := s.svc.Zipcodes.GetAll()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.mapEntity.Zipcode.ToZipcodeModelSlice(result), nil
|
||||
}
|
||||
|
||||
func (s *zipcodeService) GetByParticipatingZipcode(zipcode string) (viewmodel.Zipcode, error) {
|
||||
result, err := s.svc.Zipcodes.GetByParticipatingZipcode(zipcode)
|
||||
if err != nil {
|
||||
return viewmodel.Zipcode{}, err
|
||||
}
|
||||
return s.mapEntity.Zipcode.ToZipcodeModel(result), nil
|
||||
}
|
||||
Reference in New Issue
Block a user