diff --git a/src/main/java/fr/eni/enchere/controllers/ArticleController.java b/src/main/java/fr/eni/enchere/controllers/ArticleController.java index 6b9ef13..0e2b5d3 100644 --- a/src/main/java/fr/eni/enchere/controllers/ArticleController.java +++ b/src/main/java/fr/eni/enchere/controllers/ArticleController.java @@ -1,6 +1,7 @@ package fr.eni.enchere.controllers; import fr.eni.enchere.bll.ArticleService; +import fr.eni.enchere.bll.CategorieService; import fr.eni.enchere.bll.UserService; import fr.eni.enchere.bo.Article; import org.springframework.stereotype.Controller; @@ -13,10 +14,12 @@ public class ArticleController { private final ArticleService articleService; private final UserService userService; + private CategorieService categorieService; - public ArticleController(ArticleService articleService, UserService userService) { + public ArticleController(ArticleService articleService, UserService userService, CategorieService categorieService) { this.articleService = articleService; this.userService = userService; + this.categorieService = categorieService; } @GetMapping @@ -24,7 +27,8 @@ public class ArticleController { return "accueil"; } - @GetMapping("/article") + //Affichage d'un article + @GetMapping("/show") public String showArticle(@RequestParam(name = "slug")int id, Model model) { Article article = articleService.findArticleById(id); return "article"; @@ -39,14 +43,14 @@ public class ArticleController { @GetMapping("/new") public String test(@PathVariable(name = "slug")int id, Model model) { - - return "article"; + model.addAttribute("categories", categorieService.findAllCategories()); + return "newArticle"; } @PostMapping("/new/add") public String newArticle(@ModelAttribute("article") Article article) { articleService.saveArticle(article); - return "redirect:/article"; + return "redirect:/accueil"; } @PostMapping("/update") diff --git a/src/main/resources/templates/newArticle.html b/src/main/resources/templates/newArticle.html index 3b51fbd..50c3ea8 100644 --- a/src/main/resources/templates/newArticle.html +++ b/src/main/resources/templates/newArticle.html @@ -5,7 +5,77 @@
+

Nouvelle vente

+
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +

Retrait

+
+ + +
+
+ + +
+
+ + +
+ + +
+ +
+
+
+ +