forked from Olympic/NTO-2025-Backend-TeamTask
delet123
This commit is contained in:
@@ -41,5 +41,4 @@ public class Employee {
|
|||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
public String getCode() { return code; }
|
public String getCode() { return code; }
|
||||||
public String getPhotoUrl() { return photoUrl; }
|
public String getPhotoUrl() { return photoUrl; }
|
||||||
public List<Booking> getBookings() { return bookings; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.example.nto.excepation;
|
package com.example.nto.excepation;
|
||||||
|
|
||||||
public class EmployeeNotFoundException extends RuntimeException{
|
public class EmployeeNotFoundException extends RuntimeException{
|
||||||
public EmployeeNotFoundException(String message) {super(message);}
|
public EmployeeNotFoundException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ import java.util.Optional;
|
|||||||
* НЕЛЬЗЯ: Изменять название класса и пакета
|
* НЕЛЬЗЯ: Изменять название класса и пакета
|
||||||
*/
|
*/
|
||||||
@Repository
|
@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);
|
||||||
|
}
|
||||||
@@ -71,7 +71,9 @@ public class BookingServiceImpl implements BookingService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalArgumentException("Invalid date format. Use yyyy-MM-dd");
|
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) {
|
if (exists) {
|
||||||
throw new IllegalArgumentException("Place already booked for this date");
|
throw new IllegalArgumentException("Place already booked for this date");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user