package com.example.nto.service.impl; import com.example.nto.dto.EmployeeDTO; import com.example.nto.entity.Employee; import com.example.nto.exception.CodeNotFoundException; import com.example.nto.repository.EmployeeRepository; import com.example.nto.service.EmployeeService; import com.example.nto.util.EmployeeMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * TODO: ДОРАБОТАТЬ в рамках задания * ================================= * МОЖНО: Добавлять методы, аннотации, зависимости * НЕЛЬЗЯ: Изменять название класса и пакета */ @Service public class EmployeeServiceImpl implements EmployeeService { @Autowired EmployeeRepository employeeRepository; @Override public boolean codeExists(String code) { boolean codeExists = employeeRepository.existsByCode(code); if(!codeExists) { throw new CodeNotFoundException("Code Not Found"); } return employeeRepository.existsByCode(code); } @Override public EmployeeDTO getInfo(String code) { this.codeExists(code); Employee employee = employeeRepository.findByCode(code); return EmployeeMapper.convertToDTO(employee); } }