Files
NTO-2025-Backend-TeamTask/src/main/java/com/example/nto/service/impl/EmployeeServiceImpl.java
Bhumi Shah d836b0bfe2 1234
2025-12-07 00:48:14 +03:00

29 lines
1.1 KiB
Java

package com.example.nto.service.impl;
import com.example.nto.entity.Employee;
import com.example.nto.excepation.EmployeeNotFoundException;
import com.example.nto.repository.EmployeeRepository;
import com.example.nto.service.EmployeeService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* TODO: ДОРАБОТАТЬ в рамках задания
* =================================
* МОЖНО: Добавлять методы, аннотации, зависимости
* НЕЛЬЗЯ: Изменять название класса и пакета
*/
@Service
@RequiredArgsConstructor
public class EmployeeServiceImpl implements EmployeeService {
@Autowired
private EmployeeRepository employeeRepository;
@Override
public Employee getEmployeeByCode(String code) {
if (code == null || code.isEmpty()) {
throw new IllegalArgumentException("Employee code is required");
}
return employeeRepository.findByCode(code).orElseThrow(() -> new EmployeeNotFoundException("Employee not found"));
}
}