1234
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user