initial commit 2
This commit is contained in:
69
application/entitymapping/notification.go
Normal file
69
application/entitymapping/notification.go
Normal file
@@ -0,0 +1,69 @@
|
||||
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 notificationMapping struct {
|
||||
mapper *Mapper
|
||||
}
|
||||
|
||||
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||
func (mapping *notificationMapping) ToNotificationEntitySlice(list []viewmodel.Notification) (retVal []entity.Notification) {
|
||||
retVal = make([]entity.Notification, 0)
|
||||
|
||||
for _, item := range list {
|
||||
retVal = append(retVal, mapping.ToNotificationEntity(item))
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (mapping *notificationMapping) ToNotificationEntity(model viewmodel.Notification) entity.Notification {
|
||||
return entity.Notification{
|
||||
UUID: model.UUID,
|
||||
To: model.To,
|
||||
From: model.From,
|
||||
Type: model.Type,
|
||||
Subject: model.Subject,
|
||||
Message: model.Message,
|
||||
Created: model.Created,
|
||||
Ride: entity.Ride{
|
||||
UUID: model.Ride.UUID,
|
||||
},
|
||||
User: mapping.mapper.User.ToUserEntity(model.User),
|
||||
CreatedUser: mapping.mapper.User.ToUserEntity(model.CreatedUser),
|
||||
Read: model.Read,
|
||||
MessageType: model.MessageType,
|
||||
}
|
||||
}
|
||||
|
||||
// ToUserEntitySlice maps a User entity slice to User view model slice
|
||||
func (mapping *notificationMapping) ToNotificationModelSlice(list []entity.Notification) (retVal []viewmodel.Notification) {
|
||||
retVal = make([]viewmodel.Notification, 0)
|
||||
|
||||
for _, item := range list {
|
||||
retVal = append(retVal, mapping.ToNotificationModel(item))
|
||||
}
|
||||
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (mapping *notificationMapping) ToNotificationModel(model entity.Notification) viewmodel.Notification {
|
||||
return viewmodel.Notification{
|
||||
UUID: model.UUID,
|
||||
To: model.To,
|
||||
From: model.From,
|
||||
Type: model.Type,
|
||||
Subject: model.Subject,
|
||||
Message: model.Message,
|
||||
Created: model.Created,
|
||||
Ride: mapping.mapper.Ride.ToRideModel(model.Ride),
|
||||
User: mapping.mapper.User.ToUserModel(model.User),
|
||||
CreatedUser: mapping.mapper.User.ToUserModel(model.CreatedUser),
|
||||
Read: model.Read,
|
||||
MessageType: model.MessageType,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user