mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-09-11 16:50:46 +02:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -6,11 +6,12 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use App\Repository\SiteRepository;
|
||||
use App\Repository\RoomRepository;
|
||||
|
||||
class MapApiController extends AbstractController
|
||||
{
|
||||
#[Route('/map/api')]
|
||||
public function index(SiteRepository $srep): JsonResponse
|
||||
public function test(SiteRepository $srep): JsonResponse
|
||||
{
|
||||
|
||||
return $this->json([
|
||||
@@ -19,4 +20,54 @@ class MapApiController extends AbstractController
|
||||
'sites' => $srep->allSites()[0]->getZeroLatitude()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/map/api/get_floor')]
|
||||
public function get_floor(FloorRepository $srep, int $id): JsonResponse
|
||||
{
|
||||
return $rep->get_floor(id);
|
||||
return $this->json([
|
||||
'message' => 'Welcome to your new controller!',
|
||||
'path' => 'src/Controller/MapApiController.php',
|
||||
'sites' => $srep->allSites()[0]->getZeroLatitude()
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/map/api/find_room_by_name')]
|
||||
public function find_room_by_name(RoomRepository $srep, string $name): JsonResponse
|
||||
{
|
||||
$rooms = $rep->findRoomByName($name);
|
||||
if (sizeof($rooms)!=1) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
$room = $rooms[0];
|
||||
$CP = $room->getConnectedPlaces();
|
||||
if (sizeof($CP)==0) return null;
|
||||
$floor = $CP[0]->getFloor();
|
||||
return $this->json([
|
||||
'idRoom' => $room->getId(),
|
||||
'idFloor' => $floor->getId()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[Route('/map/api/show_room_info')]
|
||||
public function index(RoomRepository $srep, int $id): JsonResponse
|
||||
{
|
||||
$rooms = $rep->findRoomById($id);
|
||||
if (sizeof($rooms)!=1) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return $this->json([
|
||||
'idRoom' => $rooms[0]->getId(),
|
||||
'names' => $rooms[0]->getNames(),
|
||||
'users' => $rooms[0]->getUsers()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user