Search in sources :

Example 1 with RegistrationMapper

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);
}
Also used : RegistrationMapper(com.ncedu.fooddelivery.api.v1.mappers.RegistrationMapper) com.ncedu.fooddelivery.api.v1.dto.isCreatedDTO(com.ncedu.fooddelivery.api.v1.dto.isCreatedDTO)

Aggregations

com.ncedu.fooddelivery.api.v1.dto.isCreatedDTO (com.ncedu.fooddelivery.api.v1.dto.isCreatedDTO)1 RegistrationMapper (com.ncedu.fooddelivery.api.v1.mappers.RegistrationMapper)1