mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
Debug de l'API
This commit is contained in:
parent
32333be41e
commit
5e75888ab7
@ -5,68 +5,100 @@ namespace App\Controller;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
use App\Repository\SiteRepository;
|
use App\Repository\SiteRepository;
|
||||||
use App\Repository\RoomRepository;
|
use App\Repository\FloorRepository;
|
||||||
|
use App\Repository\PlaceRepository;
|
||||||
|
use App\Repository\PlaceNameRepository;
|
||||||
|
use App\Repository\RoomUserNameRepository;
|
||||||
|
use App\Repository\EditionRepository;
|
||||||
|
|
||||||
|
use App\Entity\PlaceName;
|
||||||
|
use App\Entity\RoomUserName;
|
||||||
|
use App\Entity\Edition;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MapApiController extends AbstractController
|
class MapApiController extends AbstractController
|
||||||
{
|
{
|
||||||
|
//function get_Name($rep) {return $rep->getName();}
|
||||||
|
|
||||||
#[Route('/map/api/test')]
|
#[Route('/map/api/test')]
|
||||||
public function test(SiteRepository $rep): JsonResponse
|
public function test(PlaceNameRepository $pNRep, RoomUserNameRepository $uNRep, PlaceRepository $pRep, SiteRepository $sRep): JsonResponse
|
||||||
{
|
{
|
||||||
|
$place0 = $pRep->findPlaceById(1)[0];
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'message' => 'Welcome to your new controller!',
|
'message' => 'Welcome to your new controller!',
|
||||||
'path' => 'src/Controller/MapApiController.php',
|
'path' => 'src/Controller/MapApiController.php',
|
||||||
'sites' => $rep->allSites()[0]->getZeroLatitude()
|
'allUnames' => $uNRep->allNames(),
|
||||||
|
'allPnames' => $pNRep->allNames(),
|
||||||
|
'Place0Id' => $place0->getId(),
|
||||||
|
'Place0UserNames0' => $place0->getRoomUsers()[0]->getUserName(),
|
||||||
|
'Place0Names0' => $place0->getNames()[0]->getName(),
|
||||||
|
'sites' => $sRep->allSites()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(' ')]
|
#[Route('/map/api/get_floor/{id}/{representation}')]
|
||||||
public function get_floor(FloorRepository $rep, int $id, string $representation): JsonResponse
|
public function get_floor(FloorRepository $rep, int $id, string $representation='Cylinder'): JsonResponse
|
||||||
{
|
{
|
||||||
$floor = $rep->findFloorById($id);
|
//id is the floor's id, representation being Cylinder or PolySurface or other if implemented
|
||||||
$places = $floor->getPlace();
|
//it defines which representation should we use to project it on 2 dimension
|
||||||
|
$floors = $rep->findFloorById($id);
|
||||||
|
if (sizeof($floors)!=1) { return $this->json(["Error : None or Too Many Floors have this id"]); }
|
||||||
|
$floor = $floors[0];
|
||||||
|
$places = $floor->getPlaces();
|
||||||
$jsonPlaces = new ArrayCollection();
|
$jsonPlaces = new ArrayCollection();
|
||||||
foreach ($places as $place){
|
if ($representation == 'Cylinder' || $representation == 'PolySurface'){
|
||||||
$jsonPlaces[] = $this->json([
|
foreach ($places as $place){
|
||||||
'id' => $place->getId(),
|
$jsonPlaces[] = array(
|
||||||
'name' => $place->getName(),
|
'id' => $place->getId(),
|
||||||
'type' => $place->getType(),
|
'name' => $place->getJoinedNames(),
|
||||||
'surface' => $place->getTwoDRepresentation($representation, $floor->getAltitude())
|
'type' => $place->getType(),
|
||||||
]);
|
'surface' => $place->getTwoDRepresentation($representation, $floor->getAltitude())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $jsonPlaces;
|
else {
|
||||||
|
return $this->json(["Error on represantation attribute"]);
|
||||||
|
}
|
||||||
|
return $this->json($jsonPlaces->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/map/api/find_place_by_name')]
|
#[Route('/map/api/find_place_by_name/{name}')]
|
||||||
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
|
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
|
||||||
{
|
{
|
||||||
$places = $rep->findPlaceByName($name);
|
$places = $rep->findPlaceByName($name);
|
||||||
if (sizeof($places)!=1) {
|
if (sizeof($places)!=1) { return $this->json([0]); }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$place = $places[0];
|
$place = $places[0];
|
||||||
|
$floorsId = array();
|
||||||
|
foreach ($place->getFloors() as $floor) {
|
||||||
|
$floorsId[] = $floor->getId();
|
||||||
|
}
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'idRoom' => $place->getId(),
|
'idRoom' => $place->getId(),
|
||||||
'idFloor' => $place->getFloor()->getId()
|
'idFloors' => $floorsId
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[Route('/map/api/show_place_info')]
|
#[Route('/map/api/show_place_info/{id}')]
|
||||||
public function index(PlaceRepository $rep, int $id): JsonResponse
|
public function index(PlaceRepository $rep, int $id): JsonResponse
|
||||||
{
|
{
|
||||||
$places = $rep->findPlaceById($id);
|
$places = $rep->findPlaceById($id);
|
||||||
if (sizeof($places)!=1) {
|
if (sizeof($places)!=1) {
|
||||||
return null;
|
return $this->json([0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'idRoom' => $places[0]->getId(),
|
'idRoom' => $places[0]->getId(),
|
||||||
'names' => $places[0]->getName(),
|
'names' => $places[0]->getJoinedNames(),
|
||||||
'users' => $places[0]->getUser()
|
'users' => $places[0]->getJoinedRoomUsersNames()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,80 +108,95 @@ class MapApiController extends AbstractController
|
|||||||
{
|
{
|
||||||
$edits = $rep->getAllEditions();
|
$edits = $rep->getAllEditions();
|
||||||
if (sizeof($edits)<1) {
|
if (sizeof($edits)<1) {
|
||||||
return null;
|
return $this->json([0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$listEdits = new ArrayCollection();
|
$listEdits = array();
|
||||||
foreach ($edits as $edit){
|
foreach ($edits as $edit){
|
||||||
$listEdits[] = $this->json([
|
$listEdits[] = array(
|
||||||
'id' => $edit->getId(),
|
'id' => $edit->getId(),
|
||||||
'mode' => $edit->getMode(),
|
'mode' => $edit->getMode(),
|
||||||
'name' => $edit->getNamePlace(),
|
'placeNames' => $edit->getEditedPlace()->getJoinedNames(),
|
||||||
'idPlace' => $edit->getIdPlace(),
|
'placeId' => $edit->getEditedPlace()->getId(),
|
||||||
'value' => $edit->getValue()
|
'editorValue' => $edit->getValue()
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $listEdits;
|
return $this->json($listEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/map/api/create_edition')]
|
#[Route('/map/api/create_edition/{mode}/{placeId}/{value}')]
|
||||||
public function createEdition(EditionRepository $Erep, PlaceRepository $Prep, string $mode, int $idPlace, string $value): bool
|
public function createEdition(EditionRepository $Erep, PlaceRepository $Prep, string $mode, int $placeId, string $value): JsonResponse
|
||||||
{
|
{
|
||||||
|
//mode is the type of modification, can be AddPlaceName ; DelPlaceName ; AddRoomUserName or DelRoomUserName
|
||||||
$edit = new Edition();
|
$edit = new Edition();
|
||||||
$edit->createEdition($Prep, $mode, $idPlace, $value);
|
if ($edit->initEdition($Prep, $mode, $placeId, $value) == null) {return $this->json(["Error during initEdition : None or Too Many Places found with id"]);}
|
||||||
return $Erep->add($edit);
|
$Erep->add($edit, true);
|
||||||
|
return $this->json(["added"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/map/api/remove_edition')]
|
#[Route('/map/api/remove_edition/{id}')]
|
||||||
public function removeEdition(EditionRepository $rep, int $id): bool
|
public function removeEdition(EditionRepository $rep, int $id): JsonResponse
|
||||||
{
|
{
|
||||||
$edit = $rep->findEditionById($id);
|
$edit = $rep->findEditionById($id);
|
||||||
if ($edit == null) {return false;}
|
if (sizeof($edit) == 0) {return $this->json([0]);}
|
||||||
$rep->remove($edit);
|
$rep->remove($edit[0], true);
|
||||||
return true;
|
return $this->json(["removed"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/map/api/add_place_name/{placeId}/{value}')]
|
||||||
|
public function addPlaceName(PlaceRepository $pRep, PlaceNameRepository $pNRep, int $placeId, string $value): JsonResponse
|
||||||
|
{
|
||||||
|
$places = $pRep->findPlaceById($placeId);
|
||||||
|
if (sizeof($places) != 1) { return $this->json([0]); }
|
||||||
|
else{
|
||||||
|
$names = new ArrayCollection();
|
||||||
|
foreach($places[0]->getNames() as $plName) { $names[] = $plName->getName(); }
|
||||||
|
if ($names->contains($value)) { return $this->json([2]); }
|
||||||
|
else {
|
||||||
|
$pN = new PlaceName();
|
||||||
|
$pN->setPlace($places[0]);
|
||||||
|
$pN->setName($value);
|
||||||
|
$pNRep->add($pN, true);
|
||||||
|
return $this->json(["added"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[Route('/map/api/del_place_name/{placeId}/{value}')]
|
||||||
|
public function delPlaceName(PlaceNameRepository $pNRep, int $placeId, string $value): JsonResponse
|
||||||
|
{
|
||||||
|
$pN = $pNRep->findPlaceName($placeId, $value);
|
||||||
|
if (sizeof($pN)==0) { return $this->json([0]); }
|
||||||
|
$pNRep->remove($pN[0], true);
|
||||||
|
return $this->json(["removed"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/map/api/del_place_name')]
|
|
||||||
public function delPlaceName(PlaceRepository $rep, int $id, string $value): bool
|
#[Route('/map/api/add_room_user_name/{placeId}/{value}')]
|
||||||
|
public function addRoomUserName(PlaceRepository $pRep, RoomUserNameRepository $rURep, ManagerRegistry $mr, int $placeId, string $value): JsonResponse
|
||||||
{
|
{
|
||||||
$places = $rep->findPlaceById($id);
|
$places = $pRep->findPlaceById($placeId);
|
||||||
if (sizeof($places)!=1) { return null; }
|
if (sizeof($places) != 1) { return $this->json([0]); }
|
||||||
else {
|
else{
|
||||||
$places[0]->removeName($value);
|
$names = new ArrayCollection();
|
||||||
return true;
|
foreach($places[0]->getRoomUsers() as $rUser) { $names[] = $rUser->getUserName(); }
|
||||||
|
if ($names->contains($value)) { return $this->json([2]); }
|
||||||
|
else {
|
||||||
|
$rU = new RoomUserName();
|
||||||
|
$rU->setPlace($places[0]);
|
||||||
|
$rU->setUserName($value);
|
||||||
|
$rURep->add($rU, true);
|
||||||
|
return $this->json(["added"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[Route('/map/api/add_place_name')]
|
#[Route('/map/api/del_room_user_name/{placeId}/{value}')]
|
||||||
public function addPlaceName(PlaceRepository $rep, int $id, string $value): bool
|
public function delRoomUserName(RoomUserNameRepository $uRep, int $placeId, string $value): JsonResponse
|
||||||
{
|
{
|
||||||
$places = $rep->findPlaceById($id);
|
$rU = $uRep->findRoomUserName($placeId, $value);
|
||||||
if (sizeof($places)!=1) { return null; }
|
if (sizeof($rU)==0) { return $this->json([0]); }
|
||||||
else {
|
$uRep->remove($rU[0], true);
|
||||||
$places[0]->addName($value);
|
return $this->json(["removed"]);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[Route('/map/api/del_room_user_name')]
|
|
||||||
public function delRoomUserName(PlaceRepository $rep, int $id, string $value): bool
|
|
||||||
{
|
|
||||||
$rooms = $rep->findPlaceById($id);
|
|
||||||
if (sizeof($rooms)!=1) { return null; }
|
|
||||||
else {
|
|
||||||
$rooms[0]->removeRoomUser($value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[Route('/map/api/add_room_user_name')]
|
|
||||||
public function addRoomUserName(PlaceRepository $rep, int $id, string $value): bool
|
|
||||||
{
|
|
||||||
$rooms = $rep->findPlaceById($id);
|
|
||||||
if (sizeof($rooms)!=1) { return null; }
|
|
||||||
else {
|
|
||||||
$rooms[0]->addRoomUser($value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,9 @@ class Building
|
|||||||
#[ORM\Column(type: "integer")]
|
#[ORM\Column(type: "integer")]
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
#[ORM\Column(type: "string")]
|
||||||
|
private $name;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: Site::class, inversedBy: "buildings")]
|
#[ORM\ManyToOne(targetEntity: Site::class, inversedBy: "buildings")]
|
||||||
#[ORM\JoinColumn(nullable: false)]
|
#[ORM\JoinColumn(nullable: false)]
|
||||||
private $site;
|
private $site;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class Edition
|
|||||||
#[ORM\Column(type: "string")]
|
#[ORM\Column(type: "string")]
|
||||||
private $mode;
|
private $mode;
|
||||||
|
|
||||||
#[ORM\OneToMany(targetEntity: Place::class, mappedBy: "editions")]
|
#[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "editions")]
|
||||||
private $editedPlace;
|
private $editedPlace;
|
||||||
|
|
||||||
#[ORM\Column(type: "string")]
|
#[ORM\Column(type: "string")]
|
||||||
@ -43,11 +43,11 @@ class Edition
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIdPlace(): ?int
|
public function getEditedPlace(): Place
|
||||||
{ return $this->idPlace; }
|
{ return $this->editedPlace; }
|
||||||
public function setIdPlace(int $id): self
|
public function setEditedPlace(Place $p): self
|
||||||
{
|
{
|
||||||
$this->idPlace = $id;
|
$this->editedPlace = $p;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,18 +68,19 @@ class Edition
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function createEdition(PlaceRepository $rep, string $mode, int $id, string $val): self
|
public function initEdition(PlaceRepository $rep, string $mode, int $id, string $val): self
|
||||||
{
|
{
|
||||||
$place = $rep->findPlaceById($id);
|
$places = $rep->findPlaceById($id);
|
||||||
if ($place==null) { return null; }
|
if (sizeof($places)!=1) { return null; }
|
||||||
$names = $place->getName();
|
$place=$places[0];
|
||||||
$name = '';
|
// $names = $place->getJoinedNames();
|
||||||
foreach ($names as $n) {
|
// $name = '';
|
||||||
$name = $name + $n + ", " ;
|
// foreach ($names as $n) {
|
||||||
}
|
// $name = $name . $n . ", " ;
|
||||||
|
// }
|
||||||
$this->mode = $mode;
|
$this->mode = $mode;
|
||||||
$this->idPlace = $id;
|
$this->editedPlace = $place;
|
||||||
$this->namePlace = $name;
|
// $this->namePlace = $name;
|
||||||
$this->val = $val;
|
$this->val = $val;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class Place
|
|||||||
#[ORM\OneToMany(targetEntity: PolySurface::class, mappedBy: "place")]
|
#[ORM\OneToMany(targetEntity: PolySurface::class, mappedBy: "place")]
|
||||||
private $PolySurfaceRepresentation;
|
private $PolySurfaceRepresentation;
|
||||||
|
|
||||||
#[ORM\ManyToOne(targetEntity: Edition::class, inversedBy: "editedPlace")]
|
#[ORM\OneToMany(targetEntity: Edition::class, mappedBy: "editedPlace")]
|
||||||
private $editions;
|
private $editions;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -86,7 +86,16 @@ class Place
|
|||||||
return $this->names;
|
return $this->names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addName(self $name): self
|
public function getJoinedNames(): array
|
||||||
|
{
|
||||||
|
$names = new ArrayCollection();
|
||||||
|
foreach ($this->names as $plName) {
|
||||||
|
$names[] = $plName->getName();
|
||||||
|
}
|
||||||
|
return $names->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addName(PlaceName $name): self
|
||||||
{
|
{
|
||||||
if (!$this->names->contains($name)) {
|
if (!$this->names->contains($name)) {
|
||||||
$this->names[] = $name;
|
$this->names[] = $name;
|
||||||
@ -94,11 +103,28 @@ class Place
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeName(self $name): self
|
public function removeName(PlaceName $name): self
|
||||||
{
|
{
|
||||||
$this->names->removeElement($name);
|
$this->names->removeElement($name);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, self>
|
||||||
|
*/
|
||||||
|
public function getEditions(): Collection
|
||||||
|
{ return $this->editions;
|
||||||
|
}
|
||||||
|
public function addEdition(Edition $edition): self
|
||||||
|
{ if (!$this->editions->contains($edition)) {
|
||||||
|
$this->editions[] = $edition;
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function removeEdition(Edition $edition): self
|
||||||
|
{ $this->editions->removeElement($edition);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection<int, self>
|
* @return Collection<int, self>
|
||||||
@ -108,8 +134,16 @@ class Place
|
|||||||
{
|
{
|
||||||
return $this->users;
|
return $this->users;
|
||||||
}
|
}
|
||||||
|
public function getJoinedRoomUsersNames(): array
|
||||||
|
{
|
||||||
|
$names = new ArrayCollection();
|
||||||
|
foreach ($this->users as $roomUserName) {
|
||||||
|
$names[] = $roomUserName->getUserName();
|
||||||
|
}
|
||||||
|
return $names->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public function addRoomUser(self $user): self
|
public function addRoomUser(RoomUserName $user): self
|
||||||
{
|
{
|
||||||
if (!$this->users->contains($user)) {
|
if (!$this->users->contains($user)) {
|
||||||
$this->users[] = $user;
|
$this->users[] = $user;
|
||||||
@ -117,7 +151,7 @@ class Place
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeRoomUser(self $user): self
|
public function removeRoomUser(RoomUserName $user): self
|
||||||
{
|
{
|
||||||
$this->users->removeElement($user);
|
$this->users->removeElement($user);
|
||||||
return $this;
|
return $this;
|
||||||
@ -317,26 +351,26 @@ class Place
|
|||||||
public function getTwoDRepresentation(string $representation, int $alt) : array
|
public function getTwoDRepresentation(string $representation, int $alt) : array
|
||||||
{
|
{
|
||||||
if ($representation=='Cylinder') {
|
if ($representation=='Cylinder') {
|
||||||
$rep = $this->getCylinderRepresentation();
|
$rep = $this->getCylinderRepresentation()[0]; //ARBITRARY
|
||||||
if ($rep != null){
|
if ($rep != null){
|
||||||
$repPoints = $rep->getCylinderbase()->getPolygonpoint(); //Points in repository format
|
$repPoints = $rep->getCylinderbase()->getPolygonpoint(); //Points in repository format
|
||||||
$Points = new ArrayCollection();
|
$Points = new ArrayCollection();
|
||||||
foreach ($repPoints as $p) {
|
foreach ($repPoints as $p) {
|
||||||
$xy=array([$p->getX(), $p->getY()]);
|
$xy=array('x'=>$p->getX(), 'y'=>$p->getY());
|
||||||
if (!$Points->contains($xy)){
|
if (!$Points->contains($xy)){
|
||||||
$Points[] = $xy;
|
$Points[] = $xy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $Points;
|
return $Points->toArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($representation=='PolySurface') {
|
elseif ($representation=='PolySurface') {
|
||||||
$rep = $this->getPolySurfaceRepresentation();
|
$rep = $this->getPolySurfaceRepresentation()[0]; //ARBITRARY
|
||||||
if ($rep != null){
|
if ($rep != null){
|
||||||
$repPoints = $rep->getPolysurfaceComponent()->getPolygonpoint(); //Points in repository format
|
$repPoints = $rep->getPolysurfaceComponent()->getPolygonpoint(); //Points in repository format
|
||||||
$Points = new ArrayCollection();
|
$Points = new ArrayCollection();
|
||||||
foreach ($repPoints as $p) {
|
foreach ($repPoints as $p) {
|
||||||
$xy=array([$p->getX(), $p->getY()]);
|
$xy=array('x'=>$p->getX(), 'y'=>$p->getY());
|
||||||
if (!$Points->contains($xy)){
|
if (!$Points->contains($xy)){
|
||||||
$Points[] = $xy;
|
$Points[] = $xy;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,9 @@ class Site
|
|||||||
#[ORM\Column(type: "integer")]
|
#[ORM\Column(type: "integer")]
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
// #[ORM\Column(type: "string")]
|
||||||
|
// private $name;
|
||||||
|
|
||||||
#[ORM\Column(type: "float")]
|
#[ORM\Column(type: "float")]
|
||||||
private $zeroLatitude;
|
private $zeroLatitude;
|
||||||
|
|
||||||
|
|||||||
@ -39,9 +39,19 @@ class FloorRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @return Floor[] Returns an array of Floor objects
|
* @return Floor[] Returns an array of Floor objects
|
||||||
// */
|
*/
|
||||||
|
public function findFloorById(int $id): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('f')
|
||||||
|
->andWhere('f.id = :val')
|
||||||
|
->setParameter('val', $id)
|
||||||
|
->orderBy('f.id', 'ASC')
|
||||||
|
->getQuery()
|
||||||
|
->getResult()
|
||||||
|
;
|
||||||
|
}
|
||||||
// public function findByExampleField($value): array
|
// public function findByExampleField($value): array
|
||||||
// {
|
// {
|
||||||
// return $this->createQueryBuilder('f')
|
// return $this->createQueryBuilder('f')
|
||||||
|
|||||||
@ -36,14 +36,27 @@ class PlaceNameRepository extends ServiceEntityRepository
|
|||||||
/**
|
/**
|
||||||
* @return PlaceName[] Returns an array of PlaceName objects
|
* @return PlaceName[] Returns an array of PlaceName objects
|
||||||
*/
|
*/
|
||||||
public function findPlaceNameById(int $id): array
|
public function findPlaceNameById(int $id): array
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('p')
|
return $this->createQueryBuilder('p')
|
||||||
->andWhere('p.id = :val')
|
->andWhere('p.id = :val')
|
||||||
->setParameter('val', $id)
|
->setParameter('val', $id)
|
||||||
->orderBy('p.id', 'ASC')
|
->orderBy('p.id', 'ASC')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
->getResult()
|
->getResult()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
public function allNames(): array
|
||||||
|
{ return $this->createQueryBuilder('pn')->select('pn.name')->orderBy('pn.id','ASC')->getQuery()->getResult(); }
|
||||||
|
|
||||||
|
public function findPlaceName(int $id, string $value): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('pn')
|
||||||
|
->where('pn.place = :id')
|
||||||
|
->andWhere('pn.name = :val')
|
||||||
|
->setParameter('id', $id)
|
||||||
|
->setParameter('val', $value)
|
||||||
|
->orderBy('pn.id','ASC')
|
||||||
|
->getQuery()->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace App\Repository;
|
namespace App\Repository;
|
||||||
|
|
||||||
use App\Entity\Place;
|
use App\Entity\Place;
|
||||||
|
use App\Entity\PlaceName;
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
|
||||||
@ -45,7 +46,8 @@ class PlaceRepository extends ServiceEntityRepository
|
|||||||
public function findPlaceByName(string $name): array
|
public function findPlaceByName(string $name): array
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('p')
|
return $this->createQueryBuilder('p')
|
||||||
->andWhere('LOWER(p.name) = :val')
|
->join('App\Entity\PlaceName', 'n', 'WITH', 'p.id = n.place')
|
||||||
|
->andWhere('LOWER(n.name) = :val')
|
||||||
->setParameter('val', strtolower($name))
|
->setParameter('val', strtolower($name))
|
||||||
->orderBy('p.id', 'ASC')
|
->orderBy('p.id', 'ASC')
|
||||||
->getQuery()
|
->getQuery()
|
||||||
@ -66,6 +68,10 @@ class PlaceRepository extends ServiceEntityRepository
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function allPlaces(): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('s')->orderBy('s.id','ASC')->getQuery()->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?Place
|
// public function findOneBySomeField($value): ?Place
|
||||||
|
|||||||
@ -46,4 +46,18 @@ class RoomUserNameRepository extends ServiceEntityRepository
|
|||||||
->getResult()
|
->getResult()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function allNames(): array
|
||||||
|
{ return $this->createQueryBuilder('ru')->select('ru.userName')->orderBy('ru.id','ASC')->getQuery()->getResult(); }
|
||||||
|
|
||||||
|
public function findRoomUserName(int $placeId, string $value): array
|
||||||
|
{
|
||||||
|
return $this->createQueryBuilder('u')
|
||||||
|
->where('u.place = :id')
|
||||||
|
->andWhere('u.userName = :val')
|
||||||
|
->setParameter('id', $placeId)
|
||||||
|
->setParameter('val', $value)
|
||||||
|
->orderBy('u.id','ASC')
|
||||||
|
->getQuery()->getResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user