Compare commits

...

3 Commits

Author SHA1 Message Date
Bhumi Shah
5d2d30992e ура 2025-12-06 17:15:20 +03:00
Bhumi Shah
18b3e950c1 ура 2025-12-06 17:14:50 +03:00
Bhumi Shah
0cf5cfdf59 ура 2025-12-06 17:13:28 +03:00
3 changed files with 11 additions and 7 deletions

View File

@@ -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);

View File

@@ -7,7 +7,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDate;
import java.util.Map;
/**
@@ -57,8 +56,7 @@ public class Booking {
public void setPlace(Place place) {
this.place = place;
}
public void setEmployee(Map<String, Object> employee) {
public void setEmployee(Employee employee) {
this.employee = (Employee) employee;
}
}

View File

@@ -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);