33 lines
1.2 KiB
Java
33 lines
1.2 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.BookingRepository;
|
|
import com.example.nto.repository.EmployeeRepository;
|
|
import com.example.nto.service.EmployeeService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
* TODO: ДОРАБОТАТЬ в рамках задания
|
|
* =================================
|
|
* МОЖНО: Добавлять методы, аннотации, зависимости
|
|
* НЕЛЬЗЯ: Изменять название класса и пакета
|
|
*/
|
|
@Service
|
|
public class EmployeeServiceImpl implements EmployeeService {
|
|
@Autowired
|
|
private EmployeeRepository employeeRepository;
|
|
@Override
|
|
public Employee getEmployeeWithBookings(String code) {
|
|
if (code == null || code.isEmpty()) {
|
|
throw new IllegalArgumentException("Employee code cannot be null or empty");
|
|
}
|
|
Employee employee = employeeRepository.findByCode(code);
|
|
if (employee == null) {
|
|
throw new EmployeeNotFoundException("Employee not found with code: " + code);
|
|
}
|
|
return employee;
|
|
}
|
|
|
|
} |