Sync: code local unifié
Synchronisation du code source local (fait foi). Signed-off-by: lions dev Team
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
package dev.lions.unionflow.server.resource;
|
||||
|
||||
import dev.lions.unionflow.server.api.dto.system.request.UpdateSystemConfigRequest;
|
||||
import dev.lions.unionflow.server.api.dto.system.response.CacheStatsResponse;
|
||||
import dev.lions.unionflow.server.api.dto.system.response.SystemConfigResponse;
|
||||
import dev.lions.unionflow.server.api.dto.system.response.SystemMetricsResponse;
|
||||
import dev.lions.unionflow.server.api.dto.system.response.SystemTestResultResponse;
|
||||
import dev.lions.unionflow.server.service.SystemConfigService;
|
||||
import dev.lions.unionflow.server.service.SystemMetricsService;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.ws.rs.*;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.microprofile.openapi.annotations.Operation;
|
||||
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* REST Resource pour la gestion de la configuration système
|
||||
*/
|
||||
@Slf4j
|
||||
@Path("/api/system")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Tag(name = "Système", description = "Gestion de la configuration système")
|
||||
public class SystemResource {
|
||||
|
||||
@Inject
|
||||
SystemConfigService systemConfigService;
|
||||
|
||||
@Inject
|
||||
SystemMetricsService systemMetricsService;
|
||||
|
||||
/**
|
||||
* Récupérer la configuration système
|
||||
*/
|
||||
@GET
|
||||
@Path("/config")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN", "MODERATOR"})
|
||||
@Operation(summary = "Récupérer la configuration système", description = "Retourne la configuration système complète")
|
||||
public SystemConfigResponse getSystemConfig() {
|
||||
log.info("GET /api/system/config");
|
||||
return systemConfigService.getSystemConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mettre à jour la configuration système
|
||||
*/
|
||||
@PUT
|
||||
@Path("/config")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN"})
|
||||
@Operation(summary = "Mettre à jour la configuration système")
|
||||
public SystemConfigResponse updateSystemConfig(@Valid UpdateSystemConfigRequest request) {
|
||||
log.info("PUT /api/system/config");
|
||||
return systemConfigService.updateSystemConfig(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupérer les statistiques du cache
|
||||
*/
|
||||
@GET
|
||||
@Path("/cache/stats")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN", "MODERATOR"})
|
||||
@Operation(summary = "Récupérer les statistiques du cache système")
|
||||
public CacheStatsResponse getCacheStats() {
|
||||
log.info("GET /api/system/cache/stats");
|
||||
return systemConfigService.getCacheStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vider le cache système
|
||||
*/
|
||||
@POST
|
||||
@Path("/cache/clear")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN"})
|
||||
@Operation(summary = "Vider le cache système")
|
||||
public Response clearCache() {
|
||||
log.info("POST /api/system/cache/clear");
|
||||
systemConfigService.clearCache();
|
||||
return Response.ok().entity(java.util.Map.of("message", "Cache vidé avec succès")).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tester la connexion à la base de données
|
||||
*/
|
||||
@POST
|
||||
@Path("/test/database")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN"})
|
||||
@Operation(summary = "Tester la connexion à la base de données")
|
||||
public SystemTestResultResponse testDatabaseConnection() {
|
||||
log.info("POST /api/system/test/database");
|
||||
return systemConfigService.testDatabaseConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tester la configuration email
|
||||
*/
|
||||
@POST
|
||||
@Path("/test/email")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN"})
|
||||
@Operation(summary = "Tester la configuration email")
|
||||
public SystemTestResultResponse testEmailConfiguration() {
|
||||
log.info("POST /api/system/test/email");
|
||||
return systemConfigService.testEmailConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupérer les métriques système en temps réel
|
||||
*/
|
||||
@GET
|
||||
@Path("/metrics")
|
||||
@RolesAllowed({"SUPER_ADMIN", "ADMIN", "MODERATOR"})
|
||||
@Operation(
|
||||
summary = "Récupérer les métriques système en temps réel",
|
||||
description = "Retourne toutes les métriques système (CPU, RAM, disque, utilisateurs actifs, etc.)"
|
||||
)
|
||||
public SystemMetricsResponse getSystemMetrics() {
|
||||
log.info("GET /api/system/metrics");
|
||||
return systemMetricsService.getSystemMetrics();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user