Free Places initial implementation
This commit is contained in:
@@ -28,7 +28,7 @@ public class BookingController {
|
|||||||
|
|
||||||
@GetMapping("/{code}/booking")
|
@GetMapping("/{code}/booking")
|
||||||
public ResponseEntity<Map<LocalDate, List<Place>>> getAvailablePlaces(@PathVariable String code) {
|
public ResponseEntity<Map<LocalDate, List<Place>>> getAvailablePlaces(@PathVariable String code) {
|
||||||
return ResponseEntity.noContent().build();
|
return ResponseEntity.ok(bookingService.getAvailablePlaces(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/{code}/book")
|
@PostMapping("/{code}/book")
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ import java.util.Map;
|
|||||||
* НЕЛЬЗЯ: Изменять название класса и пакета
|
* НЕЛЬЗЯ: Изменять название класса и пакета
|
||||||
*/
|
*/
|
||||||
public interface BookingService {
|
public interface BookingService {
|
||||||
Map<LocalDate, List<Place>> getAvailablePlaces();
|
Map<LocalDate, List<Place>> getAvailablePlaces(String code);
|
||||||
void createBooking(CreateBookingDTO createBookingDTO, 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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -34,8 +35,21 @@ public class BookingServiceImpl implements BookingService {
|
|||||||
EmployeeRepository employeeRepository;
|
EmployeeRepository employeeRepository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<LocalDate, List<Place>> getAvailablePlaces() {
|
public Map<LocalDate, List<Place>> getAvailablePlaces(String code) {
|
||||||
return Map.of();
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user