Upstream sync
This commit is contained in:
@@ -21,7 +21,8 @@ type Mapper struct {
|
||||
Notification *notificationMapping
|
||||
Profile *profileMapping
|
||||
Organization *organizationMapping
|
||||
Zipcode *zipcodeMapping
|
||||
Zipcode *zipcodeMapping
|
||||
Plan *planMapping
|
||||
}
|
||||
|
||||
// New returns an EntityMapper for fluent mapping
|
||||
@@ -38,6 +39,7 @@ func New() *Mapper {
|
||||
instance.Profile = &profileMapping{instance}
|
||||
instance.Organization = &organizationMapping{instance}
|
||||
instance.Zipcode = &zipcodeMapping{instance}
|
||||
instance.Plan = &planMapping{instance}
|
||||
})
|
||||
|
||||
return instance
|
||||
|
||||
65
application/entitymapping/plan.go
Normal file
65
application/entitymapping/plan.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package entitymapping
|
||||
|
||||
import (
|
||||
"bitbucket.org/nemt/nemt-portal-api/application/viewmodel"
|
||||
"bitbucket.org/nemt/nemt-portal-api/domain/entity"
|
||||
)
|
||||
|
||||
// providerMapping has method to map provider entities to view models
|
||||
type planMapping struct {
|
||||
mapper *Mapper
|
||||
}
|
||||
|
||||
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||
func (mapping *planMapping) ToPlanEntitySlice(list []viewmodel.Plan) (retVal []entity.Plan) {
|
||||
retVal = make([]entity.Plan, 0)
|
||||
|
||||
for _, item := range list {
|
||||
retVal = append(retVal, mapping.ToPlanEntity(item))
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (mapping *planMapping) ToPlanEntity(model viewmodel.Plan) entity.Plan {
|
||||
return entity.Plan{
|
||||
UUID: model.ID,
|
||||
Name: model.Name,
|
||||
InternalID: model.InternalID,
|
||||
Status: model.Status,
|
||||
PlanEntityID: model.PlanEntityID,
|
||||
EntityID: model.EntityID,
|
||||
PayerID: model.PayerID,
|
||||
PayerName: model.PayerName,
|
||||
PrefixUUID: model.PrefixID,
|
||||
AlphaPrefix: model.AlphaPrefix,
|
||||
Active: model.Active,
|
||||
}
|
||||
}
|
||||
|
||||
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||
func (mapping *planMapping) ToPlanModelSlice(list []entity.Plan) (retVal []viewmodel.Plan) {
|
||||
retVal = make([]viewmodel.Plan, 0)
|
||||
|
||||
for _, item := range list {
|
||||
retVal = append(retVal, mapping.ToPlanModel(item))
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (mapping *planMapping) ToPlanModel(model entity.Plan) viewmodel.Plan {
|
||||
return viewmodel.Plan{
|
||||
ID: model.UUID,
|
||||
Name: model.Name,
|
||||
InternalID: model.InternalID,
|
||||
Status: model.Status,
|
||||
PlanEntityID: model.PlanEntityID,
|
||||
EntityID: model.EntityID,
|
||||
PayerID: model.PayerID,
|
||||
PayerName: model.PayerName,
|
||||
PrefixID: model.PrefixUUID,
|
||||
AlphaPrefix: model.AlphaPrefix,
|
||||
Active: model.Active,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user