60 lines
1.7 KiB
Go
60 lines
1.7 KiB
Go
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 passwordResetMapping struct {
|
|
mapper *Mapper
|
|
}
|
|
|
|
// ToUserEntitySlice maps a User entity slice to User view model slice
|
|
func (mapping *passwordResetMapping) ToPasswordResetEntitySlice(list []viewmodel.PasswordReset) (retVal []entity.PasswordReset) {
|
|
retVal = make([]entity.PasswordReset, 0)
|
|
|
|
for _, item := range list {
|
|
retVal = append(retVal, mapping.ToPasswordResetEntity(item))
|
|
}
|
|
|
|
return retVal
|
|
}
|
|
|
|
func (mapping *passwordResetMapping) ToPasswordResetEntity(model viewmodel.PasswordReset) entity.PasswordReset {
|
|
return entity.PasswordReset{
|
|
ID: model.ID,
|
|
UUID: model.UUID,
|
|
User: mapping.mapper.User.ToUserEntity(model.User),
|
|
Token: model.Token,
|
|
Created: model.Created,
|
|
Expires: model.Expires,
|
|
Used: model.Used,
|
|
Opened: model.Opened,
|
|
}
|
|
}
|
|
|
|
// ToUserEntitySlice maps a User entity slice to User view model slice
|
|
func (mapping *passwordResetMapping) ToPasswordResetModelSlice(list []entity.PasswordReset) (retVal []viewmodel.PasswordReset) {
|
|
retVal = make([]viewmodel.PasswordReset, 0)
|
|
|
|
for _, item := range list {
|
|
retVal = append(retVal, mapping.ToPasswordResetModel(item))
|
|
}
|
|
|
|
return retVal
|
|
}
|
|
|
|
func (mapping *passwordResetMapping) ToPasswordResetModel(model entity.PasswordReset) viewmodel.PasswordReset {
|
|
return viewmodel.PasswordReset{
|
|
ID: model.ID,
|
|
UUID: model.UUID,
|
|
User: mapping.mapper.User.ToUserModel(model.User),
|
|
Token: model.Token,
|
|
Created: model.Created,
|
|
Expires: model.Expires,
|
|
Used: model.Used,
|
|
Opened: model.Opened,
|
|
}
|
|
}
|