test
This commit is contained in:
@@ -43,7 +43,9 @@ public class EnchereController {
|
||||
|
||||
//Empeche une enchere inférieur au prix de base de l'article
|
||||
Article article = this.articleService.findArticleById(articleId);
|
||||
if (enchere.getMontantEnchere() < article.getPrixInitial()) {
|
||||
float articlePrice = article.getPrixInitial();
|
||||
float encherePrice = enchere.getMontantEnchere();
|
||||
if (encherePrice < articlePrice) {
|
||||
result.rejectValue("montantEnchere", "error.enchere", "Vous ne pouvez pas enchérir un montant inférieur au prix initial");
|
||||
}
|
||||
|
||||
@@ -53,10 +55,14 @@ public class EnchereController {
|
||||
.map(Enchere::getMontantEnchere) // Récupère seulement les montants d'enchère
|
||||
.max(Float::compareTo);
|
||||
System.out.println(maxMontantEnchere);
|
||||
if (enchere.getMontantEnchere() < maxMontantEnchere.get()) {
|
||||
if (maxMontantEnchere.isPresent() && encherePrice < maxMontantEnchere.get()) {
|
||||
result.rejectValue("montantEnchere", "error.enchere", "Vous ne pouvez pas enchérir un montant inférieur à la dernière enchère");
|
||||
}
|
||||
|
||||
if (result.hasErrors()) {
|
||||
return "redirect:/article/show?id=" + articleId;
|
||||
}
|
||||
|
||||
this.enchereService.setEnchere(enchere);
|
||||
return "redirect:/article/show?id=" + articleId;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class InscriptionController {
|
||||
result.rejectValue("password", "error.userProfile", "Les mots de passe ne correspond pas.");
|
||||
}
|
||||
// Vérifier si le mot de passe est sécurisé
|
||||
String passwordRegex = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}$";
|
||||
String passwordRegex = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@?*#$%^&+=_!\\-])(?=\\S+$).{8,}$";
|
||||
Pattern pattern = Pattern.compile(passwordRegex);
|
||||
// Vérifier si le mot de passe correspond à l'expression régulière
|
||||
if (!pattern.matcher(userProfile.getPassword()).matches()){
|
||||
|
||||
@@ -50,6 +50,11 @@
|
||||
<input type="hidden" id="articleId" name="articleId" th:value="${article.id}">
|
||||
<label for="montantEnchere">Montant</label>
|
||||
<input type="number" th:field="*{montantEnchere}" id="montantEnchere" step="0.01" min="0">
|
||||
<span style="color: red;" th:if="${#fields.hasErrors('montantEnchere')}">
|
||||
<ul>
|
||||
<li th:each="erreur: ${#fields.errors('montantEnchere')}" th:text="${erreur}"></li>
|
||||
</ul>
|
||||
</span>
|
||||
<button type="submit" class="btn btn-primary">Enchérir</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user