This commit is contained in:
Parpaillax
2024-04-25 10:45:02 +02:00
parent eaa5a41b88
commit 7fc748caf3
6 changed files with 34 additions and 26 deletions

View File

@@ -5,6 +5,7 @@ import fr.eni.enchere.bll.CategorieService;
import fr.eni.enchere.bll.RetraitService;
import fr.eni.enchere.bll.UserService;
import fr.eni.enchere.bo.Article;
import fr.eni.enchere.bo.Categorie;
import fr.eni.enchere.bo.Retrait;
import fr.eni.enchere.bo.UserProfil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,10 +50,10 @@ public class ArticleController {
if (!authentication.getName().equals("anonymousUser")) {
Article article = articleService.findArticleById(id);
UserProfil user = userService.utilisateurById(article.getUtilisateur());
System.out.println(article);
System.out.println(user);
Categorie cate = categorieService.findCategorieById(article.getNumCategorie());
model.addAttribute("article", article);
model.addAttribute("user", user);
model.addAttribute("username", user.getPseudo());
model.addAttribute("cate", cate.getLibelle());
return "article";
} else {
return "redirect:/accueil";

View File

@@ -42,7 +42,7 @@ public class CategorieRepositoryImpl implements CategorieRepository {
@Override
public Categorie findCategorieById(int id) {
String sql = "SELECT * FROM CATEGORIES WHERE no_categorie = :id";
String sql = "SELECT * FROM CATEGORIES WHERE no_categorie = ?";
Categorie categorie = jdbcTemplate.queryForObject(sql, new CategorieRowMapper(), id);
return categorie;
}

View File

@@ -16,8 +16,7 @@ public class WebSecurityConfig{
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((requests) -> requests
.requestMatchers("/", "/accueil").permitAll()
.requestMatchers("/accueil", "/login", "/inscription/**", "/searchArticle", "/article/show", "/change-language").permitAll()
.requestMatchers("/","/accueil", "/login", "/inscription/**", "/searchArticle", "/article/show", "/change-language").permitAll()
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**", "/i18n/**").permitAll()
.requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated()
.requestMatchers("/admin").hasRole("ADMIN")

View File

@@ -95,6 +95,7 @@
</div>
<div class="row">
<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="row g-0">
<div class="col-md-4 d-flex align-items-center justify-content-center p-3">
@@ -116,6 +117,7 @@
</div>
</div>
</div>
</a>
</div>
</div>
</div>

View File

@@ -16,9 +16,15 @@
<li class="list-group-item">
<strong><label class="col-form-label" th:text="${article.nom}"></label></strong>
</li>
<!-- <li class="list-group-item">-->
<!-- <strong><label class="col-form-label" th:text="${user.pseudo}"></label></strong>-->
<!-- </li>-->
<li class="list-group-item">
<strong><label class="col-form-label" th:text="${article.desc}"></label></strong>
</li>
<li class="list-group-item">
<strong><label class="col-form-label" th:text="${username}"></label></strong>
</li>
<li class="list-group-item">
<strong><label class="col-form-label" th:text="${cate}"></label></strong>
</li>
</ul>
</div>
</div>

View File

@@ -26,7 +26,7 @@
</div>
<div class="mb-3">
<button type="submit" class="btn btn-primary">Connexion</button>
<button type="button" class="btn btn-warning text-light" href="/inscription">Créer un compte </button>
<button type="button" class="btn btn-warning text-light" href="../inscription">Créer un compte </button>
</div>
</form>
<div th:if="${param.error}" class="text-danger">