fichier langue / bootstrap / modification sql article

This commit is contained in:
mepiphana2023
2024-04-24 14:55:29 +02:00
parent 45c05debe6
commit dbd04fe987
8 changed files with 85 additions and 70 deletions

View File

@@ -12,13 +12,15 @@ public class Article {
Date dateFinEnch; Date dateFinEnch;
float prixInitial; float prixInitial;
float prixVente; float prixVente;
UserProfil Utilisateur; int noUtilisateur;
String pseudoUtilisateur;
int numCategorie; int numCategorie;
public Article() { public Article() {
} }
public Article(int id, String nom, String desc, String photo, Date dateDebutEnch, Date dateFinEnch, float prixInitial, float prixVente, UserProfil Utilisateur, int numCategorie) { public Article(int id, String nom, String desc, String photo, Date dateDebutEnch, Date dateFinEnch, float prixInitial, float prixVente, int noUtilisateur, String pseudoUtilisateur, int numCategorie) {
setId(id); setId(id);
setNom(nom); setNom(nom);
setDesc(desc); setDesc(desc);
@@ -27,7 +29,8 @@ public class Article {
setDateFinEnch(dateFinEnch); setDateFinEnch(dateFinEnch);
setPrixInitial(prixInitial); setPrixInitial(prixInitial);
setPrixVente(prixVente); setPrixVente(prixVente);
setUtilisateur(Utilisateur); setNoUtilisateur(noUtilisateur);
setPseudoUtilisateur(pseudoUtilisateur);
setNumCategorie(numCategorie); setNumCategorie(numCategorie);
} }
@@ -95,12 +98,21 @@ public class Article {
this.prixVente = prixVente; this.prixVente = prixVente;
} }
public UserProfil getUtilisateur() {
return Utilisateur; public String getPseudoUtilisateur() {
return pseudoUtilisateur;
} }
public void setUtilisateur(UserProfil Utilisateur) { public void setPseudoUtilisateur(String pseudoUtilisateur) {
this.Utilisateur = Utilisateur; this.pseudoUtilisateur = pseudoUtilisateur;
}
public int getNoUtilisateur() {
return noUtilisateur;
}
public void setNoUtilisateur(int noUtilisateur) {
this.noUtilisateur = noUtilisateur;
} }
public int getNumCategorie() { public int getNumCategorie() {

View File

@@ -21,8 +21,11 @@ public class LanguageController {
} }
@GetMapping("/change-language") @GetMapping("/change-language")
public String changeLanguage(@RequestParam("lang") String lang, HttpServletRequest request, HttpServletResponse response, RedirectAttributes redirectAttributes) { public String changeLanguage(HttpServletRequest request, HttpServletResponse response, @RequestParam("lang") String lang) {
localeResolver.setLocale(request, response, Locale.forLanguageTag(lang)); LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
return "redirect:/"; // Redirect to a specific page or the current one if (localeResolver != null) {
localeResolver.setLocale(request, response, Locale.forLanguageTag(lang));
}
return "redirect:/";
} }
} }

View File

