mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
ca239c1122
42
API.md
42
API.md
@ -19,13 +19,22 @@ __The dict looks like :__
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
'idSite' : int, //id of the Site
|
'idSite' : int, //id of the Site
|
||||||
|
'nameSite' : string, //name of the Site
|
||||||
'idBuilding': int, //id of the Building
|
'idBuilding': int, //id of the Building
|
||||||
|
'nameBuilding': string, //name of the Building
|
||||||
'places : [
|
'places : [
|
||||||
{
|
{
|
||||||
'id': int, //unique id
|
'id': int, //unique id
|
||||||
'names' : string[], //Names of the place, possibly empty,
|
'names' : string[], //Names of the place, possibly empty,
|
||||||
'type': string, //in {'C'(orridor), 'S'(tairs), 'E'(levator), 'R'(oom)} ,
|
'type': string, //in {'C'(orridor), 'S'(tairs), 'E'(levator), 'R'(oom)} ,
|
||||||
'surface' : list of [int, int] //list of every points composing the room, projected on the floor surface
|
'surface' : list of [int, int] //list of every points composing the room, projected on the floor surface
|
||||||
|
'connectedFloors' : [
|
||||||
|
{
|
||||||
|
'id' : int,
|
||||||
|
'name' : string
|
||||||
|
},
|
||||||
|
{...}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{...}
|
{...}
|
||||||
]
|
]
|
||||||
@ -83,22 +92,31 @@ __The json will look like :__
|
|||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
### /api/map/find_place_by_name/NAME
|
### /api/map/find_place_by_name/NAME
|
||||||
>Return a dict representing the list of places with NAME.
|
> Return a list of dict representing all places with NAME.
|
||||||
|
|
||||||
__Format of the dict :__
|
__Format of the dict :__
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
'idPlace':int, //unique id of the place
|
'idPlace':int, //unique id of the place
|
||||||
|
'namePlace':string[], //list of Names of the place
|
||||||
'idSite': int, //id of the place Site
|
'idSite': int, //id of the place Site
|
||||||
'idBuilding': int, //id of the place Building
|
'nameSite' : string, //name of the Site
|
||||||
'idFloors': int[] //list of every floorID the place is in
|
'idBuilding': int, //id of the Building
|
||||||
|
'nameBuilding': string, //name of the Building
|
||||||
|
'floors': [ //list of every {floorID, floorName} the place is in
|
||||||
|
{
|
||||||
|
'name': string, //name of the first floor of the building
|
||||||
|
'id' : int //its id
|
||||||
|
},
|
||||||
|
{...}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{...}
|
{...}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
__Errors :__
|
__Notes :__
|
||||||
- If _NAME_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError".
|
- If _NAME_ doesn't correspond to any registered place : Return an Empty list.
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
@ -132,7 +150,7 @@ __Errors :__
|
|||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
### /api/map/show_place_info/ID
|
### /api/map/get_place_info/ID
|
||||||
|
|
||||||
> Return a dict with main pieces of informations of the place ID.
|
> Return a dict with main pieces of informations of the place ID.
|
||||||
|
|
||||||
@ -141,7 +159,8 @@ __Format of the dict :__
|
|||||||
{
|
{
|
||||||
'idPlace': int,
|
'idPlace': int,
|
||||||
'names': string[], // list of names for this place
|
'names': string[], // list of names for this place
|
||||||
'users': string[] // list of users' name (professors, etc)
|
'users': string[], // list of users' name (professors, etc)
|
||||||
|
'floors' : int[] // list of floorIds the place is connected.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
__Errors :__
|
__Errors :__
|
||||||
@ -157,14 +176,17 @@ __Each edition is a dict :__
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
'id': int // id of the edition,
|
'id': int // id of the edition,
|
||||||
'mode': string, // should be AddName, RemoveName, AddUser or RemoveUser
|
'mode': string, // could be add_place_name, del_place_name, add_room_user_name or del_room_user_name
|
||||||
'placeNames': string[], // list of names of the place
|
'placeNames': string[], // list of names of the place
|
||||||
'placeId': string, // id of the place
|
'placeId': string, // id of the place
|
||||||
'editorValue': string // the value to add or remove
|
'editorValue': string // the value to add or remove
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
__Errors :__
|
|
||||||
- If there is no pending edition : Return Error 404 "NotFoundHttpError" > It's a Warning that is not fatal (but I didn't manage to raise a warning with symfony so it's still an error)
|
__Notes :__
|
||||||
|
- If there is no pending edition : Return Empty list
|
||||||
|
- The strings in mode are transparent to the API so the given names are only an advice. The only rules is to set adequaly create_edition and the treatment of editions.
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
### /api/map/create_edition/MODE/PLACEID/VALUE
|
### /api/map/create_edition/MODE/PLACEID/VALUE
|
||||||
|
|||||||
@ -94,22 +94,12 @@ class MapApiController extends AbstractController
|
|||||||
$jsonPlaces = array();
|
$jsonPlaces = array();
|
||||||
if ($representation == 'Cylinder' || $representation == 'PolySurface'){
|
if ($representation == 'Cylinder' || $representation == 'PolySurface'){
|
||||||
foreach ($places as $place){
|
foreach ($places as $place){
|
||||||
$connectedFloors = new ArrayCollection();
|
|
||||||
$connectedFloors[] = $floor->getId();
|
|
||||||
foreach ($place->getConnectedPlaces() as $cp) {
|
|
||||||
foreach ($cp->getFloors() as $cf) {
|
|
||||||
if (!$connectedFloors->contains($cf->getId())){
|
|
||||||
$connectedFloors[] = $cf->getId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$connectedFloors->removeElement($floor->getId());
|
|
||||||
$jsonPlaces[] = array(
|
$jsonPlaces[] = array(
|
||||||
'id' => $place->getId(),
|
'id' => $place->getId(),
|
||||||
'names' => $place->getJoinedNames(),
|
'names' => $place->getJoinedNames(),
|
||||||
'type' => $place->getType(),
|
'type' => $place->getType(),
|
||||||
'surface' => $place->getTwoDRepresentation($representation, $floor->getAltitude()),
|
'surface' => $place->getTwoDRepresentation($representation, $floor->getAltitude()),
|
||||||
'connectedFloors' => $connectedFloors->toArray() #$rep->getFloorsIdConnectedToPlaceID($place->getId()) // Will be added later
|
'connectedFloors' => $place->getFloorsNameAndId() #$rep->getFloorsIdConnectedToPlaceID($place->getId()) // Will be added later
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -117,8 +107,12 @@ class MapApiController extends AbstractController
|
|||||||
return $this->json("Error on represantation attribute");
|
return $this->json("Error on represantation attribute");
|
||||||
}
|
}
|
||||||
$building = $floor->getBuilding();
|
$building = $floor->getBuilding();
|
||||||
return $this->json(['idSite' => $building->getSite()->getId(),
|
return $this->json([
|
||||||
|
'name' => $floor->getName(),
|
||||||
|
'idSite' => $building->getSite()->getId(),
|
||||||
|
'nameSite' => $building->getSite()->getName(),
|
||||||
'idBuilding' => $building->getId(),
|
'idBuilding' => $building->getId(),
|
||||||
|
'nameBuilding' => $building->getName(),
|
||||||
'places' => $jsonPlaces
|
'places' => $jsonPlaces
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -145,29 +139,29 @@ class MapApiController extends AbstractController
|
|||||||
#[Route('/api/map/find_place_by_name/{name}')]
|
#[Route('/api/map/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);
|
$result = array();
|
||||||
if (sizeof($places)==0){ throw new NotFoundHttpException('Error: \''.$name.'\' doesn\'t correspond to any placeName.'); }
|
foreach ($rep->findPlaceByName($name) as $place){
|
||||||
else {
|
$floors = array();
|
||||||
$all = array();
|
|
||||||
foreach ($places as $place){
|
|
||||||
$floorsId = array();
|
|
||||||
foreach ($place->getFloors() as $floor) {
|
foreach ($place->getFloors() as $floor) {
|
||||||
$floorsId[] = $floor->getId();
|
$floors[] = $floor->getId();
|
||||||
}
|
}
|
||||||
$building = $place->getFloors()[0]->getBuilding();
|
$building = $place->getFloors()[0]->getBuilding();
|
||||||
$all[] = array('idRoom' => $place->getId(),
|
$result[] = array(
|
||||||
|
'idPlace' => $place->getId(),
|
||||||
|
'namePlace' => $place->getJoinedNames(),
|
||||||
'idSite' => $building->getSite()->getId(),
|
'idSite' => $building->getSite()->getId(),
|
||||||
|
'nameSite' => $building->getSite()->getName(),
|
||||||
'idBuilding' => $building->getId(),
|
'idBuilding' => $building->getId(),
|
||||||
'idFloors' => $floorsId
|
'nameBuilding' => $building->getName(),
|
||||||
|
'floors' => $place->getFloorsNameAndId()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->json($all);
|
return $this->json($result);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[Route('/api/map/show_place_info/{id}')]
|
#[Route('/api/map/get_place_info/{id}')]
|
||||||
public function show_place_info(PlaceRepository $rep, int $id): JsonResponse
|
public function get_place_info(PlaceRepository $rep, int $id): JsonResponse
|
||||||
{
|
{
|
||||||
$places = $rep->findPlaceById($id);
|
$places = $rep->findPlaceById($id);
|
||||||
if (sizeof($places) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any place.'); }
|
if (sizeof($places) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any place.'); }
|
||||||
@ -185,11 +179,8 @@ class MapApiController extends AbstractController
|
|||||||
#[Route('/api/map/get_all_editions')]
|
#[Route('/api/map/get_all_editions')]
|
||||||
public function getEditions(EditionRepository $rep): JsonResponse
|
public function getEditions(EditionRepository $rep): JsonResponse
|
||||||
{
|
{
|
||||||
$edits = $rep->getAllEditions();
|
|
||||||
if (sizeof($edits)<1) { throw new NotFoundHttpException('Warning: There is no more edition to check.'); }
|
|
||||||
else {
|
|
||||||
$listEdits = array();
|
$listEdits = array();
|
||||||
foreach ($edits as $edit){
|
foreach ($rep->getAllEditions() as $edit){
|
||||||
$listEdits[] = array(
|
$listEdits[] = array(
|
||||||
'id' => $edit->getId(),
|
'id' => $edit->getId(),
|
||||||
'mode' => $edit->getMode(),
|
'mode' => $edit->getMode(),
|
||||||
@ -198,7 +189,6 @@ class MapApiController extends AbstractController
|
|||||||
'editorValue' => $edit->getValue()
|
'editorValue' => $edit->getValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $this->json($listEdits);
|
return $this->json($listEdits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ class Building
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{ return $this->id;
|
{ return $this->name;
|
||||||
}
|
}
|
||||||
public function setName(string $name): self
|
public function setName(string $name): self
|
||||||
{ $this->name = $name;
|
{ $this->name = $name;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ class Floor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{ return $this->id;
|
{ return $this->name;
|
||||||
}
|
}
|
||||||
public function setName(string $name): self
|
public function setName(string $name): self
|
||||||
{ $this->name = $name;
|
{ $this->name = $name;
|
||||||
|
|||||||
@ -169,6 +169,14 @@ class Place
|
|||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
public function getFloorsNameAndId(): array
|
||||||
|
{
|
||||||
|
$response = array();
|
||||||
|
foreach ($this->floors as $f) {
|
||||||
|
$response[] = array('id' => $f->getId(), 'name' => $f->getName());
|
||||||
|
}
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
public function addFloor(Floor $floor): self
|
public function addFloor(Floor $floor): self
|
||||||
{
|
{
|
||||||
|
|||||||
@ -37,7 +37,7 @@ class Site
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{ return $this->id;
|
{ return $this->name;
|
||||||
}
|
}
|
||||||
public function setName(string $name): self
|
public function setName(string $name): self
|
||||||
{ $this->name = $name;
|
{ $this->name = $name;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user