示例#1
0
文件: user.go 项目: byrnedo/usersvc
func (uU *UpdateUserDTO) MapToEntity() (*models.UserModel, error) {

	var err error
	if len(uU.Password) > 0 {
		if uU.Password, err = encryptPassword(uU.Password); err != nil {
			return nil, err
		}
	}
	return &models.UserModel{
		ID:         bson.ObjectIdHex(uU.ID),
		Alias:      uU.Alias,
		FirstName:  encBson.EncryptedString(uU.FirstName),
		LastName:   encBson.EncryptedString(uU.LastName),
		Email:      uU.Email,
		Password:   uU.Password,
		Role:       uU.Role,
		UpdateTime: bson.Now(),
	}, nil
}
示例#2
0
文件: user.go 项目: byrnedo/usersvc
func (nU *NewUserDTO) MapToEntity() (*models.UserModel, error) {
	var (
		now = bson.Now()
		err error
	)

	if nU.Password, err = encryptPassword(nU.Password); err != nil {
		return nil, err
	}

	return &models.UserModel{
		ID:           bson.NewObjectId(),
		Alias:        nU.Alias,
		FirstName:    encBson.EncryptedString(nU.FirstName),
		LastName:     encBson.EncryptedString(nU.LastName),
		Email:        nU.Email,
		Password:     nU.Password,
		Role:         nU.Role,
		CreationTime: now,
		UpdateTime:   now,
	}, nil
}