From 1cd2e8d71450b25c3440f2ee5b112dc2558fe5ed Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 28 Feb 2024 12:03:27 +0100 Subject: [PATCH] mise en forme --- .../controller/ArticleControler.java | 133 +++++++++++------- 1 file changed, 86 insertions(+), 47 deletions(-) diff --git a/WebService/src/main/java/SAE/ApiREST/WebService/controller/ArticleControler.java b/WebService/src/main/java/SAE/ApiREST/WebService/controller/ArticleControler.java index 6f524c7..e914def 100644 --- a/WebService/src/main/java/SAE/ApiREST/WebService/controller/ArticleControler.java +++ b/WebService/src/main/java/SAE/ApiREST/WebService/controller/ArticleControler.java @@ -32,10 +32,10 @@ public class ArticleControler { public @ResponseBody EntityModel addArticle( @RequestBody Article article ) { - Response res = articleService.addArticle(article); + Response results = articleService.addArticle(article); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).addArticle(article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -54,10 +54,10 @@ public class ArticleControler { @PathVariable("title") String title, @RequestBody Article article ) { - Article res = articleService.updateTitle(article, title); + Article results = articleService.updateTitle(article, title); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).updateTitle(title, article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -75,10 +75,10 @@ public class ArticleControler { @PathVariable("url") String url, @RequestBody Article article ) { - Article res = articleService.updateUrl(article, url); + Article results = articleService.updateUrl(article, url); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).updateUrl(url, article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -96,10 +96,10 @@ public class ArticleControler { @PathVariable("datePublished") String datePublished, @RequestBody Article article ) { - Article res = articleService.updateDatePublished(article, datePublished); + Article results = articleService.updateDatePublished(article, datePublished); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).updateDatePublished(datePublished, article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -118,10 +118,10 @@ public class ArticleControler { @PathVariable("dateAdded") String dateAdded, @RequestBody Article article ) { - Article res = articleService.updateDateAdded(article, dateAdded); + Article results = articleService.updateDateAdded(article, dateAdded); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).updateDateAdded(dateAdded, article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -139,10 +139,10 @@ public class ArticleControler { public @ResponseBody EntityModel
changeVisibility( @RequestBody Article article ) { - Article res = articleService.changeVisibility(article); + Article results = articleService.changeVisibility(article); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).changeVisibility(article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -161,10 +161,10 @@ public class ArticleControler { @PathVariable("type") Integer type, @RequestBody Article article ) { - Article res = articleService.updateType(article, type); + Article results = articleService.updateType(article, type); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).updateType(type, article)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("allArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(article.getId())).withRel("getArticleById"), @@ -175,7 +175,10 @@ public class ArticleControler { // endregion // region GET - @GetMapping(value = "/getAllArticle", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getAllArticle", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getAllArticles() { ArrayList
results = (ArrayList
) articleService.getAllArticles(); @@ -189,7 +192,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticleById/{id}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticleById/{id}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel
getArticleById(@PathVariable(value = "id") Integer id) { Article results = articleService.getArticlesById(id); @@ -204,7 +210,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesByTitle/{title}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesByTitle/{title}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesByTitle(@PathVariable(value = "title") String title) { ArrayList
results = (ArrayList
) articleService.getArticlesByTitle(title); @@ -219,7 +228,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesByUrl/{url}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesByUrl/{url}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesByUrl(@PathVariable(value = "url") String url) { ArrayList
results = (ArrayList
) articleService.getArticlesByUrl(url); @@ -234,7 +246,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesByType/{type}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesByType/{type}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesByType(@PathVariable(value = "type") Integer type) { ArrayList
results = (ArrayList
) articleService.getArticlesByType(type); @@ -249,7 +264,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getVisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getVisibleArticles", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getVisibleArticles() { ArrayList
results = (ArrayList
) articleService.getVisibleArticles(); @@ -263,7 +281,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getInvisibleArticles", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getInvisibleArticles", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getInvisibleArticles() { ArrayList
results = (ArrayList
) articleService.getInvisibleArticles(); @@ -277,7 +298,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesAddedBefore/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesAddedBefore/{dateAdded}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesAddedBefore(@PathVariable(value = "dateAdded") String dateAdded) { ArrayList
results = (ArrayList
) articleService.getArticlesAddedBefore(dateAdded); @@ -292,7 +316,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesAddedAfter/{dateAdded}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesAddedAfter/{dateAdded}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesAddedAfter(@PathVariable(value = "dateAdded") String dateAdded) { ArrayList
results = (ArrayList
) articleService.getArticlesAddedAfter(dateAdded); @@ -307,7 +334,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesAddedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesAddedBetween/{beginning}/{end}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesAddedBetween(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) { ArrayList
results = (ArrayList
) articleService.getArticlesAddedBetween(beginning, end); @@ -322,7 +352,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesPublishedBefore/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesPublishedBefore/{datePublished}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesPublishedBefore(@PathVariable(value = "datePublished") String datePublished) { ArrayList
results = (ArrayList
) articleService.getArticlesPublishedBefore(datePublished); @@ -337,7 +370,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesPublishedAfter/{datePublished}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesPublishedAfter/{datePublished}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesPublishedAfter(@PathVariable(value = "datePublished") String datePublished) { ArrayList
results = (ArrayList
) articleService.getArticlesPublishedAfter(datePublished); @@ -352,7 +388,10 @@ public class ArticleControler { ); } - @GetMapping(value = "/getArticlesPublishedBetween/{beginning}/{end}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping( + value = "/getArticlesPublishedBetween/{beginning}/{end}", + produces = MediaType.APPLICATION_JSON_VALUE + ) public @ResponseBody EntityModel> getArticlesPublishedBetween(@PathVariable(value = "beginning") String beginning, @PathVariable(value = "end") String end) { ArrayList
results = (ArrayList
) articleService.getArticlesPublishedBetween(beginning, end); @@ -377,10 +416,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticleFromId( @PathVariable("id") Integer id ) { - Response res = articleService.deleteArticleFromId(id); + Response results = articleService.deleteArticleFromId(id); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleFromId(id)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticleById(id)).withRel("getArticleById") @@ -394,10 +433,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticleFromTitle( @PathVariable("title") String title ) { - Response res = articleService.deleteArticleFromTitle(title); + Response results = articleService.deleteArticleFromTitle(title); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleFromTitle(title)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesByTitle(title)).withRel("getArticleByTitle") @@ -411,10 +450,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticleFromUrl( @PathVariable("url") String url ) { - Response res = articleService.deleteArticleFromTitle(url); + Response results = articleService.deleteArticleFromTitle(url); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleFromUrl(url)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesByUrl(url)).withRel("getArticlesByUrl") @@ -428,10 +467,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticleFromType( @PathVariable("type") Integer type ) { - Response res = articleService.deleteArticleFromType(type); + Response results = articleService.deleteArticleFromType(type); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleFromType(type)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesByType(type)).withRel("getArticlesByType") @@ -445,10 +484,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticleAddedBefore( @PathVariable("date") String date ) { - Response res = articleService.deleteArticleAddedBefore(date); + Response results = articleService.deleteArticleAddedBefore(date); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleAddedBefore(date)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesAddedBefore(date)).withRel("getArticlesAddedBefore") @@ -462,10 +501,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticleAddedAfter( @PathVariable("date") String date ) { - Response res = articleService.deleteArticleAddedAfter(date); + Response results = articleService.deleteArticleAddedAfter(date); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleAddedAfter(date)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesAddedAfter(date)).withRel("getArticlesAddedAfter") @@ -480,10 +519,10 @@ public class ArticleControler { @PathVariable("beginning") String beginning, @PathVariable("end") String end ) { - Response res = articleService.deleteArticleAddedBetween(beginning, end); + Response results = articleService.deleteArticleAddedBetween(beginning, end); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticleAddedBetween(beginning, end)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesAddedBetween(beginning, end)).withRel("getArticlesAddedBetween") @@ -497,10 +536,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticlePublishedBefore( @PathVariable("date") String date ) { - Response res = articleService.deleteArticlePublishedBefore(date); + Response results = articleService.deleteArticlePublishedBefore(date); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticlePublishedBefore(date)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesPublishedBefore(date)).withRel("getArticlesPublishedBefore") @@ -514,10 +553,10 @@ public class ArticleControler { public @ResponseBody EntityModel deleteArticlePublishedAfter( @PathVariable("date") String date ) { - Response res = articleService.deleteArticlePublishedBefore(date); + Response results = articleService.deleteArticlePublishedBefore(date); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticlePublishedAfter(date)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesPublishedAfter(date)).withRel("getArticlesPublishedAfter") @@ -532,10 +571,10 @@ public class ArticleControler { @PathVariable("beginning") String beginning, @PathVariable("end") String end ) { - Response res = articleService.deleteArticlePublishedBetween(beginning, end); + Response results = articleService.deleteArticlePublishedBetween(beginning, end); return EntityModel.of( - res, + results, linkTo(methodOn(ArticleControler.class).deleteArticlePublishedBetween(beginning, end)).withSelfRel(), linkTo(methodOn(ArticleControler.class).getAllArticles()).withRel("getAllArticles"), linkTo(methodOn(ArticleControler.class).getArticlesPublishedBetween(beginning, end)).withRel("getArticlesPublishedBetween")