|
|
@ -244,22 +244,28 @@ public class BookingService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Map<String, Object> getOccupiedSeats(String bookingDate, Long slotId) { |
|
|
public Map<String, Object> getOccupiedSeats(String bookingDate, Long slotId) { |
|
|
String sql = " SELECT bs.booking_id, r.group_id, bs.seat_no " + |
|
|
|
|
|
|
|
|
String sql = "SELECT bs.booking_id, r.group_id, bs.seat_no " + |
|
|
"FROM booking_slots bs " + |
|
|
"FROM booking_slots bs " + |
|
|
"JOIN registration_details r ON r.id = bs.booking_id " + |
|
|
"JOIN registration_details r ON r.id = bs.booking_id " + |
|
|
"WHERE r.booking_date = ? AND r.slot_id = ? AND r.is_delete = 0 " + |
|
|
"WHERE r.booking_date = ? AND r.slot_id = ? AND r.is_delete = 0 " + |
|
|
"LIMIT 1"; |
|
|
"LIMIT 1"; |
|
|
|
|
|
|
|
|
Map<String, Object> row = jdbc.queryForMap( |
|
|
|
|
|
|
|
|
List<Map<String, Object>> rows = jdbc.queryForList( |
|
|
sql, |
|
|
sql, |
|
|
LocalDate.parse(bookingDate), |
|
|
LocalDate.parse(bookingDate), |
|
|
slotId |
|
|
slotId |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
Long bookingId = ((Number) row.get("booking_id")).longValue(); |
|
|
|
|
|
Long groupId = ((Number) row.get("group_id")).longValue(); |
|
|
|
|
|
|
|
|
Long bookingId = null; |
|
|
|
|
|
Long groupId = null; |
|
|
|
|
|
|
|
|
String seatSql = " SELECT bs.seat_no " + |
|
|
|
|
|
|
|
|
if (!rows.isEmpty()) { |
|
|
|
|
|
Map<String, Object> row = rows.get(0); |
|
|
|
|
|
bookingId = ((Number) row.get("booking_id")).longValue(); |
|
|
|
|
|
groupId = ((Number) row.get("group_id")).longValue(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String seatSql = "SELECT bs.seat_no " + |
|
|
"FROM booking_slots bs " + |
|
|
"FROM booking_slots bs " + |
|
|
"JOIN registration_details r ON r.id = bs.booking_id " + |
|
|
"JOIN registration_details r ON r.id = bs.booking_id " + |
|
|
"WHERE r.booking_date = ? AND r.slot_id = ? AND r.is_delete = 0 "; |
|
|
"WHERE r.booking_date = ? AND r.slot_id = ? AND r.is_delete = 0 "; |
|
|
@ -282,11 +288,14 @@ public class BookingService { |
|
|
result.put("occupiedSeats", occupiedSeats); |
|
|
result.put("occupiedSeats", occupiedSeats); |
|
|
result.put("capacity", slotCapacity); |
|
|
result.put("capacity", slotCapacity); |
|
|
|
|
|
|
|
|
Map<String, Object> booking = new HashMap<>(); |
|
|
|
|
|
booking.put("booking_id", bookingId); |
|
|
|
|
|
booking.put("group_id", groupId); |
|
|
|
|
|
|
|
|
|
|
|
result.put("bookings", Collections.singletonList(booking)); |
|
|
|
|
|
|
|
|
if (bookingId != null && groupId != null) { |
|
|
|
|
|
Map<String, Object> booking = new HashMap<>(); |
|
|
|
|
|
booking.put("booking_id", bookingId); |
|
|
|
|
|
booking.put("group_id", groupId); |
|
|
|
|
|
result.put("bookings", Collections.singletonList(booking)); |
|
|
|
|
|
} else { |
|
|
|
|
|
result.put("bookings", Collections.emptyList()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|