package com.service.impl;

import com.entity.SignUpUser;
import com.repository.RegistrationRepository;
import com.service.RegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
import java.sql.SQLException;

/**
 *
 * Implementation of the registration service.
 *
 * @author Laurentiu Marcut
 */
public class RegistrationServiceImpl implements RegistrationService {

    @Autowired
    private RegistrationRepository registrationRepository;

    @Override
    public boolean checkEmail(String email) throws SQLException {
        return this.registrationRepository.checkEmail(email);
    }

    @Override
    public void insertUser(SignUpUser user) throws SQLException {
        this.registrationRepository.insertUser(user);
        this.registrationRepository.insertUserRole(user.getEmail(), "ROLE_USER");
    }

}
