feat : étape 1/5 - ajout des champs sex et exitedAt sur Bovine
- 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) <noreply@anthropic.com>
This commit is contained in:
@@ -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 = {
|
||||
|
||||
33
migrations/Version20260422155300.php
Normal file
33
migrations/Version20260422155300.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260422155300 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user