Free Places initial implementation
This commit is contained in:
@@ -28,7 +28,7 @@ public class BookingController {
|
||||
|
||||
@GetMapping("/{code}/booking")
|
||||
public ResponseEntity<Map<LocalDate, List<Place>>> getAvailablePlaces(@PathVariable String code) {
|
||||
return ResponseEntity.noContent().build();
|
||||
return ResponseEntity.ok(bookingService.getAvailablePlaces(code));
|
||||
}
|
||||
|
||||
@PostMapping("/{code}/book")
|
||||
|
||||
@@ -13,6 +13,6 @@ import java.util.Map;
|
||||
* НЕЛЬЗЯ: Изменять название класса и пакета
|
||||
*/
|
||||
public interface BookingService {
|
||||
Map<LocalDate, List<Place>> getAvailablePlaces();
|
||||
Map<LocalDate, List<Place>> getAvailablePlaces(String code);
|
||||
void createBooking(CreateBookingDTO createBookingDTO, String code);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -34,8 +35,21 @@ public class BookingServiceImpl implements BookingService {
|
||||
EmployeeRepository employeeRepository;
|
||||
|
||||
@Override
|
||||
public Map<LocalDate, List<Place>> getAvailablePlaces() {
|
||||
return Map.of();
|
||||
public Map<LocalDate, List<Place>> getAvailablePlaces(String code) {
|
||||
employeeService.codeExists(code);
|
||||
|
||||
LocalDate startDate = LocalDate.now();
|
||||
LocalDate endDate = startDate.plusDays(3);
|
||||
|
||||
List<Place> allPlaces = placeRepository.findAll();
|
||||
List<Booking> allBookings = bookingRepository.findByDateBetween(startDate, endDate);
|
||||
|
||||
Map<LocalDate, List<Place>> result = new LinkedHashMap<>();
|
||||
|
||||
for (LocalDate date = startDate; !date.isAfter(endDate); date = date.plusDays(1)) {
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user