Upstream sync
This commit is contained in:
@@ -21,6 +21,7 @@ type Mapper struct {
|
||||
Notification *notificationMapping
|
||||
Profile *profileMapping
|
||||
Organization *organizationMapping
|
||||
Zipcode *zipcodeMapping
|
||||
}
|
||||
|
||||
// New returns an EntityMapper for fluent mapping
|
||||
@@ -36,6 +37,7 @@ func New() *Mapper {
|
||||
instance.Notification = ¬ificationMapping{instance}
|
||||
instance.Profile = &profileMapping{instance}
|
||||
instance.Organization = &organizationMapping{instance}
|
||||
instance.Zipcode = &zipcodeMapping{instance}
|
||||
})
|
||||
|
||||
return instance
|
||||
|
||||
51
application/entitymapping/zipcode.go
Normal file
51
application/entitymapping/zipcode.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package entitymapping
|
||||
|
||||
import (
|
||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||
)
|
||||
|
||||
// zipcodeMapping has method to map zipcode entities to view models
|
||||
type zipcodeMapping struct {
|
||||
mapper *Mapper
|
||||
}
|
||||
|
||||
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||
func (mapping *zipcodeMapping) ToZipcodeEntitySlice(list []viewmodel.Zipcode) (retVal []entity.Zipcode) {
|
||||
retVal = make([]entity.Zipcode, 0)
|
||||
|
||||
for _, item := range list {
|
||||
retVal = append(retVal, mapping.ToZipcodeEntity(item))
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (mapping *zipcodeMapping) ToZipcodeEntity(model viewmodel.Zipcode) entity.Zipcode {
|
||||
return entity.Zipcode{
|
||||
ID: model.ID,
|
||||
UUID: model.UUID,
|
||||
Zipcode: model.Zipcode,
|
||||
Participating: model.Participating,
|
||||
}
|
||||
}
|
||||
|
||||
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||
func (mapping *zipcodeMapping) ToZipcodeModelSlice(list []entity.Zipcode) (retVal []viewmodel.Zipcode) {
|
||||
retVal = make([]viewmodel.Zipcode, 0)
|
||||
|
||||
for _, item := range list {
|
||||
retVal = append(retVal, mapping.ToZipcodeModel(item))
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (mapping *zipcodeMapping) ToZipcodeModel(model entity.Zipcode) viewmodel.Zipcode {
|
||||
return viewmodel.Zipcode{
|
||||
ID: model.ID,
|
||||
UUID: model.UUID,
|
||||
Zipcode: model.Zipcode,
|
||||
Participating: model.Participating,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user