Un peu de tout
This commit is contained in:
@@ -46,6 +46,8 @@ dependencies {
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
//data
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'ch.qos.logback:logback-classic'
|
||||
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
|
||||
@@ -16,10 +16,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@@ -30,6 +27,7 @@ import java.util.Locale;
|
||||
|
||||
|
||||
@Controller
|
||||
@SessionAttributes({"searchTitle", "searchCategory", "venteOptions", "achatOptions", "typeTransaction"})
|
||||
public class AccueilController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AccueilController.class);
|
||||
@@ -45,12 +43,15 @@ public class AccueilController {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping({"/", "/enchere"})
|
||||
public String viewAccueil(HttpServletRequest request, @AuthenticationPrincipal UserDetails userDetails,
|
||||
@RequestParam(required = false) String searchTitle, @RequestParam(required = false) Integer searchCategory,
|
||||
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int size, Model model,
|
||||
@RequestParam(value = "venteOption", required = false) String[] venteOptions,
|
||||
@RequestParam(value = "achatOption", required = false) String[] achatOptions) {
|
||||
@RequestParam(value = "achatOption", required = false) String[] achatOptions,
|
||||
@RequestParam(required = false) String typeTransaction) {
|
||||
logger.error("test du logger");
|
||||
model.addAttribute("categories", categorieService.findAllCategories());
|
||||
model.addAttribute("requestURI", request.getRequestURI());
|
||||
SearchArticleCritere critere = new SearchArticleCritere();
|
||||
@@ -62,7 +63,6 @@ public class AccueilController {
|
||||
critere.setVenteOptions(venteOptions);
|
||||
critere.setAchatOptions(achatOptions);
|
||||
|
||||
// Si la page est 1 ou plus, décrémentez la valeur de la page de 1
|
||||
if (page > 0) {
|
||||
page -= 1;
|
||||
}
|
||||
@@ -71,20 +71,27 @@ public class AccueilController {
|
||||
Page<Article> articlePage = articleService.searchArticlePageable(critere, PageRequest.of(page, size));
|
||||
model.addAttribute("articles", articlePage.getContent());
|
||||
|
||||
// Ajoutez 1 à la valeur de la page actuelle pour l'affichage dans la vue
|
||||
int currentPage = page + 1;
|
||||
model.addAttribute("currentPage", currentPage);
|
||||
|
||||
model.addAttribute("critere", critere);
|
||||
model.addAttribute("totalPages", articlePage.getTotalPages());
|
||||
|
||||
return "accueil";
|
||||
}
|
||||
|
||||
@PostMapping("/enchere")
|
||||
public String handleSearch(HttpServletRequest request, @AuthenticationPrincipal UserDetails userDetails, @RequestParam(required = false) String searchTitle, @RequestParam(required = false) Integer searchCategory, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "6") int size, Model model, @RequestParam(value = "venteOption", required = false) String[] venteOptions, @RequestParam(value = "achatOption", required = false) String[] achatOptions) {
|
||||
public String handleSearch(HttpServletRequest request, @AuthenticationPrincipal UserDetails userDetails, @RequestParam(required = false) String searchTitle, @RequestParam(required = false) Integer searchCategory, @RequestParam(defaultValue = "0") int page, @RequestParam(defaultValue = "6") int size, Model model, @RequestParam(value = "venteOption", required = false) String[] venteOptions, @RequestParam(value = "achatOption", required = false) String[] achatOptions, @RequestParam(required = false) String typeTransaction) {
|
||||
|
||||
// Mettre à jour la catégorie dans la session
|
||||
model.addAttribute("searchCategory", searchCategory);
|
||||
|
||||
return viewAccueil(request, userDetails, searchTitle, searchCategory, page, size, model, venteOptions, achatOptions);
|
||||
model.addAttribute("searchTitle", searchTitle);
|
||||
|
||||
model.addAttribute("venteOptions", venteOptions);
|
||||
model.addAttribute("achatOptions", achatOptions);
|
||||
model.addAttribute("typeTransaction", typeTransaction);
|
||||
|
||||
return viewAccueil(request, userDetails, searchTitle, searchCategory, page, size, model, venteOptions, achatOptions, typeTransaction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
15
src/main/resources/logback-spring.xml
Normal file
15
src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="LOG_FILE" value="src/main/resources/logs/eni.log"/>
|
||||
|
||||
<appender name="File" class="ch.qos.logback.core.FileAppender">
|
||||
<file>${LOG_FILE}</file>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="File"/>
|
||||
</root>
|
||||
</configuration>
|
||||
2697
src/main/resources/logs/eni.log
Normal file
2697
src/main/resources/logs/eni.log
Normal file
File diff suppressed because one or more lines are too long
@@ -14,16 +14,15 @@
|
||||
<!-- Formulaire de recherche avec sélection de catégorie -->
|
||||
<form th:action="@{/enchere}" method="post" class="mb-3">
|
||||
<div class="row">
|
||||
<!-- Colonne pour la zone de recherche et Achats/Ventes -->
|
||||
<div class="col-md-6" th:if="${#authentication.principal != 'anonymousUser'}">
|
||||
<!-- Zone de recherche -->
|
||||
<div class="mb-3">
|
||||
<input type="text" class="form-control" th:attr="placeholder=#{home.search.title}" name="searchTitle">
|
||||
<input type="text" class="form-control" th:attr="placeholder=#{home.search.title}" name="searchTitle" >
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<select class="form-control" name="searchCategory">
|
||||
<option value="" th:text="#{home.search.cat}"></option>
|
||||
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}"></option>
|
||||
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle} "></option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Achats et Ventes -->
|
||||
@@ -36,8 +35,8 @@
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<select class="form-control" name="searchCategory">
|
||||
<option value="" th:text="#{home.search.cat}"></option>
|
||||
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}"></option>
|
||||
<option th:value="${categories}" th:text="#{home.search.cat}"></option>
|
||||
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}" ></option>
|
||||
</select>
|
||||
</div>
|
||||
<!-- Achats et Ventes -->
|
||||
@@ -163,7 +162,7 @@
|
||||
<ul class="pagination justify-content-center">
|
||||
<!-- Bouton pour la première page -->
|
||||
<li class="page-item">
|
||||
<a class="page-link" th:href="@{/(page=1)}">
|
||||
<a class="page-link" th:href="@{/enchere(page=1, searchTitle=${searchTitle}, searchCategory=${searchCategory}, venteOptions=${venteOptions}, achatOptions=${achatOptions})}">
|
||||
<span aria-hidden="true">«</span>
|
||||
<span th:text="#{home.button.first}"></span>
|
||||
</a>
|
||||
@@ -171,22 +170,22 @@
|
||||
|
||||
<!-- Bouton pour la page précédente -->
|
||||
<li th:if="${currentPage > 1}" class="page-item">
|
||||
<a class="page-link" th:href="@{/(page=${currentPage - 1})}">
|
||||
<a class="page-link" th:href="@{/enchere(page=${currentPage - 1}, searchTitle=${searchTitle}, searchCategory=${searchCategory}, venteOptions=${venteOptions}, achatOptions=${achatOptions})}">
|
||||
<span aria-hidden="true">‹</span>
|
||||
<span th:text="#{home.button.previous}"></span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<!-- Afficher les deux dernières pages, la page en cours et les deux suivantes -->
|
||||
<th:block th:each="page,iter : ${#numbers.sequence((currentPage - 2 > 0 ? currentPage - 2 : 1), (currentPage + 2 < totalPages ? currentPage + 2 : totalPages))}">
|
||||
<th:block th:each="page, iter : ${#numbers.sequence((currentPage - 2 > 0 ? currentPage - 2 : 1), (currentPage + 2 < totalPages ? currentPage + 2 : totalPages))}">
|
||||
<li class="page-item" th:classappend="${currentPage == page ? 'active' : ''}">
|
||||
<a class="page-link" th:href="@{/(page=${page})}" th:text="${page}"></a>
|
||||
<a class="page-link" th:href="@{/enchere(page=${page}, searchTitle=${searchTitle}, searchCategory=${searchCategory}, venteOptions=${venteOptions}, achatOptions=${achatOptions})}" th:text="${page}"></a>
|
||||
</li>
|
||||
</th:block>
|
||||
|
||||
<!-- Bouton pour la page suivante -->
|
||||
<li th:if="${currentPage < totalPages}" class="page-item">
|
||||
<a class="page-link" th:href="@{/(page=${currentPage + 1})}">
|
||||
<a class="page-link" th:href="@{/enchere(page=${currentPage + 1}, searchTitle=${searchTitle}, searchCategory=${searchCategory}, venteOptions=${venteOptions}, achatOptions=${achatOptions})}">
|
||||
<span aria-hidden="true">›</span>
|
||||
<span th:text="#{home.button.next}"></span>
|
||||
</a>
|
||||
@@ -194,7 +193,7 @@
|
||||
|
||||
<!-- Bouton pour la dernière page -->
|
||||
<li class="page-item">
|
||||
<a class="page-link" th:href="@{/(page=${totalPages})}">
|
||||
<a class="page-link" th:href="@{/enchere(page=${totalPages}, searchTitle=${searchTitle}, searchCategory=${searchCategory}, venteOptions=${venteOptions}, achatOptions=${achatOptions})}">
|
||||
<span aria-hidden="true">»</span>
|
||||
<span th:text="#{home.button.end}"></span>
|
||||
</a>
|
||||
|
||||
@@ -63,13 +63,13 @@
|
||||
<button type="submit" class="btn btn-primary" th:text="#{article.details.button.bid}"></button>
|
||||
</form>
|
||||
<div class="mt-5 d-flex justify-content-end align-items-center">
|
||||
<a class="btn btn-secondary mr-2" href="/accueil" th:text="#{edit.article.back}"></a>
|
||||
<a class="btn btn-secondary mr-2" href="/enchere" th:text="#{edit.article.back}"></a>
|
||||
<a th:if="${#strings.equals(user.getPseudo(), article.pseudoUtilisateur)} and ${#dates.format(article.dateDebutEnch, 'yyyy-MM-dd')} > ${#dates.format(#dates.createNow(), 'yyyy-MM-dd')}" class="btn btn-primary" th:href="@{/article/edit(id=${article.id})}" th:text="#{edit.article.update}"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="mt-2">
|
||||
<hr class="mt-2" th:if="${isArticleCurrentUser}">
|
||||
<div class="mt-2" th:if="${isArticleCurrentUser}">
|
||||
<h5>Enchérisseurs</h5>
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user