initial commit 2

This commit is contained in:
Senad Uka
2018-04-25 13:16:36 +02:00
parent c1520d169c
commit 99c10b75fb
167 changed files with 25057 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
package entitymapping
import (
"strings"
"sync"
)
var (
instance *Mapper
once sync.Once
)
// Mapper has mapping methods to map entities to view models
type Mapper struct {
User *userMapping
Ride *rideMapping
Visit *visitMapping
Address *addressMapping
Provider *providerMapping
Notification *notificationMapping
Profile *profileMapping
Organization *organizationMapping
}
// New returns an EntityMapper for fluent mapping
func New() *Mapper {
once.Do(func() {
instance = &Mapper{}
instance.User = &userMapping{instance}
instance.Ride = &rideMapping{instance}
instance.Visit = &visitMapping{instance}
instance.Address = &addressMapping{instance}
instance.Provider = &providerMapping{instance}
instance.Notification = &notificationMapping{instance}
instance.Profile = &profileMapping{instance}
instance.Organization = &organizationMapping{instance}
})
return instance
}
// isEmpty returns the alternative option in case the first is empty
func ifEmpty(firstOption string, alternativeOption string) string {
if strings.TrimSpace(firstOption) == "" {
return alternativeOption
}
return firstOption
}