mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-18 23:21:04 +01:00
Ajout de quelques scripts de debug pour pouvoir ajouter des données en mosse
This commit is contained in:
parent
87518f9ebc
commit
c1d6a21077
132
src/Controller/JsonReaderController.php
Normal file
132
src/Controller/JsonReaderController.php
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use App\Repository\SiteRepository;
|
||||||
|
use App\Entity\Room;
|
||||||
|
use App\Entity\Cylinder;
|
||||||
|
use App\Entity\Point;
|
||||||
|
use App\Entity\PlaneSurface;
|
||||||
|
use App\Entity\Site;
|
||||||
|
|
||||||
|
class JsonReaderController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/api/debug/loadJson')]
|
||||||
|
public function index(SiteRepository $srep): Response
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$response = new Response();
|
||||||
|
$response->setStatusCode(Response::HTTP_OK);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/debug/initialData')]
|
||||||
|
public function init(SiteRepository $srep, BuildingRepository $brep, FloorRepository $frep): Response
|
||||||
|
{
|
||||||
|
$s = new Site();
|
||||||
|
$p->setX();
|
||||||
|
$p->setY();
|
||||||
|
$p->setZ();
|
||||||
|
$prep->add($p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/debug/newRoom')]
|
||||||
|
public function addRoom(Request $request, ManagerRegistry $mr): Response {
|
||||||
|
|
||||||
|
$manager = $mr->getManager();
|
||||||
|
|
||||||
|
//return new Response(print_r($request->request->all()));
|
||||||
|
|
||||||
|
$height = $request->request->get('height');
|
||||||
|
$z = $request->request->get('z');
|
||||||
|
$name = $request->request->get('name');
|
||||||
|
$points = json_decode($request->request->get('points'));
|
||||||
|
|
||||||
|
$r = new Room();
|
||||||
|
$cyl = new Cylinder();
|
||||||
|
$cyl->setHeight($height);
|
||||||
|
$cbas = new PlaneSurface();
|
||||||
|
foreach($points as $px) {
|
||||||
|
$p = new Point();
|
||||||
|
$p->setX($px[0]);
|
||||||
|
$p->setY($px[1]);
|
||||||
|
$p->setZ($z);
|
||||||
|
$manager->persist($p);
|
||||||
|
$cbas->addPolygonpoint($p);
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->persist($cbas);
|
||||||
|
$cyl->setCylinderBase($cbas);
|
||||||
|
$manager->persist($cyl);
|
||||||
|
$r->addCylinderRepresentation($cyl);
|
||||||
|
$manager->persist($r);
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
return new Response($r->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/debug/newCorridor')]
|
||||||
|
public function addCorridor(Request $request, ManagerRegistry $mr, FloorRepository $frep): Response {
|
||||||
|
|
||||||
|
$manager = $mr->getManager();
|
||||||
|
|
||||||
|
//return new Response(print_r($request->request->all()));
|
||||||
|
|
||||||
|
$z = $request->request->get('z');
|
||||||
|
$name = $request->request->get('name');
|
||||||
|
$floorid = $request->request->get('floorid');
|
||||||
|
//$points = json_decode($request->request->get('points'));
|
||||||
|
|
||||||
|
$f = $manager->getRepository(Floor::class)->find($floorid);
|
||||||
|
$c = new Corridor();
|
||||||
|
/*$cyl = new Cylinder();
|
||||||
|
$cyl->setHeight($height);
|
||||||
|
$cbas = new PlaneSurface();
|
||||||
|
foreach($points as $px) {
|
||||||
|
$p = new Point();
|
||||||
|
$p->setX($px[0]);
|
||||||
|
$p->setY($px[1]);
|
||||||
|
$p->setZ($z);
|
||||||
|
$manager->persist($p);
|
||||||
|
$cbas->addPolygonpoint($p);
|
||||||
|
}
|
||||||
|
|
||||||
|
$manager->persist($cbas);
|
||||||
|
$cyl->setCylinderBase($cbas);
|
||||||
|
$manager->persist($cyl);
|
||||||
|
$r->addCylinderRepresentation($cyl);*/
|
||||||
|
$f->addCorridor($c)
|
||||||
|
$manager->persist($c);
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
return new Response($c->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/debug/connect')]
|
||||||
|
public function addCorridor(Request $request, ManagerRegistry $mr, PlaceRepository $prep): Response {
|
||||||
|
|
||||||
|
$manager = $mr->getManager();
|
||||||
|
|
||||||
|
//return new Response(print_r($request->request->all()));
|
||||||
|
|
||||||
|
$aid = $request->request->get('a');
|
||||||
|
$bid = $request->request->get('b');
|
||||||
|
|
||||||
|
$a = $prep->find($aid);
|
||||||
|
$b = $prep->find($bid);
|
||||||
|
|
||||||
|
$a->addConnection($b);
|
||||||
|
|
||||||
|
$manager->flush();
|
||||||
|
|
||||||
|
return new Response("OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -8,20 +8,11 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
#[ORM\Entity(repositoryClass: CorridorRepository::class)]
|
#[ORM\Entity(repositoryClass: CorridorRepository::class)]
|
||||||
class Corridor extends Place
|
class Corridor extends Place
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column(type: "integer")]
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: Floor::class, inversedBy: "corridors")]
|
#[ORM\ManyToOne(targetEntity: Floor::class, inversedBy: "corridors")]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
private $floor;
|
private $floor;
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFloor(): ?Floor
|
public function getFloor(): ?Floor
|
||||||
{
|
{
|
||||||
return $this->floor;
|
return $this->floor;
|
||||||
|
|||||||
@ -10,10 +10,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
#[ORM\Entity(repositoryClass: RoomRepository::class)]
|
#[ORM\Entity(repositoryClass: RoomRepository::class)]
|
||||||
class Room extends Place
|
class Room extends Place
|
||||||
{
|
{
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column(type: "integer")]
|
|
||||||
private $id;
|
|
||||||
|
|
||||||
#[ORM\OneToMany(targetEntity: ThreeDObjectFile::class, mappedBy: "room")]
|
#[ORM\OneToMany(targetEntity: ThreeDObjectFile::class, mappedBy: "room")]
|
||||||
private $ComplexRepresentation;
|
private $ComplexRepresentation;
|
||||||
@ -32,11 +28,6 @@ class Room extends Place
|
|||||||
$this->CylinderRepresentation = new ArrayCollection();
|
$this->CylinderRepresentation = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, ThreeDObjectFile>
|
* @return Collection<int, ThreeDObjectFile>
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user