1111
Some checks failed
Android Test / validate-and-test (pull_request) Has been cancelled

This commit is contained in:
Bhumi Shah
2025-12-05 23:02:14 +03:00
parent f6acec1b98
commit 3b64ad9626
9 changed files with 53 additions and 87 deletions

View File

@@ -4,7 +4,10 @@ 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 lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -15,19 +18,17 @@ import org.springframework.stereotype.Service;
* НЕЛЬЗЯ: Изменять название класса и пакета
*/
@Service
@RequiredArgsConstructor
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;
}
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"));
}
}