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
|
||||
{
|
||||
'idSite' : int, //id of the Site
|
||||
'nameSite' : string, //name of the Site
|
||||
'idBuilding': int, //id of the Building
|
||||
'nameBuilding': string, //name of the Building
|
||||
'places : [
|
||||
{
|
||||
'id': int, //unique id
|
||||
'names' : string[], //Names of the place, possibly empty,
|
||||
'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
|
||||
'connectedFloors' : [
|
||||
{
|
||||
'id' : int,
|
||||
'name' : string
|
||||
},
|
||||
{...}
|
||||
]
|
||||
},
|
||||
{...}
|
||||
]
|
||||
@ -83,22 +92,31 @@ __The json will look like :__
|
||||
---------------------
|
||||
|
||||
### /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 :__
|
||||
```json
|
||||
[
|
||||
{
|
||||
'idPlace':int, //unique id of the place
|
||||
'namePlace':string[], //list of Names of the place
|
||||
'idSite': int, //id of the place Site
|
||||
'idBuilding': int, //id of the place Building
|
||||
'idFloors': int[] //list of every floorID the place is in
|
||||
'nameSite' : string, //name of the Site
|
||||
'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 :__
|
||||
- If _NAME_ doesn't correspond to any registered place : Return Error 404 "NotFoundHttpError".
|
||||
__Notes :__
|
||||
- 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.
|
||||
|
||||
@ -141,7 +159,8 @@ __Format of the dict :__
|
||||
{
|
||||
'idPlace': int,
|
||||
'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 :__
|
||||
@ -157,14 +176,17 @@ __Each edition is a dict :__
|
||||
```json
|
||||
{
|
||||
'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
|
||||
'placeId': string, // id of the place
|
||||
'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
|
||||
|
||||
@ -94,22 +94,12 @@ class MapApiController extends AbstractController
|
||||
$jsonPlaces = array();
|
||||
if ($representation == 'Cylinder' || $representation == 'PolySurface'){
|
||||
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(
|
||||
'id' => $place->getId(),
|
||||
'names' => $place->getJoinedNames(),
|
||||
'type' => $place->getType(),
|
||||
'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");
|
||||
}
|
||||
$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(),
|
||||
'nameBuilding' => $building->getName(),
|
||||
'places' => $jsonPlaces
|
||||
]);
|
||||
}
|
||||
@ -145,29 +139,29 @@ class MapApiController extends AbstractController
|
||||
#[Route('/api/map/find_place_by_name/{name}')]
|
||||
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
|
||||
{
|
||||
$places = $rep->findPlaceByName($name);
|
||||
if (sizeof($places)==0){ throw new NotFoundHttpException('Error: \''.$name.'\' doesn\'t correspond to any placeName.'); }
|
||||
else {
|
||||
$all = array();
|
||||
foreach ($places as $place){
|
||||
$floorsId = array();
|
||||
foreach ($place->getFloors() as $floor) {
|
||||
$floorsId[] = $floor->getId();
|
||||
}
|
||||
$building = $place->getFloors()[0]->getBuilding();
|
||||
$all[] = array('idRoom' => $place->getId(),
|
||||
'idSite' => $building->getSite()->getId(),
|
||||
'idBuilding' => $building->getId(),
|
||||
'idFloors' => $floorsId
|
||||
);
|
||||
$result = array();
|
||||
foreach ($rep->findPlaceByName($name) as $place){
|
||||
$floors = array();
|
||||
foreach ($place->getFloors() as $floor) {
|
||||
$floors[] = $floor->getId();
|
||||
}
|
||||
return $this->json($all);
|
||||
$building = $place->getFloors()[0]->getBuilding();
|
||||
$result[] = array(
|
||||
'idPlace' => $place->getId(),
|
||||
'namePlace' => $place->getJoinedNames(),
|
||||
'idSite' => $building->getSite()->getId(),
|
||||
'nameSite' => $building->getSite()->getName(),
|
||||
'idBuilding' => $building->getId(),
|
||||
'nameBuilding' => $building->getName(),
|
||||
'floors' => $place->getFloorsNameAndId()
|
||||
);
|
||||
}
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
|
||||
#[Route('/api/map/show_place_info/{id}')]
|
||||
public function show_place_info(PlaceRepository $rep, int $id): JsonResponse
|
||||
#[Route('/api/map/get_place_info/{id}')]
|
||||
public function get_place_info(PlaceRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$places = $rep->findPlaceById($id);
|
||||
if (sizeof($places) == 0) { throw new NotFoundHttpException('Error: '.$id.' doesn\'t correspond to any place.'); }
|
||||
@ -185,19 +179,15 @@ class MapApiController extends AbstractController
|
||||
#[Route('/api/map/get_all_editions')]
|
||||
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();
|
||||
foreach ($edits as $edit){
|
||||
$listEdits[] = array(
|
||||
'id' => $edit->getId(),
|
||||
'mode' => $edit->getMode(),
|
||||
'placeNames' => $edit->getEditedPlace()->getJoinedNames(),
|
||||
'placeId' => $edit->getEditedPlace()->getId(),
|
||||
'editorValue' => $edit->getValue()
|
||||
);
|
||||
}
|
||||
$listEdits = array();
|
||||
foreach ($rep->getAllEditions() as $edit){
|
||||
$listEdits[] = array(
|
||||
'id' => $edit->getId(),
|
||||
'mode' => $edit->getMode(),
|
||||
'placeNames' => $edit->getEditedPlace()->getJoinedNames(),
|
||||
'placeId' => $edit->getEditedPlace()->getId(),
|
||||
'editorValue' => $edit->getValue()
|
||||
);
|
||||
}
|
||||
return $this->json($listEdits);
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ class Building
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{ return $this->id;
|
||||
{ return $this->name;
|
||||
}
|
||||
public function setName(string $name): self
|
||||
{ $this->name = $name;
|
||||
|
||||
@ -39,7 +39,7 @@ class Floor
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{ return $this->id;
|
||||
{ return $this->name;
|
||||
}
|
||||
public function setName(string $name): self
|
||||
{ $this->name = $name;
|
||||
|
||||
@ -169,6 +169,14 @@ class Place
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@ class Site
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{ return $this->id;
|
||||
{ return $this->name;
|
||||
}
|
||||
public function setName(string $name): self
|
||||
{ $this->name = $name;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user