From ac30d228cacc5c4bc7b280bbd55a5f1394c13e52 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 1 Apr 2025 22:01:10 +0100 Subject: [PATCH] =?UTF-8?q?ca=20court=20carr=C3=A9ment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wfwebapi/controller/ImageController.java | 7 +++++ src/main/resources/application.properties | 26 +------------------ 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/example/wfwebapi/controller/ImageController.java b/src/main/java/com/example/wfwebapi/controller/ImageController.java index 3a83838..e694de6 100644 --- a/src/main/java/com/example/wfwebapi/controller/ImageController.java +++ b/src/main/java/com/example/wfwebapi/controller/ImageController.java @@ -6,6 +6,8 @@ import com.example.wfwebapi.repository.ImageRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; + @RestController @RequestMapping("/api/v1/image") public class ImageController { @@ -19,6 +21,11 @@ public class ImageController { .orElseThrow(() -> new ResourceNotFoundException("Image non trouvée : " + id)); } + @GetMapping("/all") + public List getAllImages() { + return imageRepository.findAll(); + } + @PostMapping public Image createImage(@RequestBody Image image) { return imageRepository.save(image); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index e08706e..9cf39d8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,25 +1 @@ -# Configuration de la base de données H2 (en mémoire) -spring.datasource.url=jdbc:h2:mem:testdb -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.username=sa -spring.datasource.password= - -# Initialisation de la BDD avec le script -spring.sql.init.mode=always -spring.sql.init.schema-locations=classpath:init.sql - -# Configuration de JPA/Hibernate -spring.jpa.hibernate.ddl-auto=none -spring.jpa.show-sql=true -spring.jpa.properties.hibernate.format_sql=true - -# Console H2 pour le débogage -spring.h2.console.enabled=true -spring.h2.console.path=/h2-console - -# Port du serveur (filtré via Maven) -server.port=@server.port@ - -# (Optionnel) Niveaux de log pour SQL -logging.level.org.hibernate.SQL=DEBUG -logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE +spring.application.name=WF-WEB-API \ No newline at end of file