patch prod

This commit is contained in:
jleroy
2024-05-03 10:55:27 +02:00
parent 5caac755f6
commit cdd7da676f
6 changed files with 35 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ public class Article {
String nom;
String desc;
MultipartFile photo;
String lienImg;
Date dateDebutEnch;
Date dateFinEnch;
float prixInitial;
@@ -23,11 +24,12 @@ public class Article {
public Article() {
}
public Article(int id, String nom, String desc, MultipartFile photo, Date dateDebutEnch, Date dateFinEnch, float prixInitial, float prixVente, int Utilisateur, String pseudoUtilisateur, int numCategorie, boolean isDelete) {
public Article(int id, String nom, String desc, MultipartFile photo, String lienImg, Date dateDebutEnch, Date dateFinEnch, float prixInitial, float prixVente, int Utilisateur, String pseudoUtilisateur, int numCategorie, boolean isDelete) {
setId(id);
setNom(nom);
setDesc(desc);
setPhoto(photo);
setLienImg(lienImg);
setDateDebutEnch(dateDebutEnch);
setDateFinEnch(dateFinEnch);
setPrixInitial(prixInitial);
@@ -65,6 +67,14 @@ public class Article {
return photo;
}
public String getLienImg() {
return lienImg;
}
public void setLienImg(String lienImg) {
this.lienImg = lienImg;
}
public void setPhoto(MultipartFile photo) {
this.photo = photo;
}

View File

@@ -34,14 +34,12 @@ public class AccueilController {
private ArticleService articleService;
private CategorieService categorieService;
private UserService userService;
private FileService fileService;
public AccueilController(ArticleService articleService, CategorieService categorieService, UserService userService, FileService fileService) {
public AccueilController(ArticleService articleService, CategorieService categorieService, UserService userService) {
super();
this.categorieService = categorieService;
this.articleService = articleService;
this.userService = userService;
this.fileService = fileService;
}
@GetMapping({"/", "/enchere"})
@@ -77,7 +75,6 @@ public class AccueilController {
Page<Article> articlePage = articleService.searchArticlePageable(critere, PageRequest.of(page, size));
model.addAttribute("articles", articlePage.getContent());
model.addAttribute("fileService", fileService);
int currentPage = page + 1;
model.addAttribute("currentPage", currentPage);
model.addAttribute("critere", critere);

View File

@@ -62,6 +62,7 @@ public class ArticleController {
UserProfil user = userService.utilisateurById(article.getUtilisateur());
Categorie cate = categorieService.findCategorieById(article.getNumCategorie());
Retrait retrait = retraitService.findByNumArticle(article.getId());
article.setPseudoUtilisateur(user.getPseudo());
List<Enchere> lastEnchere = this.enchereService.enchereByArticle(article.getId());

View File

@@ -1,6 +1,7 @@
package fr.eni.enchere.dal;
import fr.eni.enchere.bll.EnchereService;
import fr.eni.enchere.bll.FileService;
import fr.eni.enchere.bll.UserService;
import fr.eni.enchere.bo.Article;
import fr.eni.enchere.bo.Enchere;
@@ -44,6 +45,7 @@ public class ArticleRepositoryImpl implements ArticleRepository {
private NamedParameterJdbcTemplate namedJdbcTemplate;
private UserService userService;
private EnchereService enchereService;
private FileService fileService;
private class ArticleRowMapper implements RowMapper<Article> {
@Override
@@ -58,6 +60,14 @@ public class ArticleRepositoryImpl implements ArticleRepository {
article.setPrixVente(rs.getFloat("a.prix_vente"));
article.setNoUtilisateur(rs.getInt("a.no_utilisateur"));
article.setNumCategorie(rs.getInt("a.no_categorie"));
String lienImgTest = "/images/articles/" + article.getId() + ".jpg";
String lienImg;
if (fileService.fileExists(lienImgTest)){
lienImg = "/images/articles/" + article.getId() + ".jpg";
}else{
lienImg = "/images/articles/no-data.jpg";
}
article.setLienImg(lienImg);
article.setIsDelete(rs.getBoolean("a.isDelete"));
return article;
}
@@ -83,16 +93,25 @@ public class ArticleRepositoryImpl implements ArticleRepository {
if (maxMontantEnchere.isPresent()) {
article.setPrixMaxEnchere(maxMontantEnchere.get());
}
String lienImgTest = "/images/articles/" + article.getId() + ".jpg";
String lienImg;
if (fileService.fileExists(lienImgTest)){
lienImg = "/images/articles/" + article.getId() + ".jpg";
}else{
lienImg = "/images/articles/no-data.jpg";
}
article.setLienImg(lienImg);
article.setNumCategorie(rs.getInt("a.no_categorie"));
return article;
}
}
public ArticleRepositoryImpl(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedJdbcTemplate, UserService userService, EnchereService enchereService) {
public ArticleRepositoryImpl(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedJdbcTemplate, UserService userService, EnchereService enchereService, FileService fileService) {
this.jdbcTemplate = jdbcTemplate;
this.namedJdbcTemplate = namedJdbcTemplate;
this.userService = userService;
this.enchereService = enchereService;
this.fileService = fileService;
}
@Override