From a4342af0957ea7f8e48ab1af5c8476cf48bacd81 Mon Sep 17 00:00:00 2001 From: tristan Date: Wed, 22 Apr 2026 17:53:37 +0200 Subject: [PATCH] =?UTF-8?q?feat=20:=20=C3=A9tape=201/5=20-=20ajout=20des?= =?UTF-8?q?=20champs=20sex=20et=20exitedAt=20sur=20Bovine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Migration pour les nouvelles colonnes - ExistsFilter sur exitedAt, SearchFilter sur sex/workNumber/breedCode, DateFilter sur birthDate - DTO front étendu avec workNumber, birthDate, breedCode, sex, exitedAt Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/services/dto/bovine-data.ts | 5 ++++ migrations/Version20260422155300.php | 33 +++++++++++++++++++++++ src/Entity/Bovine.php | 40 +++++++++++++++++++++++++++- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 migrations/Version20260422155300.php diff --git a/frontend/services/dto/bovine-data.ts b/frontend/services/dto/bovine-data.ts index 58bb736..4cf0b50 100644 --- a/frontend/services/dto/bovine-data.ts +++ b/frontend/services/dto/bovine-data.ts @@ -5,6 +5,11 @@ export interface BovineData { arrivalDate: string | null buildingCase: string | null supplier: string | null + workNumber: string | null + birthDate: string | null + breedCode: string | null + sex: string | null + exitedAt: string | null } export type BovinePayload = { diff --git a/migrations/Version20260422155300.php b/migrations/Version20260422155300.php new file mode 100644 index 0000000..7ff15b8 --- /dev/null +++ b/migrations/Version20260422155300.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE bovine ADD sex VARCHAR(1) DEFAULT NULL'); + $this->addSql('ALTER TABLE bovine ADD exited_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE bovine DROP sex'); + $this->addSql('ALTER TABLE bovine DROP exited_at'); + } +} diff --git a/src/Entity/Bovine.php b/src/Entity/Bovine.php index 275c1f5..ff18b04 100644 --- a/src/Entity/Bovine.php +++ b/src/Entity/Bovine.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace App\Entity; use ApiPlatform\Doctrine\Orm\Filter\DateFilter; +use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiResource; @@ -24,10 +25,14 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; #[ORM\UniqueConstraint(name: 'uniq_bovine_national_number', columns: ['national_number'])] #[ApiFilter(SearchFilter::class, properties: [ 'nationalNumber' => 'ipartial', + 'workNumber' => 'ipartial', + 'breedCode' => 'ipartial', + 'sex' => 'exact', 'buildingCase' => 'exact', 'receivedWeight' => 'exact', ])] -#[ApiFilter(DateFilter::class, properties: ['arrivalDate'])] +#[ApiFilter(DateFilter::class, properties: ['arrivalDate', 'birthDate'])] +#[ApiFilter(ExistsFilter::class, properties: ['exitedAt'])] #[ApiResource( operations: [ new Get( @@ -95,6 +100,15 @@ class Bovine #[Groups(['bovine:read', 'building_case:read'])] private ?string $breedCode = null; + #[ORM\Column(length: 1, nullable: true)] + #[Groups(['bovine:read', 'building_case:read'])] + private ?string $sex = null; + + #[ORM\Column(type: 'datetime_immutable', nullable: true)] + #[Groups(['bovine:read', 'building_case:read'])] + #[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])] + private ?DateTimeImmutable $exitedAt = null; + public function getId(): ?int { return $this->id; @@ -195,4 +209,28 @@ class Bovine return $this; } + + public function getSex(): ?string + { + return $this->sex; + } + + public function setSex(?string $sex): static + { + $this->sex = $sex; + + return $this; + } + + public function getExitedAt(): ?DateTimeImmutable + { + return $this->exitedAt; + } + + public function setExitedAt(?DateTimeImmutable $exitedAt): static + { + $this->exitedAt = $exitedAt; + + return $this; + } }