add password reset model ; create entry in database; send email
This commit is contained in:
@@ -13,16 +13,17 @@ var (
|
||||
|
||||
// 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
|
||||
Zipcode *zipcodeMapping
|
||||
Plan *planMapping
|
||||
User *userMapping
|
||||
Ride *rideMapping
|
||||
Visit *visitMapping
|
||||
Address *addressMapping
|
||||
Provider *providerMapping
|
||||
Notification *notificationMapping
|
||||
Profile *profileMapping
|
||||
Organization *organizationMapping
|
||||
Zipcode *zipcodeMapping
|
||||
Plan *planMapping
|
||||
PasswordReset *passwordResetMapping
|
||||
}
|
||||
|
||||
// New returns an EntityMapper for fluent mapping
|
||||
@@ -40,6 +41,7 @@ func New() *Mapper {
|
||||
instance.Organization = &organizationMapping{instance}
|
||||
instance.Zipcode = &zipcodeMapping{instance}
|
||||
instance.Plan = &planMapping{instance}
|
||||
instance.PasswordReset = &passwordResetMapping{instance}
|
||||
})
|
||||
|
||||
return instance
|
||||
|
||||
59
application/entitymapping/passwordreset.go
Normal file
59
application/entitymapping/passwordreset.go
Normal file
@@ -0,0 +1,59 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user