This commit is contained in:
@@ -5,15 +5,51 @@ namespace App\Controller;
|
||||
use App\Repository\FareTableRepository;
|
||||
use App\Repository\RoomAvailabilityRepository;
|
||||
use App\Repository\RoomCategoryRepository;
|
||||
use App\Request\SearchAvailabilityPeriodRequest;
|
||||
use App\Response\SearchAvailabilityResponse;
|
||||
use App\Request\SearchFareCategoryRequest;
|
||||
use App\Response\SearchFareCategoryResponse;
|
||||
use App\Service\PricesService;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
class SearchRoomsController extends AbstractController
|
||||
{
|
||||
#[Route('/api/search/availability', name: 'app_search_availability')]
|
||||
/**
|
||||
* Get availability for all rooms on period.
|
||||
* For each room, the minimal availability will be returned.
|
||||
*/
|
||||
#[Route('/api/search/availability', name: 'app_search_availability', methods: ["POST"])]
|
||||
#[OA\Tag(name: "Searchs")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Each room available',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "results",
|
||||
type: "array",
|
||||
items: new OA\Items(ref: new Model(type: SearchAvailabilityResponse::class))
|
||||
)
|
||||
]
|
||||
)
|
||||
)]
|
||||
#[OA\RequestBody(
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "filter",
|
||||
ref: new Model(type: SearchAvailabilityPeriodRequest::class),
|
||||
),
|
||||
],
|
||||
)
|
||||
)]
|
||||
public function getAvailabilityForPeriod(Request $request, RoomAvailabilityRepository $repoAvailability): Response
|
||||
{
|
||||
$payload = $request->toArray();
|
||||
@@ -30,7 +66,12 @@ class SearchRoomsController extends AbstractController
|
||||
return $this->json(["results" => $rs]);
|
||||
}
|
||||
|
||||
#[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails')]
|
||||
/**
|
||||
* Get Availability for all rooms on each day of a period.
|
||||
* (Not used on Front-end APP)
|
||||
*/
|
||||
#[Route('/api/search/availabilityDetails', name: 'app_search_availabilityDetails', methods: ["POST"])]
|
||||
#[OA\Tag(name: "Searchs")]
|
||||
public function getAvailabilityForPeriodDetails(Request $request, RoomAvailabilityRepository $repoAvailability): Response
|
||||
{
|
||||
$payload = $request->toArray();
|
||||
@@ -44,10 +85,41 @@ class SearchRoomsController extends AbstractController
|
||||
|
||||
$rs = $repoAvailability->getAvailabilityForPeriodDetails($startDate, $endDate);
|
||||
|
||||
return $this->json($rs);
|
||||
return $this->json(["results" => $rs]);
|
||||
}
|
||||
|
||||
#[Route('/api/search/fares', name: 'app_search_faresForCategory')]
|
||||
/**
|
||||
* Get room category price for given period.
|
||||
* Returns price for a room category.
|
||||
* This price is the total for all the selected days by guest number.
|
||||
*/
|
||||
#[Route('/api/search/fares', name: 'app_search_faresForCategory', methods: ["POST"])]
|
||||
#[OA\Tag(name: "Searchs")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Room price by guest number',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "results",
|
||||
type: "array",
|
||||
items: new OA\Items(ref: new Model(type: SearchFareCategoryResponse::class))
|
||||
)
|
||||
]
|
||||
)
|
||||
)]
|
||||
#[OA\RequestBody(
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "filter",
|
||||
ref: new Model(type: SearchFareCategoryRequest::class),
|
||||
),
|
||||
],
|
||||
)
|
||||
)]
|
||||
public function getFaresForCategoryOnPeriod(Request $request, RoomCategoryRepository $repoCat, PricesService $priceService): Response
|
||||
{
|
||||
$payload = $request->toArray();
|
||||
@@ -73,13 +145,13 @@ class SearchRoomsController extends AbstractController
|
||||
$fareList = $priceService->getFinalPricesForSearch($roomCategory, $startDate, $endDate);
|
||||
$rs = [];
|
||||
foreach ($fareList as $key => $value) {
|
||||
$rs[] = [ "guestNumber" => $key, "price" => $value];
|
||||
$rs[] = ["guestNumber" => $key, "price" => $value];
|
||||
}
|
||||
|
||||
return $this->json(["results" => $rs]);
|
||||
}
|
||||
|
||||
#[Route('/search/debug', name: 'app_search_faresDebug')]
|
||||
#[Route('/debug/search', name: 'app_search_faresDebug')]
|
||||
public function faresDebug(Request $request, PricesService $priceService, FareTableRepository $repoFareTable, RoomCategoryRepository $repoCat): Response
|
||||
{
|
||||
$fareTable[] = $repoFareTable->find(1);
|
||||
|
||||
Reference in New Issue
Block a user