Fix get season teams
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Details
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
Details
This commit is contained in:
parent
4819033a26
commit
8932feca8b
|
|
@ -7,7 +7,7 @@ use DMD\LaLigaApi\Service\Season\createFacilities\HandleCreateFacilities;
|
||||||
use DMD\LaLigaApi\Service\Season\createGameCalendar\HandleCreateGameCalendarRequest;
|
use DMD\LaLigaApi\Service\Season\createGameCalendar\HandleCreateGameCalendarRequest;
|
||||||
use DMD\LaLigaApi\Service\Season\createSeason\HandleCreateSeason;
|
use DMD\LaLigaApi\Service\Season\createSeason\HandleCreateSeason;
|
||||||
use DMD\LaLigaApi\Service\Season\getAllFacilities\HandleGetAllFacilities;
|
use DMD\LaLigaApi\Service\Season\getAllFacilities\HandleGetAllFacilities;
|
||||||
use DMD\LaLigaApi\Service\Season\getAllTeams\HandleGetAllTeams;
|
use DMD\LaLigaApi\Service\Season\getAllTeams\HandleGetSeasonTeams;
|
||||||
use DMD\LaLigaApi\Service\Season\getSeasonById\HandleGetSeasonById;
|
use DMD\LaLigaApi\Service\Season\getSeasonById\HandleGetSeasonById;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
@ -33,8 +33,8 @@ class SeasonController extends AbstractController
|
||||||
{
|
{
|
||||||
return $handleAddTeam($request, $leagueId, $seasonId);
|
return $handleAddTeam($request, $leagueId, $seasonId);
|
||||||
}
|
}
|
||||||
#[Route('/api/league/{leagueId}/season/{seasonId}/team', name: 'app_get_all_teams', methods: ['GET'])]
|
#[Route('/api/league/{leagueId}/season/{seasonId}/team', name: 'app_get_season_teams', methods: ['GET'])]
|
||||||
public function getAllTeam(Request $request, HandleGetAllTeams $handleGetAllTeams, int $leagueId, int $seasonId): JsonResponse
|
public function getSeasonTeams(Request $request, HandleGetSeasonTeams $handleGetAllTeams, int $leagueId, int $seasonId): JsonResponse
|
||||||
{
|
{
|
||||||
return $handleGetAllTeams($request, $leagueId, $seasonId);
|
return $handleGetAllTeams($request, $leagueId, $seasonId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class HandleGetAllSeason
|
class HandleGetAllSeasons
|
||||||
{
|
{
|
||||||
public const PAGE_SIZE = 10;
|
public const PAGE_SIZE = 10;
|
||||||
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
namespace DMD\LaLigaApi\Service\Season\getAllTeams;
|
namespace DMD\LaLigaApi\Service\Season\getAllTeams;
|
||||||
|
|
||||||
|
use DMD\LaLigaApi\Entity\League;
|
||||||
|
use DMD\LaLigaApi\Entity\Season;
|
||||||
use DMD\LaLigaApi\Repository\LeagueRepository;
|
use DMD\LaLigaApi\Repository\LeagueRepository;
|
||||||
use DMD\LaLigaApi\Repository\SeasonRepository;
|
use DMD\LaLigaApi\Repository\SeasonRepository;
|
||||||
use DMD\LaLigaApi\Repository\TeamRepository;
|
use DMD\LaLigaApi\Repository\TeamRepository;
|
||||||
|
|
@ -11,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
|
|
||||||
class HandleGetAllTeams
|
class HandleGetSeasonTeams
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public TeamRepository $teamRepository,
|
public TeamRepository $teamRepository,
|
||||||
|
|
@ -29,14 +31,8 @@ class HandleGetAllTeams
|
||||||
'id' => $seasonId,
|
'id' => $seasonId,
|
||||||
'league' => $leagueEntity
|
'league' => $leagueEntity
|
||||||
]);
|
]);
|
||||||
if (is_null($seasonEntity))
|
$this->validateRequest($leagueEntity, $seasonEntity);
|
||||||
{
|
$teamEntityCollection = $seasonEntity?->getTeams();
|
||||||
throw new HttpException(Response::HTTP_NOT_FOUND, "Season not found");
|
|
||||||
}
|
|
||||||
$teamEntityCollection = $this->teamRepository->findBy([
|
|
||||||
'leagueId' => $leagueId,
|
|
||||||
'active' => true
|
|
||||||
]);
|
|
||||||
if (empty($teamEntityCollection))
|
if (empty($teamEntityCollection))
|
||||||
{
|
{
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
|
|
@ -56,4 +52,16 @@ class HandleGetAllTeams
|
||||||
], Response::HTTP_OK
|
], Response::HTTP_OK
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function validateRequest(?League $leagueEntity, ?Season $seasonEntity): void
|
||||||
|
{
|
||||||
|
if (is_null($leagueEntity))
|
||||||
|
{
|
||||||
|
throw new HttpException(Response::HTTP_NOT_FOUND, "League not found");
|
||||||
|
}
|
||||||
|
if (is_null($seasonEntity))
|
||||||
|
{
|
||||||
|
throw new HttpException(Response::HTTP_NOT_FOUND, "Season not found");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ $classes[] = 'DMD\LaLigaApi\Service\Season\createGameCalendar\HandleCreateGameCa
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\Season\createSeason\HandleCreateSeason';
|
$classes[] = 'DMD\LaLigaApi\Service\Season\createSeason\HandleCreateSeason';
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\Season\SeasonFactory';
|
$classes[] = 'DMD\LaLigaApi\Service\Season\SeasonFactory';
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\Season\getAllFacilities\HandleGetAllFacilities';
|
$classes[] = 'DMD\LaLigaApi\Service\Season\getAllFacilities\HandleGetAllFacilities';
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\Season\getAllTeams\HandleGetAllTeams';
|
$classes[] = 'DMD\LaLigaApi\Service\Season\getAllTeams\HandleGetSeasonTeams';
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\User\Handlers\UserSaver';
|
$classes[] = 'DMD\LaLigaApi\Service\User\Handlers\UserSaver';
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\User\Handlers\delete\HandleDeleteUser';
|
$classes[] = 'DMD\LaLigaApi\Service\User\Handlers\delete\HandleDeleteUser';
|
||||||
$classes[] = 'DMD\LaLigaApi\Service\User\Handlers\getNotifications\HandleGetNotifications';
|
$classes[] = 'DMD\LaLigaApi\Service\User\Handlers\getNotifications\HandleGetNotifications';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue