Move points per match to season entity
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good
This commit is contained in:
+1
-54
@@ -13,9 +13,6 @@ class LeagueDto
|
||||
public string $city;
|
||||
public string $logo;
|
||||
public string $description;
|
||||
public int $pointsPerWin;
|
||||
public int $pointsPerDraw;
|
||||
public int $pointsPerLoss;
|
||||
public int $matchesBetweenTeams;
|
||||
public array $blockedMatchDates;
|
||||
public bool $active;
|
||||
@@ -41,9 +38,6 @@ class LeagueDto
|
||||
'city' => $this->city ?? null,
|
||||
'logo' => $this->logo ?? null,
|
||||
'description' => $this->description ?? null,
|
||||
'pointsPerWin' => $this->pointsPerWin ?? null,
|
||||
'pointsPerDraw' => $this->pointsPerDraw ?? null,
|
||||
'pointsPerLoss' => $this->pointsPerLoss ?? null,
|
||||
'matchesBetweenTeams' => $this->matchesBetweenTeams ?? [],
|
||||
'blockedMatchDates' => $this->blockedMatchDates ?? [],
|
||||
'active' => $this->active ?? null,
|
||||
@@ -91,18 +85,6 @@ class LeagueDto
|
||||
{
|
||||
$this->description = $dataList['description'];
|
||||
}
|
||||
if (isset($dataList['pointsPerWin']))
|
||||
{
|
||||
$this->pointsPerWin = (int) $dataList['pointsPerWin'];
|
||||
}
|
||||
if (isset($dataList['pointsPerDraw']))
|
||||
{
|
||||
$this->pointsPerDraw = (int) $dataList['pointsPerDraw'];
|
||||
}
|
||||
if (isset($dataList['pointsPerLoss']))
|
||||
{
|
||||
$this->pointsPerLoss = (int) $dataList['pointsPerLoss'];
|
||||
}
|
||||
if (isset($dataList['matchesBetweenTeams']))
|
||||
{
|
||||
$this->matchesBetweenTeams = (int) $dataList['matchesBetweenTeams'];
|
||||
@@ -152,18 +134,6 @@ class LeagueDto
|
||||
{
|
||||
$this->logo = $leagueObj->getLogo();
|
||||
}
|
||||
if ($leagueObj->getPointsPerWin() !== null)
|
||||
{
|
||||
$this->pointsPerWin = $leagueObj->getPointsPerWin();
|
||||
}
|
||||
if ($leagueObj->getPointsPerDraw() !== null)
|
||||
{
|
||||
$this->pointsPerDraw = $leagueObj->getPointsPerDraw();
|
||||
}
|
||||
if ($leagueObj->getPointsPerLoss() !== null)
|
||||
{
|
||||
$this->pointsPerLoss = $leagueObj->getPointsPerLoss();
|
||||
}
|
||||
if ($leagueObj->getMatchesBetweenTeams() !== null)
|
||||
{
|
||||
$this->matchesBetweenTeams = $leagueObj->getMatchesBetweenTeams();
|
||||
@@ -204,30 +174,7 @@ class LeagueDto
|
||||
{
|
||||
$this->validationErrors[] = 'La localidad no puede estar vacía.';
|
||||
}
|
||||
if (empty($this->pointsPerWin))
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por partido ganado no pueden estar vacíos.';
|
||||
}
|
||||
if (
|
||||
isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) &&
|
||||
(($this->pointsPerWin <= $this->pointsPerDraw) ||
|
||||
($this->pointsPerWin <= $this->pointsPerLoss))
|
||||
)
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por partido ganado deben ser superiores a los puntos por empate y por perdida.';
|
||||
}
|
||||
if (isset($this->pointsPerDraw, $this->pointsPerWin) && ($this->pointsPerDraw > $this->pointsPerWin))
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por empate deben ser inferiores a los puntos por partido ganado.';
|
||||
}
|
||||
if (isset($this->pointsPerDraw, $this->pointsPerLoss) && ($this->pointsPerDraw < $this->pointsPerLoss))
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por empate deben ser superiores a los puntos por partido perdido.';
|
||||
}
|
||||
if (isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) && ($this->pointsPerWin + $this->pointsPerDraw + $this->pointsPerLoss > 20))
|
||||
{
|
||||
$this->validationErrors[] = 'La suma de los puntos por partidos ganados, perdidos y empatados no puede ser superior a 20.';
|
||||
}
|
||||
|
||||
if (!empty($this->validationErrors))
|
||||
{
|
||||
throw new ValidationException($this->validationErrors);
|
||||
|
||||
@@ -12,6 +12,9 @@ class SeasonDto
|
||||
public array $teamDtoList;
|
||||
public array $facilityDtoList;
|
||||
public int $leagueId;
|
||||
public int $pointsPerWin;
|
||||
public int $pointsPerLoss;
|
||||
public int $pointsPerDraw;
|
||||
public array $gameDtoList;
|
||||
public array $seasonDataDtoList;
|
||||
public bool $active;
|
||||
@@ -59,6 +62,18 @@ class SeasonDto
|
||||
$this->dateStart = $dateStart;
|
||||
}
|
||||
}
|
||||
if (isset($dataList['pointsPerWin']))
|
||||
{
|
||||
$this->pointsPerWin = (int) $dataList['pointsPerWin'];
|
||||
}
|
||||
if (isset($dataList['pointsPerDraw']))
|
||||
{
|
||||
$this->pointsPerDraw = (int) $dataList['pointsPerDraw'];
|
||||
}
|
||||
if (isset($dataList['pointsPerLoss']))
|
||||
{
|
||||
$this->pointsPerLoss = (int) $dataList['pointsPerLoss'];
|
||||
}
|
||||
if (isset($dataList['active']))
|
||||
{
|
||||
$this->active = $dataList['active'];
|
||||
@@ -118,6 +133,30 @@ class SeasonDto
|
||||
*/
|
||||
public function validate(): void
|
||||
{
|
||||
if (empty($this->pointsPerWin))
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por partido ganado no pueden estar vacíos.';
|
||||
}
|
||||
if (
|
||||
isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) &&
|
||||
(($this->pointsPerWin <= $this->pointsPerDraw) ||
|
||||
($this->pointsPerWin <= $this->pointsPerLoss))
|
||||
)
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por partido ganado deben ser superiores a los puntos por empate y por perdida.';
|
||||
}
|
||||
if (isset($this->pointsPerDraw, $this->pointsPerWin) && ($this->pointsPerDraw > $this->pointsPerWin))
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por empate deben ser inferiores a los puntos por partido ganado.';
|
||||
}
|
||||
if (isset($this->pointsPerDraw, $this->pointsPerLoss) && ($this->pointsPerDraw < $this->pointsPerLoss))
|
||||
{
|
||||
$this->validationErrors[] = 'Los puntos por empate deben ser superiores a los puntos por partido perdido.';
|
||||
}
|
||||
if (isset($this->pointsPerDraw, $this->pointsPerWin, $this->pointsPerLoss) && ($this->pointsPerWin + $this->pointsPerDraw + $this->pointsPerLoss > 20))
|
||||
{
|
||||
$this->validationErrors[] = 'La suma de los puntos por partidos ganados, perdidos y empatados no puede ser superior a 20.';
|
||||
}
|
||||
if (!empty($this->validationErrors))
|
||||
{
|
||||
throw new ValidationException($this->validationErrors);
|
||||
|
||||
Reference in New Issue
Block a user