This commit is contained in:
Bhumi Shah
2025-12-07 00:48:14 +03:00
parent 5d2d30992e
commit d836b0bfe2
6 changed files with 23 additions and 85 deletions

View File

@@ -1,13 +1,10 @@
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 lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
@@ -22,13 +19,11 @@ import org.springframework.stereotype.Service;
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"));
return employeeRepository.findByCode(code).orElseThrow(() -> new EmployeeNotFoundException("Employee not found"));
}
}