src/Controller/API/BuscadorController.php line 50

Open in your IDE?
  1. <?php
  2. namespace App\Controller\API;
  3. use App\Controller\BaseController;
  4. use App\Entity\Log\LogInteraction;
  5. use App\Services\API\BuscadorService;
  6. use App\Utils\APIResponse;
  7. use App\Utils\CommonFunctions;
  8. use Exception;
  9. use OpenApi\Annotations as OA;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. /**
  14.  * @Route("/buscador")
  15.  */
  16. class BuscadorController extends BaseController
  17. {
  18.     /**
  19.      * @Route("", name="get_bloques_buscador", methods={"GET"})
  20.      * @param Request $request
  21.      * @param BuscadorService $buscadorService
  22.      * @return Response
  23.      *
  24.      * @OA\Get(
  25.      *     path="/api/v1/buscador",
  26.      *     summary="Obtener todos los bloques del buscador",
  27.      *     @OA\Parameter(
  28.      *         name="texto",
  29.      *         in="query",
  30.      *         required=false,
  31.      *         @OA\Schema(type="string")
  32.      *     ),
  33.      *     @OA\Response(
  34.      *         response=200,
  35.      *         description="Response",
  36.      *         @OA\MediaType(
  37.      *             mediaType="application/json",
  38.      *             @OA\Schema(
  39.      *                 @OA\Property(property="status", type="integer"),
  40.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  41.      *                 @OA\Property(property="content", type="object")
  42.      *            )
  43.      *        )
  44.      *    )
  45.      * )
  46.      */
  47.     public function buscadorAction(Request $requestBuscadorService $buscadorService)
  48.     {
  49.         $statusCode APIResponse::$SUCCESS;
  50.         $status APIResponse::$SUCCESS;
  51.         $errors = array();
  52.         $result null;
  53.         try {
  54.             $filtros CommonFunctions::parseQueryString($request->getQueryString());
  55.             $result $buscadorService->getBloquesBuscador($filtros);
  56.         } catch (Exception $e) {
  57.             $statusCode APIResponse::$INTERNAL_ERROR;
  58.             $status APIResponse::$INTERNAL_ERROR;
  59.             $errors = array($e->getMessage());
  60.             $errorInfo CommonFunctions::getErrorException($e);
  61.             $this->logInteractionService->addErrorLog(
  62.                 LogInteraction::$LIST,
  63.                 CommonFunctions::getClassMethod(__METHOD__),
  64.                 $e->getMessage(),
  65.                 $errorInfo
  66.             );
  67.         }
  68.         return $this->generateJsonResponse($result$statusCode$status$errors);
  69.     }
  70.     /**
  71.      * @Route("/general/{page}", name="get_buscador_general", methods={"GET"})
  72.      * @param Request $request
  73.      * @param BuscadorService $buscadorService
  74.      * @param $page
  75.      * @return Response
  76.      *
  77.      * @OA\Get(
  78.      *     path="/api/v1/buscador/general/{page}",
  79.      *     summary="Obtener todos los resultados generales del buscador",
  80.      *     @OA\Parameter(
  81.      *         name="texto",
  82.      *         in="query",
  83.      *         required=false,
  84.      *         @OA\Schema(type="string")
  85.      *     ),
  86.      *     @OA\Response(
  87.      *         response=200,
  88.      *         description="Response",
  89.      *         @OA\MediaType(
  90.      *             mediaType="application/json",
  91.      *             @OA\Schema(
  92.      *                 @OA\Property(property="status", type="integer"),
  93.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  94.      *                 @OA\Property(property="content", type="object")
  95.      *            )
  96.      *        )
  97.      *    )
  98.      * )
  99.      */
  100.     public function buscadorGeneralAction(Request $requestBuscadorService $buscadorService$page)
  101.     {
  102.         $statusCode APIResponse::$SUCCESS;
  103.         $status APIResponse::$SUCCESS;
  104.         $errors = array();
  105.         $result null;
  106.         try {
  107.             $filtros CommonFunctions::parseQueryString($request->getQueryString());
  108.             $result $buscadorService->getResultadosGeneralesBuscador($filtros$page);
  109.         } catch (Exception $e) {
  110.             $statusCode APIResponse::$INTERNAL_ERROR;
  111.             $status APIResponse::$INTERNAL_ERROR;
  112.             $errors = array($e->getMessage());
  113.             $errorInfo CommonFunctions::getErrorException($e);
  114.             $this->logInteractionService->addErrorLog(
  115.                 LogInteraction::$LIST,
  116.                 CommonFunctions::getClassMethod(__METHOD__),
  117.                 $e->getMessage(),
  118.                 $errorInfo
  119.             );
  120.         }
  121.         return $this->generateJsonResponse($result$statusCode$status$errors);
  122.     }
  123.     /**
  124.      * @Route("/tramites-servicios/{page}", name="get_buscador_tramites_servicios", methods={"GET"})
  125.      * @param Request $request
  126.      * @param BuscadorService $buscadorService
  127.      * @param $page
  128.      * @return Response
  129.      *
  130.      * @OA\Get(
  131.      *     path="/api/v1/buscador/tramites-servicios/{page}",
  132.      *     summary="Obtener todos los tramites y servicios del buscador",
  133.      *     @OA\Parameter(
  134.      *         name="texto",
  135.      *         in="query",
  136.      *         required=false,
  137.      *         @OA\Schema(type="string")
  138.      *     ),
  139.      *     @OA\Response(
  140.      *         response=200,
  141.      *         description="Response",
  142.      *         @OA\MediaType(
  143.      *             mediaType="application/json",
  144.      *             @OA\Schema(
  145.      *                 @OA\Property(property="status", type="integer"),
  146.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  147.      *                 @OA\Property(property="content", type="object")
  148.      *            )
  149.      *        )
  150.      *    )
  151.      * )
  152.      */
  153.     public function buscadorTramitesServiciosAction(Request $requestBuscadorService $buscadorService$page)
  154.     {
  155.         $statusCode APIResponse::$SUCCESS;
  156.         $status APIResponse::$SUCCESS;
  157.         $errors = array();
  158.         $result null;
  159.         try {
  160.             $filtros CommonFunctions::parseQueryString($request->getQueryString());
  161.             $result $buscadorService->getTramitesBuscador($filtros$page);
  162.         } catch (Exception $e) {
  163.             $statusCode APIResponse::$INTERNAL_ERROR;
  164.             $status APIResponse::$INTERNAL_ERROR;
  165.             $errors = array($e->getMessage());
  166.             $errorInfo CommonFunctions::getErrorException($e);
  167.             $this->logInteractionService->addErrorLog(
  168.                 LogInteraction::$LIST,
  169.                 CommonFunctions::getClassMethod(__METHOD__),
  170.                 $e->getMessage(),
  171.                 $errorInfo
  172.             );
  173.         }
  174.         return $this->generateJsonResponse($result$statusCode$status$errors);
  175.     }
  176.     /**
  177.      * @Route("/areas-gobierno/{page}", name="get_buscador_areas_gobierno", methods={"GET"})
  178.      * @param Request $request
  179.      * @param BuscadorService $buscadorService
  180.      * @param $page
  181.      * @return Response
  182.      *
  183.      * @OA\Get(
  184.      *     path="/api/v1/buscador/areas-gobierno/{page}",
  185.      *     summary="Obtener todos las areas de gobierno del buscador",
  186.      *     @OA\Parameter(
  187.      *         name="texto",
  188.      *         in="query",
  189.      *         required=false,
  190.      *         @OA\Schema(type="string")
  191.      *     ),
  192.      *     @OA\Response(
  193.      *         response=200,
  194.      *         description="Response",
  195.      *         @OA\MediaType(
  196.      *             mediaType="application/json",
  197.      *             @OA\Schema(
  198.      *                 @OA\Property(property="status", type="integer"),
  199.      *                 @OA\Property(property="errors", type="array", @OA\Items(type="string")),
  200.      *                 @OA\Property(property="content", type="object")
  201.      *            )
  202.      *        )
  203.      *    )
  204.      * )
  205.      */
  206.     public function buscadorAreasGobiernoAction(Request $requestBuscadorService $buscadorService$page)
  207.     {
  208.         $statusCode APIResponse::$SUCCESS;
  209.         $status APIResponse::$SUCCESS;
  210.         $errors = array();
  211.         $result null;
  212.         try {
  213.             $filtros CommonFunctions::parseQueryString($request->getQueryString());
  214.             $result $buscadorService->getAreasGobiernoBuscador($filtros$page);
  215.         } catch (Exception $e) {
  216.             $statusCode APIResponse::$INTERNAL_ERROR;
  217.             $status APIResponse::$INTERNAL_ERROR;
  218.             $errors = array($e->getMessage());
  219.             $errorInfo CommonFunctions::getErrorException($e);
  220.             $this->logInteractionService->addErrorLog(
  221.                 LogInteraction::$LIST,
  222.                 CommonFunctions::getClassMethod(__METHOD__),
  223.                 $e->getMessage(),
  224.                 $errorInfo
  225.             );
  226.         }
  227.         return $this->generateJsonResponse($result$statusCode$status$errors);
  228.     }
  229. }