aled
This commit is contained in:
@@ -43,9 +43,16 @@ public class ArticleController {
|
|||||||
//Affichage d'un article
|
//Affichage d'un article
|
||||||
|
|
||||||
@GetMapping("/show")
|
@GetMapping("/show")
|
||||||
public String showArticle(@RequestParam(name = "slug")int id, Model model) {
|
public String showArticle(@RequestParam()int id, Model model) {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if (!authentication.getName().equals("anonymousUser")) {
|
||||||
Article article = articleService.findArticleById(id);
|
Article article = articleService.findArticleById(id);
|
||||||
|
System.out.println(article);
|
||||||
|
model.addAttribute("article", article);
|
||||||
return "article";
|
return "article";
|
||||||
|
} else {
|
||||||
|
return "redirect:/accueil";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{slug}")
|
@GetMapping("/{slug}")
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Article findArticleById(int id) {
|
public Article findArticleById(int id) {
|
||||||
return null;
|
String sql = "SELECT * FROM ARTICLES_VENDUS a WHERE no_article = ?";
|
||||||
|
Article article = jdbcTemplate.queryForObject(sql, new ArticleRowMapper(), id);
|
||||||
|
return article;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ public class UserInterceptor implements HandlerInterceptor {
|
|||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
if (authentication != null && authentication.isAuthenticated() && !authentication.getName().equals("anonymousUser")) {
|
if (authentication != null && authentication.isAuthenticated() && !authentication.getName().equals("anonymousUser")) {
|
||||||
UserProfil user = this.userService.utilisateurByName(authentication.getName());
|
UserProfil user = this.userService.utilisateurByName(authentication.getName());
|
||||||
modelAndView.getModelMap().addAttribute("user", user.getCredit());
|
if (modelAndView != null && modelAndView.getViewName() != null && !modelAndView.getViewName().startsWith("redirect:")) {
|
||||||
|
modelAndView.addObject("user", user.getCredit());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
//package fr.eni.enchere.interceptor;
|
|
||||||
//
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
||||||
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
//
|
|
||||||
//public class UserServiceInterceptorAppConfig implements WebMvcConfigurer {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void addInterceptors(InterceptorRegistry registry) {
|
|
||||||
// registry.addInterceptor(new UserInterceptor());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -30,6 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div th:each="article : ${articles}" class="col-md-6 mb-4">
|
<div th:each="article : ${articles}" class="col-md-6 mb-4">
|
||||||
|
<a th:href="@{/article/show(id=${article.id})}">
|
||||||
<div class="card shadow-sm h-100">
|
<div class="card shadow-sm h-100">
|
||||||
<div class="row g-0">
|
<div class="row g-0">
|
||||||
<div class="col-md-4 d-flex align-items-center justify-content-center p-3">
|
<div class="col-md-4 d-flex align-items-center justify-content-center p-3">
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,7 +5,22 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container-main">
|
<div id="container-main">
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-md-6 offset-md-3">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h4>Article</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<strong><label class="col-form-label" th:text="${article}"></label></strong>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user