mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
Add B and S name for get_floor and return empty list if find_place_by_name doesn't find anything
This commit is contained in:
parent
33d15d4400
commit
33677c9232
17
API.md
17
API.md
@ -19,7 +19,9 @@ __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
|
||||||
@ -90,7 +92,7 @@ __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
|
||||||
@ -104,8 +106,8 @@ __Format of the dict :__
|
|||||||
{...}
|
{...}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
__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.
|
||||||
|
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
@ -148,7 +150,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 :__
|
||||||
@ -164,7 +167,7 @@ __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
|
||||||
@ -172,6 +175,10 @@ __Each edition is a dict :__
|
|||||||
```
|
```
|
||||||
__Errors :__
|
__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)
|
- 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 :__
|
||||||
|
- 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
|
||||||
|
|||||||
@ -113,8 +113,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
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -141,24 +145,21 @@ 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 {
|
$floorsId = array();
|
||||||
$all = array();
|
foreach ($place->getFloors() as $floor) {
|
||||||
foreach ($places as $place){
|
$floorsId[] = $floor->getId();
|
||||||
$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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $this->json($all);
|
$building = $place->getFloors()[0]->getBuilding();
|
||||||
|
$result[] = array(
|
||||||
|
'idRoom' => $place->getId(),
|
||||||
|
'idSite' => $building->getSite()->getId(),
|
||||||
|
'idBuilding' => $building->getId(),
|
||||||
|
'idFloors' => $floorsId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
return $this->json($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user