current init
This commit is contained in:
16
backend/src/DTO/Request/CreateCategoryRequest.php
Normal file
16
backend/src/DTO/Request/CreateCategoryRequest.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class CreateCategoryRequest
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public string $name;
|
||||
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\CssColor(formats: Assert\CssColor::HEX_LONG)]
|
||||
public string $color;
|
||||
}
|
||||
59
backend/src/DTO/Request/CreateSchemaRequest.php
Normal file
59
backend/src/DTO/Request/CreateSchemaRequest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
class CreateSchemaRequest
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
public ?int $categoryId = null;
|
||||
public ?string $status = null;
|
||||
public ?string $taskType = null;
|
||||
public ?string $deadline = null;
|
||||
public ?string $startDate = null;
|
||||
public ?string $endDate = null;
|
||||
public ?array $weekdays = null;
|
||||
public ?array $monthDays = null;
|
||||
public ?array $yearDays = null;
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validate(ExecutionContextInterface $context): void
|
||||
{
|
||||
if ($this->taskType !== null && $this->taskType !== 'einzel') {
|
||||
if ($this->startDate !== null && $this->endDate !== null && $this->endDate < $this->startDate) {
|
||||
$context->buildViolation('endDate muss >= startDate sein.')
|
||||
->atPath('endDate')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'woechentlich') {
|
||||
if (empty($this->weekdays)) {
|
||||
$context->buildViolation('weekdays darf nicht leer sein.')
|
||||
->atPath('weekdays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'monatlich') {
|
||||
if (empty($this->monthDays)) {
|
||||
$context->buildViolation('monthDays darf nicht leer sein.')
|
||||
->atPath('monthDays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'multi' || $this->taskType === 'jaehrlich') {
|
||||
if (empty($this->yearDays)) {
|
||||
$context->buildViolation('yearDays darf nicht leer sein.')
|
||||
->atPath('yearDays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
backend/src/DTO/Request/ToggleRequest.php
Normal file
8
backend/src/DTO/Request/ToggleRequest.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
class ToggleRequest
|
||||
{
|
||||
public ?string $date = null;
|
||||
}
|
||||
14
backend/src/DTO/Request/UpdateCategoryRequest.php
Normal file
14
backend/src/DTO/Request/UpdateCategoryRequest.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class UpdateCategoryRequest
|
||||
{
|
||||
#[Assert\Length(min: 1, max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
#[Assert\CssColor(formats: Assert\CssColor::HEX_LONG)]
|
||||
public ?string $color = null;
|
||||
}
|
||||
60
backend/src/DTO/Request/UpdateSchemaRequest.php
Normal file
60
backend/src/DTO/Request/UpdateSchemaRequest.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
class UpdateSchemaRequest
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $name = null;
|
||||
|
||||
public ?int $categoryId = null;
|
||||
public bool $hasCategoryId = false;
|
||||
public ?string $status = null;
|
||||
public ?string $taskType = null;
|
||||
public ?string $deadline = null;
|
||||
public ?string $startDate = null;
|
||||
public ?string $endDate = null;
|
||||
public ?array $weekdays = null;
|
||||
public ?array $monthDays = null;
|
||||
public ?array $yearDays = null;
|
||||
|
||||
#[Assert\Callback]
|
||||
public function validate(ExecutionContextInterface $context): void
|
||||
{
|
||||
if ($this->taskType !== null && $this->taskType !== 'einzel') {
|
||||
if ($this->startDate !== null && $this->endDate !== null && $this->endDate < $this->startDate) {
|
||||
$context->buildViolation('endDate muss >= startDate sein.')
|
||||
->atPath('endDate')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'woechentlich') {
|
||||
if (empty($this->weekdays)) {
|
||||
$context->buildViolation('weekdays darf nicht leer sein.')
|
||||
->atPath('weekdays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'monatlich') {
|
||||
if (empty($this->monthDays)) {
|
||||
$context->buildViolation('monthDays darf nicht leer sein.')
|
||||
->atPath('monthDays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->taskType === 'multi' || $this->taskType === 'jaehrlich') {
|
||||
if (empty($this->yearDays)) {
|
||||
$context->buildViolation('yearDays darf nicht leer sein.')
|
||||
->atPath('yearDays')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
backend/src/DTO/Request/UpdateTaskRequest.php
Normal file
11
backend/src/DTO/Request/UpdateTaskRequest.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Request;
|
||||
|
||||
class UpdateTaskRequest
|
||||
{
|
||||
public ?string $name = null;
|
||||
public ?int $categoryId = null;
|
||||
public ?string $status = null;
|
||||
public ?string $date = null;
|
||||
}
|
||||
12
backend/src/DTO/Response/CategoryResponse.php
Normal file
12
backend/src/DTO/Response/CategoryResponse.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Response;
|
||||
|
||||
class CategoryResponse
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $id,
|
||||
public readonly string $name,
|
||||
public readonly string $color,
|
||||
) {}
|
||||
}
|
||||
12
backend/src/DTO/Response/DayResponse.php
Normal file
12
backend/src/DTO/Response/DayResponse.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Response;
|
||||
|
||||
class DayResponse
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $date,
|
||||
/** @var TaskResponse[] */
|
||||
public readonly array $tasks,
|
||||
) {}
|
||||
}
|
||||
18
backend/src/DTO/Response/TaskResponse.php
Normal file
18
backend/src/DTO/Response/TaskResponse.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Response;
|
||||
|
||||
class TaskResponse
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $schemaId,
|
||||
public readonly int $taskId,
|
||||
public readonly string $name,
|
||||
public readonly string $status,
|
||||
public readonly string $taskType,
|
||||
public readonly ?string $date,
|
||||
public readonly ?string $deadline,
|
||||
public readonly bool $isPast,
|
||||
public readonly ?CategoryResponse $category,
|
||||
) {}
|
||||
}
|
||||
10
backend/src/DTO/Response/ToggleResponse.php
Normal file
10
backend/src/DTO/Response/ToggleResponse.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Response;
|
||||
|
||||
class ToggleResponse
|
||||
{
|
||||
public function __construct(
|
||||
public readonly bool $completed,
|
||||
) {}
|
||||
}
|
||||
13
backend/src/DTO/Response/WeekViewResponse.php
Normal file
13
backend/src/DTO/Response/WeekViewResponse.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTO\Response;
|
||||
|
||||
class WeekViewResponse
|
||||
{
|
||||
public function __construct(
|
||||
/** @var TaskResponse[] */
|
||||
public readonly array $tasksWithoutDeadline,
|
||||
/** @var DayResponse[] */
|
||||
public readonly array $days,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user