This commit is contained in:
Bhumi Shah
2025-12-08 18:36:42 +03:00
parent 3c3ef45d78
commit c43e4b18fb
4 changed files with 9 additions and 4 deletions

View File

@@ -41,5 +41,4 @@ public class Employee {
public String getName() { return name; }
public String getCode() { return code; }
public String getPhotoUrl() { return photoUrl; }
public List<Booking> getBookings() { return bookings; }
}

View File

@@ -1,5 +1,7 @@
package com.example.nto.excepation;
public class EmployeeNotFoundException extends RuntimeException{
public EmployeeNotFoundException(String message) {super(message);}
public EmployeeNotFoundException(String message) {
super(message);
}
}

View File

@@ -13,4 +13,6 @@ import java.util.Optional;
* НЕЛЬЗЯ: Изменять название класса и пакета
*/
@Repository
public interface EmployeeRepository extends JpaRepository<Employee, Long> {Optional<Employee> findByCode(String code);}
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
Optional<Employee> findByCode(String code);
}

View File

@@ -71,7 +71,9 @@ public class BookingServiceImpl implements BookingService {
} catch (Exception e) {
throw new IllegalArgumentException("Invalid date format. Use yyyy-MM-dd");
}
boolean exists = bookingRepository.findByDateBetween(bookingDate, bookingDate).stream().anyMatch(b -> b.getPlace().getId() == placeId);
boolean exists = bookingRepository.findByDateBetween(bookingDate, bookingDate).stream().anyMatch(
b -> b.getPlace()
.getId() == placeId);
if (exists) {
throw new IllegalArgumentException("Place already booked for this date");
}