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

View File

@@ -42,7 +42,7 @@ public class CategorieRepositoryImpl implements CategorieRepository {
@Override @Override
public Categorie findCategorieById(int id) { 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); Categorie categorie = jdbcTemplate.queryForObject(sql, new CategorieRowMapper(), id);
return categorie; return categorie;
} }

View File

@@ -16,8 +16,7 @@ public class WebSecurityConfig{
@Bean @Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests((requests) -> requests 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("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**", "/i18n/**").permitAll()
.requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated() .requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated()
.requestMatchers("/admin").hasRole("ADMIN") .requestMatchers("/admin").hasRole("ADMIN")

View File

@@ -95,27 +95,29 @@
</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">
<div class="card shadow-sm h-100"> <a th:href="@{/article/show(id=${article.id})}">
<div class="row g-0"> <div class="card shadow-sm h-100">
<div class="col-md-4 d-flex align-items-center justify-content-center p-3"> <div class="row g-0">
<img th:src="${'images/articles/' + article.id + '.jpg'}" alt="Image de l'article" class="img-fluid rounded"> <div class="col-md-4 d-flex align-items-center justify-content-center p-3">
</div> <img th:src="${'images/articles/' + article.id + '.jpg'}" alt="Image de l'article" class="img-fluid rounded">
<div class="col-md-8"> </div>
<div class="card-body d-flex flex-column"> <div class="col-md-8">
<h5 class="card-title" th:text="${article.nom}">Nom de l'article</h5> <div class="card-body d-flex flex-column">
<p class="card-text mb-auto" th:text="${article.desc}">Description</p> <h5 class="card-title" th:text="${article.nom}">Nom de l'article</h5>
<div class="d-flex justify-content-between align-items-center"> <p class="card-text mb-auto" th:text="${article.desc}">Description</p>
<div> <div class="d-flex justify-content-between align-items-center">
<h6>Prix de vente: <span th:text="${article.prixVente}"></span></h6> <div>
<h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></span> </h6> <h6>Prix de vente: <span th:text="${article.prixVente}"></span> </h6>
<h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></span> </h6>
</div>
</div> </div>
<br>
<h6 class="text-muted">Fin de l'enchère: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
</div> </div>
<br>
<h6 class="text-muted">Fin de l'enchère: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
</div> </div>
</div> </div>
</div> </div>
</div> </a>
</div> </div>
</div> </div>
</div> </div>

View File

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

View File

@@ -26,7 +26,7 @@
</div> </div>
<div class="mb-3"> <div class="mb-3">
<button type="submit" class="btn btn-primary">Connexion</button> <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> </div>
</form> </form>
<div th:if="${param.error}" class="text-danger"> <div th:if="${param.error}" class="text-danger">