Win
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
package com.example.nto.service.impl;
|
||||
|
||||
import com.example.nto.entity.Booking;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* TODO: ДОРАБОТАТЬ в рамках задания
|
||||
@@ -8,5 +17,25 @@ import com.example.nto.service.EmployeeService;
|
||||
* МОЖНО: Добавлять методы, аннотации, зависимости
|
||||
* НЕЛЬЗЯ: Изменять название класса и пакета
|
||||
*/
|
||||
@Service
|
||||
public class EmployeeServiceImpl implements EmployeeService {
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private EmployeeRepository employeeRepository;
|
||||
|
||||
@Autowired
|
||||
private BookingRepository bookingRepository;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user