Merge branch 'main' into Johan
This commit is contained in:
@@ -44,9 +44,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) {
|
||||||
Article article = articleService.findArticleById(id);
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
return "article";
|
if (!authentication.getName().equals("anonymousUser")) {
|
||||||
|
Article article = articleService.findArticleById(id);
|
||||||
|
System.out.println(article);
|
||||||
|
model.addAttribute("article", article);
|
||||||
|
return "article";
|
||||||
|
} else {
|
||||||
|
return "redirect:/accueil";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/{slug}")
|
@GetMapping("/{slug}")
|
||||||
|
|||||||
@@ -91,7 +91,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());
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -17,41 +17,64 @@
|
|||||||
<input type="text" class="form-control" th:attr="placeholder=#{home.search.title}" name="searchTitle">
|
<input type="text" class="form-control" th:attr="placeholder=#{home.search.title}" name="searchTitle">
|
||||||
<select class="form-control mt-2" name="searchCategory">
|
<select class="form-control mt-2" name="searchCategory">
|
||||||
<option value="" th:text="#{home.search.cat}"></option>
|
<option value="" th:text="#{home.search.cat}"></option>
|
||||||
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}"></option>
|
<!-- Options de catégorie -->
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4 text-center">
|
<div class="col-md-4 text-center">
|
||||||
<button type="submit" class="btn btn-primary" th:text="#{home.search.button}">Search</button>
|
<button type="submit" class="btn btn-primary" th:text="#{home.search.button}">Search</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="card mt-3">
|
||||||
|
<div class="card-body">
|
||||||
|
<form class="row">
|
||||||
|
<div class="col-6">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="transactionType" id="achats" value="achats">
|
||||||
|
<label class="form-check-label" type="chec" >Achats</label>
|
||||||
|
</div>
|
||||||
|
</div><div class="col-6">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="transactionType" id="ventes" value="ventes">
|
||||||
|
<label class="form-check-label" for="ventes">Mes ventes</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>Prix de vente: <span th:text="${article.prixVente}"></span> €</h6>
|
||||||
|
|
||||||
<h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></span> </h6>
|
<h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></span> </h6>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</br>
|
||||||
|
<h6 class="text-muted">Fin de l'enchere: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
|
||||||
</div>
|
</div>
|
||||||
</br>
|
|
||||||
<h6 class="text-muted">Fin de l'enchere: <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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -3,30 +3,40 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container-main">
|
<div class="container" id="container-main">
|
||||||
<h2>Pour se Connecter :</h2>
|
<div class="row justify-content-center mt-5">
|
||||||
<br>
|
<div class="col-md-6">
|
||||||
|
<h2 class="text-center mb-4">Pour se Connecter :</h2>
|
||||||
<form th:action="@{/login}" method="post">
|
<form th:action="@{/login}" method="post">
|
||||||
<div>
|
<div class="mb-3">
|
||||||
<label for="username">Identifiant: </label>
|
<label for="username" class="form-label">Identifiant:</label>
|
||||||
<input type="username" name="username" id="username"/>
|
<input type="text" class="form-control" name="username" id="username" placeholder="Entrez votre identifiant">
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="mb-3">
|
||||||
<label for="password">Mot de passe:</label>
|
<label for="password" class="form-label">Mot de passe:</label>
|
||||||
<input type="password" name="password" id="password"/>
|
<input type="password" class="form-control" name="password" id="password" placeholder="Entrez votre mot de passe">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" id="remember-me" name="remember-me">
|
||||||
|
<label class="form-check-label" for="remember-me">Se souvenir de moi</label>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<a href="/mot-de-passe-oublie">Mot de passe oublié</a>
|
||||||
|
</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>
|
||||||
</div>
|
</div>
|
||||||
<div><input type="checkbox" id="remember-me" name="remember-me"/><label for="remember-me"> Se souvenir de moi</label></div>
|
|
||||||
<div><a href="/mot-de-passe-oublie">Mot de passe oublié</a></div>
|
|
||||||
<div><input type="submit" value="Connexion"/></div>
|
|
||||||
</form>
|
</form>
|
||||||
<div th:if="${param.error}">
|
<div th:if="${param.error}" class="text-danger">
|
||||||
Identifiant ou mot de passe incorrect
|
Identifiant ou mot de passe incorrect
|
||||||
</div>
|
</div>
|
||||||
<div th:if="${param.logout}">
|
<div th:if="${param.logout}" class="text-success">
|
||||||
Vous avez été déconnecté
|
Vous avez été déconnecté
|
||||||
</div>
|
</div>
|
||||||
<div><a href="/inscription">Créer un compte</a></div>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user