From 05d24d0034b6d4c47c7b345e0e76ee16b7f3209b Mon Sep 17 00:00:00 2001 From: NOPepin Date: Tue, 13 Jan 2026 16:53:42 +0100 Subject: [PATCH] ajout entites --- api-platform/api/README.md | 15 +++ api-platform/api/src/Entity/Commune.php | 103 ++++++++++++++++++ api-platform/api/src/Entity/Departement.php | 96 ++++++++++++++++ api-platform/api/src/Entity/Greeting.php | 35 ------ api-platform/api/src/Entity/Region.php | 80 ++++++++++++++ api-platform/api/src/Entity/Taxe.php | 99 +++++++++++++++++ api-platform/api/src/Entity/TypeTaxe.php | 95 ++++++++++++++++ .../api/src/Repository/CommuneRepository.php | 43 ++++++++ .../src/Repository/DepartementRepository.php | 43 ++++++++ .../api/src/Repository/RegionRepository.php | 43 ++++++++ .../api/src/Repository/TaxeRepository.php | 43 ++++++++ .../api/src/Repository/TypeTaxeRepository.php | 43 ++++++++ 12 files changed, 703 insertions(+), 35 deletions(-) create mode 100644 api-platform/api/src/Entity/Commune.php create mode 100644 api-platform/api/src/Entity/Departement.php delete mode 100644 api-platform/api/src/Entity/Greeting.php create mode 100644 api-platform/api/src/Entity/Region.php create mode 100644 api-platform/api/src/Entity/Taxe.php create mode 100644 api-platform/api/src/Entity/TypeTaxe.php create mode 100644 api-platform/api/src/Repository/CommuneRepository.php create mode 100644 api-platform/api/src/Repository/DepartementRepository.php create mode 100644 api-platform/api/src/Repository/RegionRepository.php create mode 100644 api-platform/api/src/Repository/TaxeRepository.php create mode 100644 api-platform/api/src/Repository/TypeTaxeRepository.php diff --git a/api-platform/api/README.md b/api-platform/api/README.md index d0edd4c..a40bfd2 100644 --- a/api-platform/api/README.md +++ b/api-platform/api/README.md @@ -3,3 +3,18 @@ The API will be here. Refer to the [Getting Started Guide](https://api-platform.com/docs/distribution) for more information. + +Entities/Fixtures + +Commune : +- Num Commune : Col 3 +- Nom Commune : Col 10 +- Département : Col 1 +- Région : à calculer je crois + +Données : +- Commune : Col 3 +- Année : fichier +- Type de taxe : TFPNB | TFPB | TH | CFE +- Taux : Cols 13 | 68 | 175 | 332 +- Volume Collecté : 14 | 69 | 176 | 333 \ No newline at end of file diff --git a/api-platform/api/src/Entity/Commune.php b/api-platform/api/src/Entity/Commune.php new file mode 100644 index 0000000..addaa55 --- /dev/null +++ b/api-platform/api/src/Entity/Commune.php @@ -0,0 +1,103 @@ + + */ + #[ORM\OneToMany(targetEntity: Taxe::class, mappedBy: 'commune', orphanRemoval: true)] + private Collection $taxes; + + public function __construct() + { + $this->taxes = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function setId(int $id): static + { + $this->id = $id; + + return $this; + } + + public function getNom(): ?string + { + return $this->nom; + } + + public function setNom(string $nom): static + { + $this->nom = $nom; + + return $this; + } + + public function getDepartement(): ?Departement + { + return $this->departement; + } + + public function setDepartement(?Departement $departement): static + { + $this->departement = $departement; + + return $this; + } + + /** + * @return Collection + */ + public function getTaxes(): Collection + { + return $this->taxes; + } + + public function addTax(Taxe $tax): static + { + if (!$this->taxes->contains($tax)) { + $this->taxes->add($tax); + $tax->setCommune($this); + } + + return $this; + } + + public function removeTax(Taxe $tax): static + { + if ($this->taxes->removeElement($tax)) { + // set the owning side to null (unless already changed) + if ($tax->getCommune() === $this) { + $tax->setCommune(null); + } + } + + return $this; + } +} diff --git a/api-platform/api/src/Entity/Departement.php b/api-platform/api/src/Entity/Departement.php new file mode 100644 index 0000000..6c40eda --- /dev/null +++ b/api-platform/api/src/Entity/Departement.php @@ -0,0 +1,96 @@ + + */ + #[ORM\OneToMany(targetEntity: Commune::class, mappedBy: 'departement', orphanRemoval: true)] + private Collection $communes; + + public function __construct() + { + $this->communes = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getCode(): ?int + { + return $this->code; + } + + public function setCode(int $code): static + { + $this->code = $code; + + return $this; + } + + public function getRegion(): ?Region + { + return $this->region; + } + + public function setRegion(?Region $region): static + { + $this->region = $region; + + return $this; + } + + /** + * @return Collection + */ + public function getCommunes(): Collection + { + return $this->communes; + } + + public function addCommune(Commune $commune): static + { + if (!$this->communes->contains($commune)) { + $this->communes->add($commune); + $commune->setDepartement($this); + } + + return $this; + } + + public function removeCommune(Commune $commune): static + { + if ($this->communes->removeElement($commune)) { + // set the owning side to null (unless already changed) + if ($commune->getDepartement() === $this) { + $commune->setDepartement(null); + } + } + + return $this; + } +} diff --git a/api-platform/api/src/Entity/Greeting.php b/api-platform/api/src/Entity/Greeting.php deleted file mode 100644 index ba4c640..0000000 --- a/api-platform/api/src/Entity/Greeting.php +++ /dev/null @@ -1,35 +0,0 @@ -id; - } -} diff --git a/api-platform/api/src/Entity/Region.php b/api-platform/api/src/Entity/Region.php new file mode 100644 index 0000000..617cb3a --- /dev/null +++ b/api-platform/api/src/Entity/Region.php @@ -0,0 +1,80 @@ + + */ + #[ORM\OneToMany(targetEntity: Departement::class, mappedBy: 'region', orphanRemoval: true)] + private Collection $departements; + + public function __construct() + { + $this->departements = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getNom(): ?string + { + return $this->nom; + } + + public function setNom(string $nom): static + { + $this->nom = $nom; + + return $this; + } + + /** + * @return Collection + */ + public function getDepartements(): Collection + { + return $this->departements; + } + + public function addDepartement(Departement $departement): static + { + if (!$this->departements->contains($departement)) { + $this->departements->add($departement); + $departement->setRegion($this); + } + + return $this; + } + + public function removeDepartement(Departement $departement): static + { + if ($this->departements->removeElement($departement)) { + // set the owning side to null (unless already changed) + if ($departement->getRegion() === $this) { + $departement->setRegion(null); + } + } + + return $this; + } +} diff --git a/api-platform/api/src/Entity/Taxe.php b/api-platform/api/src/Entity/Taxe.php new file mode 100644 index 0000000..bba17e4 --- /dev/null +++ b/api-platform/api/src/Entity/Taxe.php @@ -0,0 +1,99 @@ +id; + } + + public function getCommune(): ?Commune + { + return $this->commune; + } + + public function setCommune(?Commune $commune): static + { + $this->commune = $commune; + + return $this; + } + + public function getAnnee(): ?int + { + return $this->annee; + } + + public function setAnnee(int $annee): static + { + $this->annee = $annee; + + return $this; + } + + public function getType(): ?TypeTaxe + { + return $this->type; + } + + public function setType(?TypeTaxe $type): static + { + $this->type = $type; + + return $this; + } + + public function getTaux(): ?float + { + return $this->taux; + } + + public function setTaux(float $taux): static + { + $this->taux = $taux; + + return $this; + } + + public function getVolume(): ?float + { + return $this->volume; + } + + public function setVolume(float $volume): static + { + $this->volume = $volume; + + return $this; + } +} diff --git a/api-platform/api/src/Entity/TypeTaxe.php b/api-platform/api/src/Entity/TypeTaxe.php new file mode 100644 index 0000000..02f89b8 --- /dev/null +++ b/api-platform/api/src/Entity/TypeTaxe.php @@ -0,0 +1,95 @@ + + */ + #[ORM\OneToMany(targetEntity: Taxe::class, mappedBy: 'type', orphanRemoval: true)] + private Collection $taxes; + + public function __construct() + { + $this->taxes = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function getLabel(): ?string + { + return $this->label; + } + + public function setLabel(string $label): static + { + $this->label = $label; + + return $this; + } + + /** + * @return Collection + */ + public function getTaxes(): Collection + { + return $this->taxes; + } + + public function addTax(Taxe $tax): static + { + if (!$this->taxes->contains($tax)) { + $this->taxes->add($tax); + $tax->setType($this); + } + + return $this; + } + + public function removeTax(Taxe $tax): static + { + if ($this->taxes->removeElement($tax)) { + // set the owning side to null (unless already changed) + if ($tax->getType() === $this) { + $tax->setType(null); + } + } + + return $this; + } +} diff --git a/api-platform/api/src/Repository/CommuneRepository.php b/api-platform/api/src/Repository/CommuneRepository.php new file mode 100644 index 0000000..393ffd5 --- /dev/null +++ b/api-platform/api/src/Repository/CommuneRepository.php @@ -0,0 +1,43 @@ + + */ +class CommuneRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Commune::class); + } + +// /** +// * @return Commune[] Returns an array of Commune objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('c.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Commune +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/api-platform/api/src/Repository/DepartementRepository.php b/api-platform/api/src/Repository/DepartementRepository.php new file mode 100644 index 0000000..2cd3581 --- /dev/null +++ b/api-platform/api/src/Repository/DepartementRepository.php @@ -0,0 +1,43 @@ + + */ +class DepartementRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Departement::class); + } + + // /** + // * @return Departement[] Returns an array of Departement objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('d') + // ->andWhere('d.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('d.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Departement + // { + // return $this->createQueryBuilder('d') + // ->andWhere('d.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/api-platform/api/src/Repository/RegionRepository.php b/api-platform/api/src/Repository/RegionRepository.php new file mode 100644 index 0000000..83e6a38 --- /dev/null +++ b/api-platform/api/src/Repository/RegionRepository.php @@ -0,0 +1,43 @@ + + */ +class RegionRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Region::class); + } + + // /** + // * @return Region[] Returns an array of Region objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('r') + // ->andWhere('r.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('r.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Region + // { + // return $this->createQueryBuilder('r') + // ->andWhere('r.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/api-platform/api/src/Repository/TaxeRepository.php b/api-platform/api/src/Repository/TaxeRepository.php new file mode 100644 index 0000000..9218441 --- /dev/null +++ b/api-platform/api/src/Repository/TaxeRepository.php @@ -0,0 +1,43 @@ + + */ +class TaxeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Taxe::class); + } + +// /** +// * @return Taxe[] Returns an array of Taxe objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('t') +// ->andWhere('t.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('t.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?Taxe +// { +// return $this->createQueryBuilder('t') +// ->andWhere('t.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/api-platform/api/src/Repository/TypeTaxeRepository.php b/api-platform/api/src/Repository/TypeTaxeRepository.php new file mode 100644 index 0000000..d42be41 --- /dev/null +++ b/api-platform/api/src/Repository/TypeTaxeRepository.php @@ -0,0 +1,43 @@ + + */ +class TypeTaxeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, TypeTaxe::class); + } + + // /** + // * @return TypeTaxe[] Returns an array of TypeTaxe objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('t') + // ->andWhere('t.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('t.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?TypeTaxe + // { + // return $this->createQueryBuilder('t') + // ->andWhere('t.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} -- GitLab