mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-09-11 16:50:46 +02:00
Add Editions
This commit is contained in:
@@ -10,7 +10,7 @@ use App\Repository\RoomRepository;
|
||||
|
||||
class MapApiController extends AbstractController
|
||||
{
|
||||
#[Route('/map/api')]
|
||||
#[Route('/map/api/test')]
|
||||
public function test(SiteRepository $rep): JsonResponse
|
||||
{
|
||||
|
||||
@@ -38,98 +38,115 @@ class MapApiController extends AbstractController
|
||||
return $jsonPlaces;
|
||||
}
|
||||
|
||||
#[Route('/map/api/find_room_by_name')]
|
||||
public function find_room_by_name(RoomRepository $rep, string $name): JsonResponse
|
||||
#[Route('/map/api/find_place_by_name')]
|
||||
public function find_place_by_name(PlaceRepository $rep, string $name): JsonResponse
|
||||
{
|
||||
$rooms = $rep->findRoomByName($name);
|
||||
if (sizeof($rooms)!=1) {
|
||||
$places = $rep->findPlaceByName($name);
|
||||
if (sizeof($places)!=1) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$room = $rooms[0];
|
||||
$CP = $room->getConnectedPlaces();
|
||||
if (sizeof($CP)==0) return null;
|
||||
$floor = $CP[0]->getFloor();
|
||||
$place = $places[0];
|
||||
return $this->json([
|
||||
'idRoom' => $room->getId(),
|
||||
'idFloor' => $floor->getId()
|
||||
'idRoom' => $place->getId(),
|
||||
'idFloor' => $place->getFloor()->getId()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[Route('/map/api/show_room_info')]
|
||||
public function index(RoomRepository $rep, int $id): JsonResponse
|
||||
#[Route('/map/api/show_place_info')]
|
||||
public function index(PlaceRepository $rep, int $id): JsonResponse
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) {
|
||||
$places = $rep->findPlaceById($id);
|
||||
if (sizeof($places)!=1) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return $this->json([
|
||||
'idRoom' => $rooms[0]->getId(),
|
||||
'names' => $rooms[0]->getName(),
|
||||
'users' => $rooms[0]->getUser()
|
||||
'idRoom' => $places[0]->getId(),
|
||||
'names' => $places[0]->getName(),
|
||||
'users' => $places[0]->getUser()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// #[Route('/map/api/get_all_propal_edit')]
|
||||
// public function index(EditRepository $rep): JsonResponse
|
||||
// {
|
||||
// $edits = $rep->getAllEdit($id);
|
||||
// if (sizeof($rooms)<1) {
|
||||
// return null;
|
||||
// }
|
||||
// else {
|
||||
// $listEdits = []
|
||||
// for i
|
||||
// return $this->json([
|
||||
// 'idRoom' => $rooms[0]->getId(),
|
||||
// 'names' => $rooms[0]->getName(),
|
||||
// 'users' => $rooms[0]->getUser()
|
||||
// ]);
|
||||
// }
|
||||
// }
|
||||
#[Route('/map/api/get_all_editions')]
|
||||
public function getEditions(EditionRepository $rep): JsonResponse
|
||||
{
|
||||
$edits = $rep->getAllEditions();
|
||||
if (sizeof($edits)<1) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
$listEdits = new ArrayCollection();
|
||||
foreach ($edits as $edit){
|
||||
$listEdits[] = $this->json([
|
||||
'id' => $edit->getId(),
|
||||
'mode' => $edit->getMode(),
|
||||
'name' => $edit->getNamePlace(),
|
||||
'idPlace' => $edit->getIdPlace(),
|
||||
'value' => $edit->getValue()
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
return $listEdits;
|
||||
}
|
||||
|
||||
#[Route('/map/api/set_edition')]
|
||||
public function setEdition(PlaceRepository $rep, string $mode, int $idPlace, string $value): bool
|
||||
{
|
||||
$edit = new Edition();
|
||||
return $edit->setEdition($rep, $mode, $idPlace, $value);
|
||||
}
|
||||
|
||||
#[Route('/map/api/del_room_name')]
|
||||
public function delRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
#[Route('/map/api/remove_edition')]
|
||||
public function removeEdition(EditionRepository $rep, int $id): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
$edit = $rep->findEditionById($id);
|
||||
if ($edit == null) {return false;}
|
||||
$rep->remove($edit);
|
||||
return true;
|
||||
}
|
||||
|
||||
#[Route('/map/api/del_place_name')]
|
||||
public function delPlaceName(PlaceRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$places = $rep->findPlaceById($id);
|
||||
if (sizeof($places)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->removeName($value);
|
||||
$places[0]->removeName($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#[Route('/map/api/add_room_name')]
|
||||
public function addRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
#[Route('/map/api/add_place_name')]
|
||||
public function addPlaceName(PlaceRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
$places = $rep->findPlaceById($id);
|
||||
if (sizeof($places)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->addName($value);
|
||||
$places[0]->addName($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#[Route('/map/api/del_prof_room_name')]
|
||||
public function delProfRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
#[Route('/map/api/del_room_user_name')]
|
||||
public function delRoomUserName(PlaceRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
$rooms = $rep->findPlaceById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->delUser($value);
|
||||
$rooms[0]->removeRoomUser($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#[Route('/map/api/add_prof_room_name')]
|
||||
public function addProfRoomName(RoomRepository $rep, int $id, string $value): bool
|
||||
#[Route('/map/api/add_room_user_name')]
|
||||
public function addRoomUserName(PlaceRepository $rep, int $id, string $value): bool
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
$rooms = $rep->findPlaceById($id);
|
||||
if (sizeof($rooms)!=1) { return null; }
|
||||
else {
|
||||
$rooms[0]->addUser($value);
|
||||
$rooms[0]->addRoomUser($value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user