Merge branch 'refs/heads/marvin'
This commit is contained in:
@@ -11,4 +11,5 @@ public interface ArticleService {
|
|||||||
void saveArticle(Article article);
|
void saveArticle(Article article);
|
||||||
void deleteArticle(int id);
|
void deleteArticle(int id);
|
||||||
void updateArticle(int id);
|
void updateArticle(int id);
|
||||||
|
List<Article> findArticleByTitle(String title);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,4 +38,9 @@ public class ArticleServiceImpl implements ArticleService{
|
|||||||
public void updateArticle(int id) {
|
public void updateArticle(int id) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Article> findArticleByTitle(String title) {
|
||||||
|
return articleRepository.findArticleByTitle(title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
package fr.eni.enchere.controllers;
|
package fr.eni.enchere.controllers;
|
||||||
|
|
||||||
import fr.eni.enchere.bll.ArticleService;
|
import fr.eni.enchere.bll.ArticleService;
|
||||||
|
import fr.eni.enchere.bo.Article;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@@ -16,6 +22,7 @@ public class AccueilController {
|
|||||||
|
|
||||||
public AccueilController(ArticleService articleService) {
|
public AccueilController(ArticleService articleService) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.articleService = articleService;
|
this.articleService = articleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +32,12 @@ public class AccueilController {
|
|||||||
return "accueil";
|
return "accueil";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/searchArticle")
|
||||||
|
public String searchArticle(@ModelAttribute String title, Model model) {
|
||||||
|
model.addAttribute("Articles", articleService.findArticleByTitle(title));
|
||||||
|
return "accueil";
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/login")
|
@GetMapping("/login")
|
||||||
public String login(Model modele) {
|
public String login(Model modele) {
|
||||||
return "login";
|
return "login";
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
public interface ArticleRepository {
|
public interface ArticleRepository {
|
||||||
List<Article> findAllArticle();
|
List<Article> findAllArticle();
|
||||||
Article findArticleById(int id);
|
Article findArticleById(int id);
|
||||||
|
List<Article> findArticleByTitle(String title);
|
||||||
void saveArticle(Article article);
|
void saveArticle(Article article);
|
||||||
void deleteArticle(int id);
|
void deleteArticle(int id);
|
||||||
void updateArticle(int id);
|
void updateArticle(int id);
|
||||||
|
|||||||
@@ -56,6 +56,13 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Article> findArticleByTitle(String title) {
|
||||||
|
String sql = "SELECT * FROM ARTICLES_VENDUS WHERE nom_article LIKE '?'";
|
||||||
|
List<Article> articles = jdbcTemplate.query(sql, new ArticleRowMapper(), title);
|
||||||
|
return articles;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveArticle(Article article) {
|
public void saveArticle(Article article) {
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class WebSecurityConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
http.authorizeHttpRequests((requests) -> requests.requestMatchers("/", "/accueil").permitAll()
|
http.authorizeHttpRequests((requests) -> requests.requestMatchers("/", "/accueil").permitAll()
|
||||||
.requestMatchers("/accueil", "/login", "/inscription").permitAll()
|
.requestMatchers("/accueil", "/login", "/inscription", "/searchArticle").permitAll()
|
||||||
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**").permitAll()
|
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**").permitAll()
|
||||||
.requestMatchers("/admin").hasRole("ADMIN")
|
.requestMatchers("/admin").hasRole("ADMIN")
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="row mb-4">
|
<div class="row mb-4">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form th:action="@{/search}" method="get" class="input-group">
|
<form th:action="@{/searchArticle}" method="post" class="input-group">
|
||||||
<input type="text" class="form-control" placeholder="Rechercher un article par nom..." name="searchTerm" th:value="${searchTerm}">
|
<input type="text" class="form-control" placeholder="Rechercher un article par nom..." name="searchTerm" th:value="${titre}">
|
||||||
<button type="submit" class="btn btn-primary">Recherche</button>
|
<button type="submit" class="btn btn-primary">Recherche</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@@ -32,7 +32,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<h6>Prix de vente: <span th:text="${article.prixVente}"></span> €</h6>
|
<h6>Prix de vente: <span th:text="${article.prixVente}"></span> €</h6>
|
||||||
<h6 class="text-muted">Fin de l'enchere: <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
|
<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>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse " id="navbarNav">
|
<div class="collapse navbar-collapse " id="navbarNav">
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<li class="nav-item active">
|
<li class="nav-item active">
|
||||||
<a class="nav-link" href="#">Encheres <span class="sr-only">(current)</span></a>
|
<a class="nav-link" href="#">Encheres <span class="sr-only">(current)</span></a>
|
||||||
@@ -30,6 +30,9 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Déconnection</a>
|
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Déconnection</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item" th:if="${#authorization.expression('hasRole(''ROLE_ADMIN'')')}">
|
||||||
|
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">S'inscrire - Se connecter</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
Reference in New Issue
Block a user