42 lines
1.1 KiB
Java
42 lines
1.1 KiB
Java
package fr.la_banquise.backend.rest;
|
|
|
|
import fr.la_banquise.backend.rest.response.DashboardResponse;
|
|
import fr.la_banquise.backend.services.InstanceService;
|
|
import fr.la_banquise.backend.services.SujetService;
|
|
import io.quarkus.security.identity.SecurityIdentity;
|
|
import jakarta.inject.Inject;
|
|
import jakarta.ws.rs.GET;
|
|
import jakarta.ws.rs.Path;
|
|
import jakarta.ws.rs.core.Response;
|
|
|
|
/**
|
|
* Endpoints
|
|
*/
|
|
@Path("api")
|
|
public class Endpoints {
|
|
|
|
@Inject
|
|
SecurityIdentity identity;
|
|
|
|
@Inject
|
|
InstanceService instanceService;
|
|
|
|
@Inject
|
|
SujetService sujetService;
|
|
|
|
@GET
|
|
@Path("dashboard")
|
|
public Response getDashboard() {
|
|
String username = identity.getPrincipal().getName();
|
|
DashboardResponse dashboard = new DashboardResponse();
|
|
if (identity.getRoles().contains("root")) {
|
|
dashboard.tps = sujetService.getAllSujetsAdmin();
|
|
} else {
|
|
|
|
dashboard.tps = sujetService.getAllSujetsRespo(identity.getPrincipal().getName());
|
|
}
|
|
dashboard.instances = instanceService.getAllInstances(username);
|
|
return Response.ok(dashboard).build();
|
|
}
|
|
}
|