Merge branch 'marvin'
This commit is contained in:
@@ -46,6 +46,8 @@ dependencies {
|
|||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
//data
|
//data
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||||
|
implementation 'ch.qos.logback:logback-classic'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named('test') {
|
tasks.named('test') {
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
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.servlet.i18n.SessionLocaleResolver;
|
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
@@ -30,6 +27,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
|
@SessionAttributes({"searchTitle", "searchCategory", "venteOptions", "achatOptions", "typeTransaction"})
|
||||||
public class AccueilController {
|
public class AccueilController {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AccueilController.class);
|
private static final Logger logger = LoggerFactory.getLogger(AccueilController.class);
|
||||||
@@ -45,12 +43,15 @@ public class AccueilController {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping({"/", "/enchere"})
|
@GetMapping({"/", "/enchere"})
|
||||||
public String viewAccueil(HttpServletRequest request, @AuthenticationPrincipal UserDetails userDetails,
|
public String viewAccueil(HttpServletRequest request, @AuthenticationPrincipal UserDetails userDetails,
|
||||||
@RequestParam(required = false) String searchTitle, @RequestParam(required = false) Integer searchCategory,
|
@RequestParam(required = false) String searchTitle, @RequestParam(required = false) Integer searchCategory,
|
||||||
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int size, Model model,
|
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "6") int size, Model model,
|
||||||
@RequestParam(value = "venteOption", required = false) String[] venteOptions,
|
@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("categories", categorieService.findAllCategories());
|
||||||
model.addAttribute("requestURI", request.getRequestURI());
|
model.addAttribute("requestURI", request.getRequestURI());
|
||||||
SearchArticleCritere critere = new SearchArticleCritere();
|
SearchArticleCritere critere = new SearchArticleCritere();
|
||||||
@@ -62,7 +63,6 @@ public class AccueilController {
|
|||||||
critere.setVenteOptions(venteOptions);
|
critere.setVenteOptions(venteOptions);
|
||||||
critere.setAchatOptions(achatOptions);
|
critere.setAchatOptions(achatOptions);
|
||||||
|
|
||||||
// Si la page est 1 ou plus, décrémentez la valeur de la page de 1
|
|
||||||
if (page > 0) {
|
if (page > 0) {
|
||||||
page -= 1;
|
page -= 1;
|
||||||
}
|
}
|
||||||
@@ -71,20 +71,27 @@ public class AccueilController {
|
|||||||
Page<Article> articlePage = articleService.searchArticlePageable(critere, PageRequest.of(page, size));
|
Page<Article> articlePage = articleService.searchArticlePageable(critere, PageRequest.of(page, size));
|
||||||
model.addAttribute("articles", articlePage.getContent());
|
model.addAttribute("articles", articlePage.getContent());
|
||||||
|
|
||||||
// Ajoutez 1 à la valeur de la page actuelle pour l'affichage dans la vue
|
|
||||||
int currentPage = page + 1;
|
int currentPage = page + 1;
|
||||||
model.addAttribute("currentPage", currentPage);
|
model.addAttribute("currentPage", currentPage);
|
||||||
|
model.addAttribute("critere", critere);
|
||||||
model.addAttribute("totalPages", articlePage.getTotalPages());
|
model.addAttribute("totalPages", articlePage.getTotalPages());
|
||||||
|
|
||||||
return "accueil";
|
return "accueil";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/enchere")
|
@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 -->
|
<!-- Formulaire de recherche avec sélection de catégorie -->
|
||||||
<form th:action="@{/enchere}" method="post" class="mb-3">
|
<form th:action="@{/enchere}" method="post" class="mb-3">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Colonne pour la zone de recherche et Achats/Ventes -->
|
|
||||||
<div class="col-md-6" th:if="${#authentication.principal != 'anonymousUser'}">
|
<div class="col-md-6" th:if="${#authentication.principal != 'anonymousUser'}">
|
||||||
<!-- Zone de recherche -->
|
<!-- Zone de recherche -->
|
||||||
<div class="mb-3">
|
<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>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<select class="form-control" name="searchCategory">
|
<select class="form-control" name="searchCategory">
|
||||||
<option value="" th:text="#{home.search.cat}"></option>
|
<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>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<!-- Achats et Ventes -->
|
<!-- Achats et Ventes -->
|
||||||
@@ -36,8 +35,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<select class="form-control" name="searchCategory">
|
<select class="form-control" name="searchCategory">
|
||||||
<option value="" th:text="#{home.search.cat}"></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>
|
<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.libelle}" ></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<!-- Achats et Ventes -->
|
<!-- Achats et Ventes -->
|
||||||
@@ -163,7 +162,7 @@
|
|||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
<!-- Bouton pour la première page -->
|
<!-- Bouton pour la première page -->
|
||||||
<li class="page-item">
|
<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 aria-hidden="true">«</span>
|
||||||
<span th:text="#{home.button.first}"></span>
|
<span th:text="#{home.button.first}"></span>
|
||||||
</a>
|
</a>
|
||||||
@@ -171,22 +170,22 @@
|
|||||||
|
|
||||||
<!-- Bouton pour la page précédente -->
|
<!-- Bouton pour la page précédente -->
|
||||||
<li th:if="${currentPage > 1}" class="page-item">
|
<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 aria-hidden="true">‹</span>
|
||||||
<span th:text="#{home.button.previous}"></span>
|
<span th:text="#{home.button.previous}"></span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<!-- Afficher les deux dernières pages, la page en cours et les deux suivantes -->
|
<!-- 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' : ''}">
|
<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>
|
</li>
|
||||||
</th:block>
|
</th:block>
|
||||||
|
|
||||||
<!-- Bouton pour la page suivante -->
|
<!-- Bouton pour la page suivante -->
|
||||||
<li th:if="${currentPage < totalPages}" class="page-item">
|
<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 aria-hidden="true">›</span>
|
||||||
<span th:text="#{home.button.next}"></span>
|
<span th:text="#{home.button.next}"></span>
|
||||||
</a>
|
</a>
|
||||||
@@ -194,7 +193,7 @@
|
|||||||
|
|
||||||
<!-- Bouton pour la dernière page -->
|
<!-- Bouton pour la dernière page -->
|
||||||
<li class="page-item">
|
<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 aria-hidden="true">»</span>
|
||||||
<span th:text="#{home.button.end}"></span>
|
<span th:text="#{home.button.end}"></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -63,13 +63,13 @@
|
|||||||
<button type="submit" class="btn btn-primary" th:text="#{article.details.button.bid}"></button>
|
<button type="submit" class="btn btn-primary" th:text="#{article.details.button.bid}"></button>
|
||||||
</form>
|
</form>
|
||||||
<div class="mt-5 d-flex justify-content-end align-items-center">
|
<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>
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr class="mt-2" th:if="${isArticleCurrentUser}">
|
||||||
<div class="mt-2">
|
<div class="mt-2" th:if="${isArticleCurrentUser}">
|
||||||
<h5>Enchérisseurs</h5>
|
<h5>Enchérisseurs</h5>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
Reference in New Issue
Block a user