Commit #2
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user