src/Controller/MobileApi/V2/Beauty/Offer/GetMastersWithFilterAction.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Controller\MobileApi\V2\Beauty\Offer;
  4. use Nelmio\ApiDocBundle\Annotation\Model;
  5. use OpenApi\Annotations as OA;
  6. use Slivki\Message\Query\Beauty\Offer\GetMastersWithFilterQuery;
  7. use Slivki\Messenger\Query\QueryBusInterface;
  8. use Slivki\Request\PageAndPerPageRequest;
  9. use Slivki\Response\Beauty\Offer\MasterResponse;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. final class GetMastersWithFilterAction
  13. {
  14.     private QueryBusInterface $queryBus;
  15.     public function __construct(QueryBusInterface $queryBus)
  16.     {
  17.         $this->queryBus $queryBus;
  18.     }
  19.     /**
  20.      * @Route("/mobile/api/v2/beauty/offer/{offerId}/masters_with_filter", methods={"GET"}, name="mobile_api_v2_beauty_offer_masters_with_filter_get")
  21.      * @OA\Tag(name="Beauty"),
  22.      *
  23.      * @OA\Response(
  24.      *     response=200,
  25.      *     description="Все мастера акции с пагинацией",
  26.      *     @OA\JsonContent(
  27.      *             type="array",
  28.      *             @OA\Items(
  29.      *                 @OA\Property(
  30.      *                     property="items",
  31.      *                     type="array",
  32.      *                     description="Мастер",
  33.      *                     @OA\Items(ref=@Model(type=MasterResponse::class)),
  34.      *                 ),
  35.      *                 @OA\Property(
  36.      *                     property="total",
  37.      *                     description="Количество мастеров",
  38.      *                     example=185,
  39.      *                 ),
  40.      *             ),
  41.      *         ),
  42.      *     ),
  43.      * ),
  44.      *
  45.      * @OA\Parameter(
  46.      *     name="offerId",
  47.      *     in="path",
  48.      *     description="The ID of the offer",
  49.      *     @OA\Schema(type="integer", example=12345, nullable=false),
  50.      * ),
  51.      * @OA\Parameter(
  52.      *     name="page",
  53.      *     in="query",
  54.      *     description="Страница",
  55.      *     required=false,
  56.      *     @OA\Schema(type="integer"),
  57.      * ),
  58.      * @OA\Parameter(
  59.      *     name="perPage",
  60.      *     in="query",
  61.      *     description="Лимит",
  62.      *     required=false,
  63.      *     @OA\Schema(type="integer"),
  64.      * ),
  65.      */
  66.     public function __invoke(PageAndPerPageRequest $requestint $offerId): JsonResponse
  67.     {
  68.         return new JsonResponse(
  69.             $this->queryBus->handle(
  70.                 new GetMastersWithFilterQuery(
  71.                     $offerId,
  72.                     $request->getPage(),
  73.                     $request->getPerPage(),
  74.                 ),
  75.             ),
  76.         );
  77.     }
  78. }