use of com.ncedu.fooddelivery.api.v1.mappers.RegistrationMapper in project 2021-msk-food-delivery by netcracker-edu.
the class AuthServiceImpl method signUp.
@Override
public isCreatedDTO signUp(NewUserDTO userInfo) {
RegistrationMapper regMapper = RegistrationMapper.INSTANCE;
userInfo.setPassword(encoder.encode(userInfo.getPassword()));
User user = regMapper.dtoToUser(userInfo);
user.setRegDate(Timestamp.valueOf(LocalDateTime.now()));
if (Role.isCLIENT(userInfo.getRole())) {
Client client = regMapper.dtoToClient(userInfo);
user.setClient(client);
}
if (Role.isMODERATOR(userInfo.getRole())) {
Moderator moderator = regMapper.dtoToModerator(userInfo);
user.setModerator(moderator);
}
user = userRepo.save(user);
Long userId = user.getId();
return new isCreatedDTO(userId);
}
Aggregations