diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index 4311652..2131d24 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -4,7 +4,7 @@
- + - + diff --git a/frontend/pages/infrastructure/batiment.vue b/frontend/pages/infrastructure/batiment.vue new file mode 100644 index 0000000..8293cdb --- /dev/null +++ b/frontend/pages/infrastructure/batiment.vue @@ -0,0 +1,199 @@ + + + diff --git a/frontend/pages/infrastructure/case.vue b/frontend/pages/infrastructure/case.vue new file mode 100644 index 0000000..28c96c6 --- /dev/null +++ b/frontend/pages/infrastructure/case.vue @@ -0,0 +1,6 @@ + + diff --git a/frontend/services/dto/building-case-data.ts b/frontend/services/dto/building-case-data.ts new file mode 100644 index 0000000..6a59f1f --- /dev/null +++ b/frontend/services/dto/building-case-data.ts @@ -0,0 +1,6 @@ +export interface BuildingCaseData { + id: number + caseNumber: number | null + code: string | null + capacity: number | null +} diff --git a/frontend/services/dto/building-case-position-data.ts b/frontend/services/dto/building-case-position-data.ts new file mode 100644 index 0000000..b1f6e84 --- /dev/null +++ b/frontend/services/dto/building-case-position-data.ts @@ -0,0 +1,11 @@ +import type { BuildingCaseData } from '~/services/dto/building-case-data' + +export interface BuildingCasePositionData { + id: number + x: number | null + y: number | null + w: number | null + h: number | null + renderOrder: string | null + buildingCase: BuildingCaseData | null +} diff --git a/frontend/services/dto/building-data.ts b/frontend/services/dto/building-data.ts index 4993219..60729d4 100644 --- a/frontend/services/dto/building-data.ts +++ b/frontend/services/dto/building-data.ts @@ -1,5 +1,8 @@ +import type { BuildingLayoutData } from '~/services/dto/building-layout-data' + export interface BuildingData { id: number label: string code: string + layouts?: BuildingLayoutData[] | null } diff --git a/frontend/services/dto/building-layout-data.ts b/frontend/services/dto/building-layout-data.ts new file mode 100644 index 0000000..f9a2661 --- /dev/null +++ b/frontend/services/dto/building-layout-data.ts @@ -0,0 +1,9 @@ +import type { BuildingCasePositionData } from '~/services/dto/building-case-position-data' + +export interface BuildingLayoutData { + id: number + name: string | null + columns: number | null + rows: number | null + casePositions?: BuildingCasePositionData[] | null +} diff --git a/migrations/Version20260219100826.php b/migrations/Version20260219100826.php new file mode 100644 index 0000000..7d0be76 --- /dev/null +++ b/migrations/Version20260219100826.php @@ -0,0 +1,47 @@ +addSql('CREATE TABLE building_case (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, case_number INT NOT NULL, code VARCHAR(255) NOT NULL, capacity INT NOT NULL, id_building_id INT DEFAULT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_DE2CEE505538B3E5 ON building_case (id_building_id)'); + $this->addSql('CREATE TABLE building_case_position (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, x INT NOT NULL, y INT NOT NULL, w INT NOT NULL, h INT NOT NULL, render_order VARCHAR(255) NOT NULL, building_layout_id INT NOT NULL, building_case_id INT NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_ACCDF9077040AE67 ON building_case_position (building_layout_id)'); + $this->addSql('CREATE INDEX IDX_ACCDF907F8D859DF ON building_case_position (building_case_id)'); + $this->addSql('CREATE TABLE building_layout (id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, name VARCHAR(255) NOT NULL, columns INT NOT NULL, rows INT NOT NULL, id_building_id INT NOT NULL, PRIMARY KEY (id))'); + $this->addSql('CREATE INDEX IDX_2A8CB1095538B3E5 ON building_layout (id_building_id)'); + $this->addSql('ALTER TABLE building_case ADD CONSTRAINT FK_DE2CEE505538B3E5 FOREIGN KEY (id_building_id) REFERENCES building (id)'); + $this->addSql('ALTER TABLE building_case_position ADD CONSTRAINT FK_ACCDF9077040AE67 FOREIGN KEY (building_layout_id) REFERENCES building_layout (id) NOT DEFERRABLE'); + $this->addSql('ALTER TABLE building_case_position ADD CONSTRAINT FK_ACCDF907F8D859DF FOREIGN KEY (building_case_id) REFERENCES building_case (id) NOT DEFERRABLE'); + $this->addSql('ALTER TABLE building_layout ADD CONSTRAINT FK_2A8CB1095538B3E5 FOREIGN KEY (id_building_id) REFERENCES building (id) NOT DEFERRABLE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE building_case DROP CONSTRAINT FK_DE2CEE505538B3E5'); + $this->addSql('ALTER TABLE building_case_position DROP CONSTRAINT FK_ACCDF9077040AE67'); + $this->addSql('ALTER TABLE building_case_position DROP CONSTRAINT FK_ACCDF907F8D859DF'); + $this->addSql('ALTER TABLE building_layout DROP CONSTRAINT FK_2A8CB1095538B3E5'); + $this->addSql('DROP TABLE building_case'); + $this->addSql('DROP TABLE building_case_position'); + $this->addSql('DROP TABLE building_layout'); + } +} diff --git a/src/Entity/Building.php b/src/Entity/Building.php index 92caa14..af68257 100644 --- a/src/Entity/Building.php +++ b/src/Entity/Building.php @@ -11,6 +11,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Serializer\Attribute\Groups; +use Symfony\Component\Serializer\Attribute\SerializedName; #[ORM\Entity] #[ORM\Table(name: 'building')] @@ -48,9 +49,25 @@ class Building #[ORM\ManyToMany(targetEntity: Reception::class, mappedBy: 'buildings')] private Collection $receptions; + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: BuildingCase::class, mappedBy: 'id_building')] + private Collection $buildingCases; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: BuildingLayout::class, mappedBy: 'id_building')] + #[Groups(['building:read'])] + #[SerializedName('layouts')] + private Collection $buildingLayout; + public function __construct() { - $this->receptions = new ArrayCollection(); + $this->receptions = new ArrayCollection(); + $this->buildingCases = new ArrayCollection(); + $this->buildingLayout = new ArrayCollection(); } public function getId(): ?int @@ -89,4 +106,41 @@ class Building { return $this->receptions; } + + /** + * @return Collection + */ + public function getBuildingCases(): Collection + { + return $this->buildingCases; + } + + public function addBuildingCase(BuildingCase $buildingCase): static + { + if (!$this->buildingCases->contains($buildingCase)) { + $this->buildingCases->add($buildingCase); + $buildingCase->setIdBuilding($this); + } + + return $this; + } + + public function removeBuildingCase(BuildingCase $buildingCase): static + { + if ($this->buildingCases->removeElement($buildingCase)) { + if ($buildingCase->getIdBuilding() === $this) { + $buildingCase->setIdBuilding(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getBuildingLayout(): Collection + { + return $this->buildingLayout; + } } diff --git a/src/Entity/BuildingCase.php b/src/Entity/BuildingCase.php new file mode 100644 index 0000000..1730324 --- /dev/null +++ b/src/Entity/BuildingCase.php @@ -0,0 +1,139 @@ + + */ + #[ORM\OneToMany(targetEntity: BuildingCasePosition::class, mappedBy: 'buildingCase')] + private Collection $id_case_position; + + #[ORM\ManyToOne(inversedBy: 'buildingCases')] + private ?Building $id_building = null; + + public function __construct() + { + $this->id_case_position = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function setId(int $id): static + { + $this->id = $id; + + return $this; + } + + public function getCaseNumber(): ?int + { + return $this->case_number; + } + + public function setCaseNumber(int $case_number): static + { + $this->case_number = $case_number; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function getCapacity(): ?int + { + return $this->capacity; + } + + public function setCapacity(int $capacity): static + { + $this->capacity = $capacity; + + return $this; + } + + /** + * @return Collection + */ + public function getIdCasePosition(): Collection + { + return $this->id_case_position; + } + + public function addIdCasePosition(BuildingCasePosition $idCasePosition): static + { + if (!$this->id_case_position->contains($idCasePosition)) { + $this->id_case_position->add($idCasePosition); + $idCasePosition->setBuildingCase($this); + } + + return $this; + } + + public function removeIdCasePosition(BuildingCasePosition $idCasePosition): static + { + if ($this->id_case_position->removeElement($idCasePosition)) { + // set the owning side to null (unless already changed) + if ($idCasePosition->getBuildingCase() === $this) { + $idCasePosition->setBuildingCase(null); + } + } + + return $this; + } + + public function getIdBuilding(): ?Building + { + return $this->id_building; + } + + public function setIdBuilding(?Building $id_building): static + { + $this->id_building = $id_building; + + return $this; + } +} diff --git a/src/Entity/BuildingCasePosition.php b/src/Entity/BuildingCasePosition.php new file mode 100644 index 0000000..de2196f --- /dev/null +++ b/src/Entity/BuildingCasePosition.php @@ -0,0 +1,146 @@ +id; + } + + public function setId(int $id): static + { + $this->id = $id; + + return $this; + } + + public function getX(): ?int + { + return $this->x; + } + + public function setX(int $x): static + { + $this->x = $x; + + return $this; + } + + public function getY(): ?int + { + return $this->y; + } + + public function setY(int $y): static + { + $this->y = $y; + + return $this; + } + + public function getW(): ?int + { + return $this->w; + } + + public function setW(int $w): static + { + $this->w = $w; + + return $this; + } + + public function getH(): ?int + { + return $this->h; + } + + public function setH(int $h): static + { + $this->h = $h; + + return $this; + } + + public function getRenderOrder(): ?string + { + return $this->render_order; + } + + public function setRenderOrder(string $render_order): static + { + $this->render_order = $render_order; + + return $this; + } + + public function getBuildingLayout(): ?BuildingLayout + { + return $this->buildingLayout; + } + + public function setBuildingLayout(?BuildingLayout $buildingLayout): static + { + $this->buildingLayout = $buildingLayout; + + return $this; + } + + public function getBuildingCase(): ?BuildingCase + { + return $this->buildingCase; + } + + public function setBuildingCase(?BuildingCase $buildingCase): static + { + $this->buildingCase = $buildingCase; + + return $this; + } +} diff --git a/src/Entity/BuildingLayout.php b/src/Entity/BuildingLayout.php new file mode 100644 index 0000000..a019e8a --- /dev/null +++ b/src/Entity/BuildingLayout.php @@ -0,0 +1,141 @@ + + */ + #[ORM\OneToMany(targetEntity: BuildingCasePosition::class, mappedBy: 'buildingLayout')] + #[Groups(['building:read'])] + #[SerializedName('casePositions')] + private Collection $id_case_position; + + public function __construct() + { + $this->id_case_position = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->id; + } + + public function setId(int $id): static + { + $this->id = $id; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getColumns(): ?int + { + return $this->columns; + } + + public function setColumns(int $columns): static + { + $this->columns = $columns; + + return $this; + } + + public function getRows(): ?int + { + return $this->rows; + } + + public function setRows(int $rows): static + { + $this->rows = $rows; + + return $this; + } + + public function getIdBuilding(): ?Building + { + return $this->id_building; + } + + public function setIdBuilding(?Building $id_building): static + { + $this->id_building = $id_building; + + return $this; + } + + /** + * @return Collection + */ + public function getIdCasePosition(): Collection + { + return $this->id_case_position; + } + + public function addIdCasePosition(BuildingCasePosition $idCasePosition): static + { + if (!$this->id_case_position->contains($idCasePosition)) { + $this->id_case_position->add($idCasePosition); + $idCasePosition->setBuildingLayout($this); + } + + return $this; + } + + public function removeIdCasePosition(BuildingCasePosition $idCasePosition): static + { + if ($this->id_case_position->removeElement($idCasePosition)) { + // set the owning side to null (unless already changed) + if ($idCasePosition->getBuildingLayout() === $this) { + $idCasePosition->setBuildingLayout(null); + } + } + + return $this; + } +}