This commit is contained in:
indx0
2025-11-21 21:39:00 +03:00
parent a612c92833
commit 02a8c05142
11 changed files with 92 additions and 28 deletions

View File

@@ -2,6 +2,7 @@ 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;
@@ -22,11 +23,15 @@ public class EmployeeServiceImpl implements EmployeeService {
@Override
public boolean codeExists(String code) {
boolean codeExists = employeeRepository.existsByCode(code);
return codeExists;
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);
}