diff --git a/TopModel.Generator.Jpa/EndpointGeneration/SpringClientApiGenerator.cs b/TopModel.Generator.Jpa/EndpointGeneration/SpringClientApiGenerator.cs index b9cf0c14..37bf8500 100644 --- a/TopModel.Generator.Jpa/EndpointGeneration/SpringClientApiGenerator.cs +++ b/TopModel.Generator.Jpa/EndpointGeneration/SpringClientApiGenerator.cs @@ -178,7 +178,8 @@ private void WriteEndpoint(JavaWriter fw, Endpoint endpoint, string tag) } } - fw.WriteLine(1, $"{(endpoint.IsMultipart ? " " : string.Empty)}{returnType} {endpoint.NameCamel}({string.Join(", ", methodParams)});"); + fw.AddImport("org.springframework.http.ResponseEntity"); + fw.WriteLine(1, $"{(endpoint.IsMultipart ? " " : string.Empty)}ResponseEntity<{returnType}> {endpoint.NameCamel}({string.Join(", ", methodParams)});"); } private void WriteImports(IEnumerable endpoints, JavaWriter fw, string tag) diff --git a/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java b/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java index 67a2a466..ccfa520f 100644 --- a/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java +++ b/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java @@ -6,6 +6,7 @@ import java.util.List; +import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -33,7 +34,7 @@ public interface ProfilClient { */ @PreAuthorize("hasRole('CREATE')") @PostExchange(value = "/") - ProfilRead addProfil(@RequestBody @Valid ProfilWrite profil); + ResponseEntity addProfil(@RequestBody @Valid ProfilWrite profil); /** * Charge le détail d'un Profil. @@ -42,7 +43,7 @@ public interface ProfilClient { */ @PreAuthorize("hasRole('READ')") @GetExchange(value = "/{proId}") - ProfilRead getProfil(@PathVariable("proId") Integer proId); + ResponseEntity getProfil(@PathVariable("proId") Integer proId); /** * Liste tous les Profils. @@ -50,7 +51,7 @@ public interface ProfilClient { */ @PreAuthorize("hasRole('READ')") @GetExchange(value = "/") - List getProfils(); + ResponseEntity> getProfils(); /** * Sauvegarde un Profil. @@ -60,5 +61,5 @@ public interface ProfilClient { */ @PreAuthorize("hasRole('UPDATE')") @PutExchange(value = "/{proId}") - ProfilRead updateProfil(@PathVariable("proId") Integer proId, @RequestBody @Valid ProfilWrite profil); + ResponseEntity updateProfil(@PathVariable("proId") Integer proId, @RequestBody @Valid ProfilWrite profil); } diff --git a/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java b/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java index d7a3c168..d473acde 100644 --- a/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java +++ b/samples/generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java @@ -7,6 +7,7 @@ import java.time.LocalDate; import java.util.List; +import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -37,7 +38,7 @@ public interface UtilisateurClient { */ @PreAuthorize("hasRole('CREATE')") @PostExchange(value = "/") - UtilisateurRead addUtilisateur(@RequestBody @Valid UtilisateurWrite utilisateur); + ResponseEntity addUtilisateur(@RequestBody @Valid UtilisateurWrite utilisateur); /** * Supprime un utilisateur. @@ -45,7 +46,7 @@ public interface UtilisateurClient { */ @PreAuthorize("hasRole('DELETE')") @DeleteExchange(value = "/{utiId}") - void deleteUtilisateur(@PathVariable("utiId") Integer utiId); + ResponseEntity deleteUtilisateur(@PathVariable("utiId") Integer utiId); /** * Charge le détail d'un utilisateur. @@ -54,7 +55,7 @@ public interface UtilisateurClient { */ @PreAuthorize("hasRole('READ')") @GetExchange(value = "/{utiId}") - UtilisateurRead getUtilisateur(@PathVariable("utiId") Integer utiId); + ResponseEntity getUtilisateur(@PathVariable("utiId") Integer utiId); /** * Recherche des utilisateurs. @@ -70,7 +71,7 @@ public interface UtilisateurClient { */ @PreAuthorize("hasRole('READ')") @GetExchange(value = "/") - List searchUtilisateur(@RequestParam(value = "nom", required = true) String nom, @RequestParam(value = "prenom", required = true) String prenom, @RequestParam(value = "email", required = true) String email, @RequestParam(value = "dateNaissance", required = false) LocalDate dateNaissance, @RequestParam(value = "adresse", required = false) String adresse, @RequestParam(value = "actif", required = true) Boolean actif, @RequestParam(value = "profilId", required = true) Integer profilId, @RequestParam(value = "typeUtilisateurCode", required = true) TypeUtilisateurCode typeUtilisateurCode); + ResponseEntity> searchUtilisateur(@RequestParam(value = "nom", required = true) String nom, @RequestParam(value = "prenom", required = true) String prenom, @RequestParam(value = "email", required = true) String email, @RequestParam(value = "dateNaissance", required = false) LocalDate dateNaissance, @RequestParam(value = "adresse", required = false) String adresse, @RequestParam(value = "actif", required = true) Boolean actif, @RequestParam(value = "profilId", required = true) Integer profilId, @RequestParam(value = "typeUtilisateurCode", required = true) TypeUtilisateurCode typeUtilisateurCode); /** * Sauvegarde un utilisateur. @@ -80,5 +81,5 @@ public interface UtilisateurClient { */ @PreAuthorize("hasRole('UPDATE')") @PutExchange(value = "/{utiId}") - UtilisateurRead updateUtilisateur(@PathVariable("utiId") Integer utiId, @RequestBody @Valid UtilisateurWrite utilisateur); + ResponseEntity updateUtilisateur(@PathVariable("utiId") Integer utiId, @RequestBody @Valid UtilisateurWrite utilisateur); } diff --git a/samples/model/jpa.topmodel.lock b/samples/model/jpa.topmodel.lock index 5a33da4b..da7ebb4f 100644 --- a/samples/model/jpa.topmodel.lock +++ b/samples/model/jpa.topmodel.lock @@ -4,7 +4,7 @@ version: 2.2.1 custom: - ../../../TopModel.Generator.Jpa: 9c152aa27af0b426e7267c2ebe36ef62 + ../../../TopModel.Generator.Jpa: 8f78520bb47d1d3ea1f64a5489e0fb77 generatedFiles: - ../generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/profil/ProfilClient.java - ../generators/jpa/src/main/javagen/topmodel/jpa/sample/demo/api/client/securite/utilisateur/UtilisateurClient.java