critere de recherche
This commit is contained in:
@@ -13,6 +13,7 @@ public class Article {
|
|||||||
Date dateDebutEnch;
|
Date dateDebutEnch;
|
||||||
Date dateFinEnch;
|
Date dateFinEnch;
|
||||||
float prixInitial;
|
float prixInitial;
|
||||||
|
float prixMaxEnchere;
|
||||||
float prixVente;
|
float prixVente;
|
||||||
int Utilisateur;
|
int Utilisateur;
|
||||||
String pseudoUtilisateur;
|
String pseudoUtilisateur;
|
||||||
@@ -131,4 +132,12 @@ public class Article {
|
|||||||
public void setIsDelete(boolean delete) {
|
public void setIsDelete(boolean delete) {
|
||||||
isDelete = delete;
|
isDelete = delete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getPrixMaxEnchere() {
|
||||||
|
return prixMaxEnchere;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrixMaxEnchere(float prixMaxEnchere) {
|
||||||
|
this.prixMaxEnchere = prixMaxEnchere;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package fr.eni.enchere.dal;
|
package fr.eni.enchere.dal;
|
||||||
|
|
||||||
|
import fr.eni.enchere.bll.EnchereService;
|
||||||
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.Enchere;
|
||||||
import fr.eni.enchere.bo.SearchArticleCritere;
|
import fr.eni.enchere.bo.SearchArticleCritere;
|
||||||
import fr.eni.enchere.bo.UserProfil;
|
import fr.eni.enchere.bo.UserProfil;
|
||||||
import fr.eni.enchere.controllers.AccueilController;
|
import fr.eni.enchere.controllers.AccueilController;
|
||||||
@@ -30,6 +32,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
@Primary
|
@Primary
|
||||||
@@ -40,6 +43,7 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
|||||||
private JdbcTemplate jdbcTemplate;
|
private JdbcTemplate jdbcTemplate;
|
||||||
private NamedParameterJdbcTemplate namedJdbcTemplate;
|
private NamedParameterJdbcTemplate namedJdbcTemplate;
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
private EnchereService enchereService;
|
||||||
|
|
||||||
private class ArticleRowMapper implements RowMapper<Article> {
|
private class ArticleRowMapper implements RowMapper<Article> {
|
||||||
@Override
|
@Override
|
||||||
@@ -72,15 +76,23 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
|||||||
article.setPrixVente(rs.getFloat("a.prix_vente"));
|
article.setPrixVente(rs.getFloat("a.prix_vente"));
|
||||||
article.setNoUtilisateur(rs.getInt("u.no_utilisateur"));
|
article.setNoUtilisateur(rs.getInt("u.no_utilisateur"));
|
||||||
article.setPseudoUtilisateur(rs.getString("u.pseudo"));
|
article.setPseudoUtilisateur(rs.getString("u.pseudo"));
|
||||||
|
List<Enchere> lastEnchere = enchereService.enchereByArticle(rs.getInt("a.no_article"));
|
||||||
|
Optional<Float> maxMontantEnchere = lastEnchere.stream()
|
||||||
|
.map(Enchere::getMontantEnchere)
|
||||||
|
.max(Float::compareTo);
|
||||||
|
if (maxMontantEnchere.isPresent()) {
|
||||||
|
article.setPrixMaxEnchere(maxMontantEnchere.get());
|
||||||
|
}
|
||||||
article.setNumCategorie(rs.getInt("a.no_categorie"));
|
article.setNumCategorie(rs.getInt("a.no_categorie"));
|
||||||
return article;
|
return article;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticleRepositoryImpl(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedJdbcTemplate, UserService userService) {
|
public ArticleRepositoryImpl(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedJdbcTemplate, UserService userService, EnchereService enchereService) {
|
||||||
this.jdbcTemplate = jdbcTemplate;
|
this.jdbcTemplate = jdbcTemplate;
|
||||||
this.namedJdbcTemplate = namedJdbcTemplate;
|
this.namedJdbcTemplate = namedJdbcTemplate;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
|
this.enchereService = enchereService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ article.details.pseudo = Username
|
|||||||
article.details.mountench = Bidding Amount
|
article.details.mountench = Bidding Amount
|
||||||
article.details.ench = Bidders
|
article.details.ench = Bidders
|
||||||
article.details.lastof = Last Bid
|
article.details.lastof = Last Bid
|
||||||
|
article.details.label.last_price = Current sale price
|
||||||
|
article.details.label.start_date = Start date
|
||||||
|
|
||||||
edit.article.title = Edit my article
|
edit.article.title = Edit my article
|
||||||
edit.article.update = Edit
|
edit.article.update = Edit
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ article.details.pseudo = Pseudo
|
|||||||
article.details.mountench = Montant Ench\u00E8re
|
article.details.mountench = Montant Ench\u00E8re
|
||||||
article.details.ench = Ench\u00E9risseurs
|
article.details.ench = Ench\u00E9risseurs
|
||||||
article.details.lastof = Derni\u00E9re offre
|
article.details.lastof = Derni\u00E9re offre
|
||||||
|
article.details.label.last_price = Prix de vente actuel
|
||||||
|
article.details.label.start_date = Date de debut
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
</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">
|
||||||
<a th:href="@{/article/show(id=${article.id})}" class="text-decoration-none text-dark" id="article-card">
|
<a th:href="@{/article/show(id=${article.id})}" class="text-decoration-none text-dark" id="article-card">
|
||||||
<div class="card shadow-sm h-100 card-article">
|
<div class="card shadow-sm h-100 card-article">
|
||||||
<div class="row g-0">
|
<div class="row g-0">
|
||||||
@@ -123,20 +123,23 @@
|
|||||||
<img th:unless="${fileService.fileExists('/images/articles/' + article.id + '.jpg')}" th:src="@{/images/articles/no-data.jpg}" alt="Image de l'article" class="img-fluid rounded">
|
<img th:unless="${fileService.fileExists('/images/articles/' + article.id + '.jpg')}" th:src="@{/images/articles/no-data.jpg}" alt="Image de l'article" class="img-fluid rounded">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<div class="card-body d-flex flex-column ">
|
<div class="card-body d-flex flex-column">
|
||||||
<h5 class="text-dark card-title text" th:text="${article.nom}"></h5>
|
<h5 class="text-dark card-title" th:text="${article.nom}"></h5>
|
||||||
<p class="text-dark card-text mb-auto" th:text="${article.desc}"></p>
|
<p class="text-dark card-text mb-3" th:text="${article.desc}" style="overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;"></p>
|
||||||
<div class="mt-2 d-flex flex-row align-items-center justify-content-between">
|
<div class="mt-2 d-flex flex-row align-items-center justify-content-between">
|
||||||
<strong><label class="col-form-label mr-2" th:text="#{article.details.label.sale_price}"></label></strong>
|
<strong><label class="col-form-label mr-2" th:text="#{article.details.label.sale_price}"></label></strong>
|
||||||
<div class="col-form-label">
|
<div class="col-form-label">
|
||||||
<span class="text-dark" th:if="${article.prixInitial < article.prixVente}">
|
<span class="text-dark">
|
||||||
<i class="fas fa-coins"></i> <!-- Assurez-vous de remplacer "fa-coins" par la classe de votre icône -->
|
<i class="fas fa-coins"></i>
|
||||||
<span th:text="${article.prixVente}"></span>
|
<span th:text="${article.prixInitial}"></span>
|
||||||
</span>
|
</span>
|
||||||
<span class="text-dark" th:if="${article.prixVente < article.prixInitial}">
|
</div>
|
||||||
<i class="fas fa-coins"></i> <!-- Assurez-vous de remplacer "fa-coins" par la classe de votre icône -->
|
</div>
|
||||||
<span th:text="${article.prixInitial}"></span>
|
<div class="mt-2 d-flex flex-row align-items-center justify-content-between">
|
||||||
</span>
|
<strong><label class="col-form-label mr-2" th:text="#{article.details.label.last_price}"></label></strong>
|
||||||
|
<div class="col-form-label">
|
||||||
|
<i class="fas fa-coins"></i>
|
||||||
|
<span class="text-dark" th:text="${article.prixMaxEnchere}"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2 d-flex flex-row align-items-center justify-content-between">
|
<div class="mt-2 d-flex flex-row align-items-center justify-content-between">
|
||||||
@@ -146,7 +149,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<h6 class="text-muted"> <span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h6 class="text-muted"><strong><span th:text="#{article.details.label.start_date}"></span>: </strong></h6>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h6 class="text-muted"><span th:text="${#dates.format(article.dateDebutEnch, 'dd/MM/yyyy')}"></span></h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h6 class="text-muted"><strong><span th:text="#{article.details.label.end_date}"></span>: </strong></h6>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h6 class="text-muted"><span th:text="${#dates.format(article.dateFinEnch, 'dd/MM/yyyy')}"></span></h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -154,6 +172,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Pagination -->
|
<!-- Pagination -->
|
||||||
<div class="row mt-4" th:if="${not #lists.isEmpty(articles)}">
|
<div class="row mt-4" th:if="${not #lists.isEmpty(articles)}">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|||||||
Reference in New Issue
Block a user