critere de recherche
This commit is contained in:
@@ -74,7 +74,6 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
||||
StringBuilder sql = new StringBuilder("SELECT a.*, u.* FROM ARTICLES_VENDUS a ");
|
||||
sql.append("JOIN UTILISATEURS u ON a.no_utilisateur = u.no_utilisateur ");
|
||||
sql.append("WHERE 1 = 1 AND a.isDelete = 0");
|
||||
|
||||
List<Object> params = new ArrayList<>();
|
||||
|
||||
if (critere.getNoCategorie() != null) {
|
||||
@@ -86,9 +85,38 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
||||
params.add('%' + critere.getTitle() + '%');
|
||||
}
|
||||
|
||||
// Ajouter les conditions supplémentaires basées sur les options de vente
|
||||
sql.append(" AND ("); // Début du bloc des conditions supplémentaires
|
||||
boolean isFirstCondition = true; // Pour vérifier la première condition
|
||||
for (String option : critere.getVenteOptions()) {
|
||||
if (option.equals("venteEnCours")) {
|
||||
if (!isFirstCondition) {
|
||||
sql.append(" OR "); // Ajouter un OR si ce n'est pas la première condition
|
||||
}
|
||||
sql.append(" (a.date_debut_encheres <= NOW() AND a.date_fin_encheres >= NOW()) ");
|
||||
isFirstCondition = false;
|
||||
}
|
||||
if (option.equals("ventesNonDebutees")) {
|
||||
if (!isFirstCondition) {
|
||||
sql.append(" OR "); // Ajouter un OR si ce n'est pas la première condition
|
||||
}
|
||||
sql.append(" (a.date_debut_encheres > NOW()) ");
|
||||
isFirstCondition = false;
|
||||
}
|
||||
if (option.equals("ventesTerminees")) {
|
||||
if (!isFirstCondition) {
|
||||
sql.append(" OR "); // Ajouter un OR si ce n'est pas la première condition
|
||||
}
|
||||
sql.append(" (a.date_fin_encheres < NOW()) ");
|
||||
isFirstCondition = false;
|
||||
}
|
||||
}
|
||||
sql.append(")"); // Fin du bloc des conditions supplémentaires
|
||||
|
||||
return jdbcTemplate.query(sql.toString(), new ArticleRowMapper(), params.toArray());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Article findArticleById(int id) {
|
||||
String sql = "SELECT * FROM ARTICLES_VENDUS a WHERE no_article = ?";
|
||||
|
||||
Reference in New Issue
Block a user