Merge branch 'Olivier'

This commit is contained in:
Parpaillax
2024-04-25 10:45:30 +02:00
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,27 +95,29 @@
</div>
<div class="row">
<div th:each="article : ${articles}" class="col-md-6 mb-4">
<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">
<img th:src="${'images/articles/' + article.id + '.jpg'}" alt="Image de l'article" class="img-fluid rounded">
</div>
<div class="col-md-8">
<div class="card-body d-flex flex-column">
<h5 class="card-title" th:text="${article.nom}">Nom de l'article</h5>
<p class="card-text mb-auto" th:text="${article.desc}">Description</p>
<div class="d-flex justify-content-between align-items-center">
<div>
<h6>Prix de vente: <span th:text="${article.prixVente}"></span></h6>
<h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></span> </h6>
<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">
<img th:src="${'images/articles/' + article.id + '.jpg'}" alt="Image de l'article" class="img-fluid rounded">
</div>
<div class="col-md-8">
<div class="card-body d-flex flex-column">
<h5 class="card-title" th:text="${article.nom}">Nom de l'article</h5>
<p class="card-text mb-auto" th:text="${article.desc}">Description</p>
<div class="d-flex justify-content-between align-items-center">
<div>
<h6>Prix de vente: <span th:text="${article.prixVente}"></span> </h6>
<h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></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>
<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>
</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">