forked from Olympic/NTO-2025-Backend-TeamTask
ура
This commit is contained in:
@@ -52,10 +52,16 @@ public class BookingController {
|
||||
@PostMapping("/{code}/book")
|
||||
public ResponseEntity<?> createBooking(
|
||||
@PathVariable String code,
|
||||
@RequestBody Long placeId,
|
||||
@RequestBody String date
|
||||
@RequestBody Map<String, Object> body
|
||||
) {
|
||||
try {
|
||||
Long placeId = body.get("placeId") != null
|
||||
? Long.valueOf(body.get("placeId").toString())
|
||||
: null;
|
||||
|
||||
String date = body.get("date") != null
|
||||
? body.get("date").toString()
|
||||
: null;
|
||||
if (placeId == null || date == null || date.isEmpty()) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
|
||||
.body("Place ID and date must be provided");
|
||||
@@ -85,7 +91,7 @@ public class BookingController {
|
||||
.body("Place already booked for this date");
|
||||
}
|
||||
Booking booking = new Booking();
|
||||
booking.setEmployee((Map<String, Object>) employee);
|
||||
booking.setEmployee(employee);
|
||||
booking.setPlace(place);
|
||||
booking.setDate(bookingDate);
|
||||
bookingRepository.save(booking);
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,7 +57,7 @@ public class Booking {
|
||||
this.place = place;
|
||||
}
|
||||
|
||||
public void setEmployee(Map<String, Object> employee) {
|
||||
public void setEmployee(Employee employee) {
|
||||
this.employee = (Employee) employee;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class BookingServiceImpl implements BookingService {
|
||||
throw new IllegalArgumentException("Place already booked for this date");
|
||||
}
|
||||
Booking booking = new Booking();
|
||||
booking.setEmployee((Map<String, Object>) employee);
|
||||
booking.setEmployee((Employee) employee);
|
||||
booking.setPlace(place);
|
||||
booking.setDate(bookingDate);
|
||||
bookingRepository.save(booking);
|
||||
|
||||
Reference in New Issue
Block a user