@@ -31,22 +31,16 @@ public class ArticleRepositoryImpl implements ArticleRepository {
@Override @Override
public Article mapRow(ResultSet rs, int rowNum) throws SQLException { public Article mapRow(ResultSet rs, int rowNum) throws SQLException {
Article article = new Article(); Article article = new Article();
article.setId(rs.getInt("no_article")); article.setId(rs.getInt("a.no_article"));
article.setNom(rs.getString("nom_article")); article.setNom(rs.getString("a.nom_article"));
article.setDesc(rs.getString("description")); article.setDesc(rs.getString("a.description"));
article.setDateDebutEnch(rs.getDate("date_debut_encheres")); article.setDateDebutEnch(rs.getDate("a.date_debut_encheres"));
article.setDateFinEnch(rs.getDate("date_fin_encheres")); article.setDateFinEnch(rs.getDate("a.date_fin_encheres"));
article.setPrixInitial(rs.getFloat("prix_initial")); article.setPrixInitial(rs.getFloat("a.prix_initial"));
article.setPrixVente(rs.getFloat("prix_vente")); article.setPrixVente(rs.getFloat("a.prix_vente"));
article.setNoUtilisateur(rs.getInt("u.no_utilisateur"));
UserProfil user = userService.utilisateurById(rs.getInt("no_utilisateur")); article.setPseudoUtilisateur(rs.getString("u.pseudo"));
if (user != null) { article.setNumCategorie(rs.getInt("a.no_categorie"));
article.setUtilisateur(user);
} else {
logger.error("erreur de l'utilisateur");
}
article.setNumCategorie(rs.getInt("no_categorie"));
return article; return article;
} }
} }
@@ -59,24 +53,26 @@ public class ArticleRepositoryImpl implements ArticleRepository {
@Override @Override
public List<Article> findAllArticle() { public List<Article> findAllArticle() {
String sql = "SELECT * FROM ARTICLES_VENDUS"; String sql = "SELECT * FROM ARTICLES_VENDUS a";
List<Article> articles = jdbcTemplate.query(sql, new ArticleRowMapper()); List<Article> articles = jdbcTemplate.query(sql, new ArticleRowMapper());
return articles; return articles;
} }
@Override @Override
public List<Article> searchArticle(SearchArticleCritere critere) { public List<Article> searchArticle(SearchArticleCritere critere) {
StringBuilder sql = new StringBuilder("SELECT * FROM ARTICLES_VENDUS WHERE 1 = 1 AND isDelete = 0"); 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<>(); List<Object> params = new ArrayList<>();
if (critere.getNoCategorie() != null) { if (critere.getNoCategorie() != null) {
sql.append(" AND no_categorie = ?"); sql.append(" AND a.no_categorie = ?");
params.add(critere.getNoCategorie()); params.add(critere.getNoCategorie());
} }
if (critere.getTitle() != null && !critere.getTitle().isEmpty()) { if (critere.getTitle() != null && !critere.getTitle().isEmpty()) {
sql.append(" AND nom_article LIKE ?"); sql.append(" AND a.nom_article LIKE ?");
params.add( '%' + critere.getTitle() + "%"); params.add('%' + critere.getTitle() + '%');
} }
return jdbcTemplate.query(sql.toString(), new ArticleRowMapper(), params.toArray()); return jdbcTemplate.query(sql.toString(), new ArticleRowMapper(), params.toArray());
@@ -89,7 +85,7 @@ public class ArticleRepositoryImpl implements ArticleRepository {
@Override @Override
public List<Article> findArticleByTitle(String title) { public List<Article> findArticleByTitle(String title) {
String sql = "SELECT * FROM ARTICLES_VENDUS WHERE nom_article LIKE ?"; String sql = "SELECT * FROM ARTICLES_VENDUS a WHERE nom_article LIKE ?";
List<Article> articles = jdbcTemplate.query(sql, new ArticleRowMapper(), "%" + title + "%"); List<Article> articles = jdbcTemplate.query(sql, new ArticleRowMapper(), "%" + title + "%");
return articles; return articles;
} }

View File

@@ -2,24 +2,24 @@ home.search.title = Search for an item by name...
home.search.cat = All categories home.search.cat = All categories
home.search.button = Search home.search.button = Search
profile.title = My Profile profil.title = My Profile
profile.button = Edit profil.button = Edit
profile.pseudo = Username: profil.pseudo = Username:
profile.surname = First Name: profil.surname = First Name:
profile.name = Last Name: profil.name = Last Name:
profile.email = Email: profil.email = Email:
profile.phone = Phone: profil.phone = Phone:
profile.street = Street: profil.street = Street:
profile.postal = Zip Code: profil.postal = Zip Code:
profile.city = City: profil.city = City:
profile.credit = Credits: profil.credit = Credits:
edit.profile.currentpassword = Current Password: edit.profil.currentpassword = Current Password:
edit.profile.newpassword = New Password: edit.profil.newpassword = New Password:
edit.profile.confirmnewpassword = Confirm New Password: edit.profil.confirmnewpassword = Confirm New Password:
edit.profile.title = Edit My Profile edit.profil.title = Edit My Profile
edit.profile.button.edit = Save Changes edit.profil.button.edit = Save Changes
edit.profile.button.del = Delete My Account edit.profil.button.del = Delete My Account
login.title = To Log In: login.title = To Log In:
login.id = Username: login.id = Username:
@@ -27,7 +27,7 @@ login.password = Password:
login.save = Remember Me login.save = Remember Me
login.forgotpassword = Forgot Password login.forgotpassword = Forgot Password
login.connection = Login login.connection = Login
login.makecompte = Create Account login.makecompte = Create an Account
register.title = My Profile register.title = My Profile
register.button = Edit register.button = Edit

View File

@@ -1,6 +1,6 @@
accueil.search.title = Rechercher un article par nom... home.search.title = Rechercher un article par nom...
accueil.search.cat = Toutes les cat\u00e9gories home.search.cat = Toutes les cat\u00e9gories
accueil.search.button = Recherche home.search.button = Recherche
profil.title = Mon profil profil.title = Mon profil
profil.button = Modifier profil.button = Modifier

View File

@@ -9,19 +9,23 @@
<div class="row mb-4"> <div class="row mb-4">
<div class="col-12"> <div class="col-12">
<!-- Formulaire de recherche avec sélection de catégorie --> <!-- Formulaire de recherche avec sélection de catégorie -->
<form th:action="@{/accueil}" method="post" class="mb-3"> <div class="card">
<!-- Barre de recherche --> <div class="card-body">
<div class="mb-3"> <form th:action="@{/accueil}" method="post" class="row g-3 align-items-center">
<input type="text" class="form-control" th:attr="placeholder=#{accueil.search.title}" name="searchTitle"> <div class="col-md-8">
<!-- Barre de recherche -->
<input type="text" class="form-control" th:attr="placeholder=#{home.search.title}" name="searchTitle">
<select class="form-control mt-2" name="searchCategory">
<option value="" th:text="#{home.search.cat}"></option>
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}"></option>
</select>
</div>
<div class="col-md-4 text-center">
<button type="submit" class="btn btn-primary" th:text="#{home.search.button}">Search</button>
</div>
</form>
</div> </div>
<div class="mb-3"> </div>
<select class="form-control" name="searchCategory">
<option value="" th:text="#{accueil.search.cat}"></option>
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}"></option>
</select>
</div>
<button type="submit" class="btn btn-primary"th:text="#{accueil.search.button}"></button>
</form>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@@ -39,7 +43,7 @@
<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>Vendeur: <span th:text="${article.utilisateur.getPseudo()}"></span> </h6> <h6>Vendeur: <span th:text="${article.pseudoUtilisateur}"></span> </h6>
</div> </div>
</div> </div>
</br> </br>

View File

@@ -110,7 +110,7 @@
<span th:text="#{profil.credit}"></span> <span th:text="${userProfile.credit}"></span> <span th:text="#{profil.credit}"></span> <span th:text="${userProfile.credit}"></span>
</div> </div>
<input type="hidden" th:field="*{id}" id="userId" th:value="${userProfile.id}"> <input type="hidden" th:field="*{id}" id="userId" th:value="${userProfile.id}">
<button type="submit" class="btn btn-primary" th:text="#{edit.profil.button.edit}"></button> <button type="submit" class="btn btn-primary border-right" th:text="#{edit.profil.button.edit}"></button>
</div> </div>
</div> </div>
</form> </form>

View File

@@ -107,7 +107,7 @@
</span> </span>
</div> </div>
<div class="champ-saisie"> <div class="champ-saisie">
<label for="password">Mot de passe: </label> <label for="password" th:text="#{re}">Mot de passe: </label>
<div> <div>
<input type="password" th:field="*{password}" id="password" /> <input type="password" th:field="*{password}" id="password" />
</div> </div>
@@ -118,7 +118,7 @@
</span> </span>
</div> </div>
<div class="champ-saisie"> <div class="champ-saisie">
<label for="confirmPassword">Confirmation du mot de passe: </label> <label for="confirmPassword" th:text="#{}">Confirmation du mot de passe: </label>
<div> <div>
<input type="password" id="confirmPassword" /> <input type="password" id="confirmPassword" />
</div> </div>