Merge branch 'Johan'
This commit is contained in:
8
src/main/java/fr/eni/enchere/bll/RetraitService.java
Normal file
8
src/main/java/fr/eni/enchere/bll/RetraitService.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package fr.eni.enchere.bll;
|
||||||
|
|
||||||
|
import fr.eni.enchere.bo.Retrait;
|
||||||
|
|
||||||
|
public interface RetraitService {
|
||||||
|
Retrait retraitByNumarticle(int id);
|
||||||
|
void setRetrait(Retrait retrait);
|
||||||
|
}
|
||||||
17
src/main/java/fr/eni/enchere/bll/RetraitServiceImpl.java
Normal file
17
src/main/java/fr/eni/enchere/bll/RetraitServiceImpl.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package fr.eni.enchere.bll;
|
||||||
|
|
||||||
|
import fr.eni.enchere.bo.Retrait;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service("RetraitService")
|
||||||
|
public class RetraitServiceImpl implements RetraitService {
|
||||||
|
@Override
|
||||||
|
public Retrait retraitByNumarticle(int id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRetrait(Retrait retrait) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ public class Article {
|
|||||||
int id;
|
int id;
|
||||||
String nom;
|
String nom;
|
||||||
String desc;
|
String desc;
|
||||||
|
String photo;
|
||||||
Date dateDebutEnch;
|
Date dateDebutEnch;
|
||||||
Date dateFinEnch;
|
Date dateFinEnch;
|
||||||
float prixInitial;
|
float prixInitial;
|
||||||
@@ -17,16 +18,17 @@ public class Article {
|
|||||||
public Article() {
|
public Article() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Article(int id, String nom, String desc, 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, UserProfil Utilisateur, int numCategorie) {
|
||||||
this.id = id;
|
setId(id);
|
||||||
this.nom = nom;
|
setNom(nom);
|
||||||
this.desc = desc;
|
setDesc(desc);
|
||||||
this.dateDebutEnch = dateDebutEnch;
|
setPhoto(photo);
|
||||||
this.dateFinEnch = dateFinEnch;
|
setDateDebutEnch(dateDebutEnch);
|
||||||
this.prixInitial = prixInitial;
|
setDateFinEnch(dateFinEnch);
|
||||||
this.prixVente = prixVente;
|
setPrixInitial(prixInitial);
|
||||||
this.Utilisateur = Utilisateur;
|
setPrixVente(prixVente);
|
||||||
this.numCategorie = numCategorie;
|
setUtilisateur(Utilisateur);
|
||||||
|
setNumCategorie(numCategorie);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -53,6 +55,14 @@ public class Article {
|
|||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPhoto() {
|
||||||
|
return photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhoto(String photo) {
|
||||||
|
this.photo = photo;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getDateDebutEnch() {
|
public Date getDateDebutEnch() {
|
||||||
return dateDebutEnch;
|
return dateDebutEnch;
|
||||||
}
|
}
|
||||||
|
|||||||
50
src/main/java/fr/eni/enchere/bo/Retrait.java
Normal file
50
src/main/java/fr/eni/enchere/bo/Retrait.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
package fr.eni.enchere.bo;
|
||||||
|
|
||||||
|
public class Retrait {
|
||||||
|
|
||||||
|
private int numArticle;
|
||||||
|
private String rue;
|
||||||
|
private String code_postale;
|
||||||
|
private String ville;
|
||||||
|
|
||||||
|
public Retrait(){}
|
||||||
|
|
||||||
|
public Retrait(int numArticle, String rue, String code_postale, String ville) {
|
||||||
|
setNumArticle(numArticle);
|
||||||
|
setRue(rue);
|
||||||
|
setCode_postale(code_postale);
|
||||||
|
setVille(ville);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVille() {
|
||||||
|
return ville;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVille(String ville) {
|
||||||
|
this.ville = ville;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode_postale() {
|
||||||
|
return code_postale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode_postale(String code_postale) {
|
||||||
|
this.code_postale = code_postale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRue() {
|
||||||
|
return rue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRue(String rue) {
|
||||||
|
this.rue = rue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumArticle() {
|
||||||
|
return numArticle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumArticle(int numArticle) {
|
||||||
|
this.numArticle = numArticle;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,12 @@ package fr.eni.enchere.controllers;
|
|||||||
|
|
||||||
import fr.eni.enchere.bll.ArticleService;
|
import fr.eni.enchere.bll.ArticleService;
|
||||||
import fr.eni.enchere.bll.CategorieService;
|
import fr.eni.enchere.bll.CategorieService;
|
||||||
|
import fr.eni.enchere.bll.RetraitService;
|
||||||
import fr.eni.enchere.bll.UserService;
|
import fr.eni.enchere.bll.UserService;
|
||||||
import fr.eni.enchere.bo.Article;
|
import fr.eni.enchere.bo.Article;
|
||||||
|
import fr.eni.enchere.bo.Retrait;
|
||||||
|
import fr.eni.enchere.bo.UserProfil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@@ -12,14 +16,17 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
@RequestMapping("/article")
|
@RequestMapping("/article")
|
||||||
public class ArticleController {
|
public class ArticleController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private final ArticleService articleService;
|
private final ArticleService articleService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private CategorieService categorieService;
|
private CategorieService categorieService;
|
||||||
|
private RetraitService retraitService;
|
||||||
|
|
||||||
public ArticleController(ArticleService articleService, UserService userService, CategorieService categorieService) {
|
public ArticleController(ArticleService articleService, UserService userService, CategorieService categorieService, RetraitService retraitService) {
|
||||||
this.articleService = articleService;
|
this.articleService = articleService;
|
||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.categorieService = categorieService;
|
this.categorieService = categorieService;
|
||||||
|
this.retraitService = retraitService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@@ -28,6 +35,7 @@ public class ArticleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Affichage d'un article
|
//Affichage d'un article
|
||||||
|
|
||||||
@GetMapping("/show")
|
@GetMapping("/show")
|
||||||
public String showArticle(@RequestParam(name = "slug")int id, Model model) {
|
public String showArticle(@RequestParam(name = "slug")int id, Model model) {
|
||||||
Article article = articleService.findArticleById(id);
|
Article article = articleService.findArticleById(id);
|
||||||
@@ -41,25 +49,26 @@ public class ArticleController {
|
|||||||
return "article";
|
return "article";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Création d'un article
|
||||||
|
|
||||||
@GetMapping("/new")
|
@GetMapping("/new")
|
||||||
public String test(@PathVariable(name = "slug")int id, Model model) {
|
public String newArticleForm(Model model) {
|
||||||
model.addAttribute("categories", categorieService.findAllCategories());
|
model.addAttribute("categories", categorieService.findAllCategories());
|
||||||
|
model.addAttribute("article", new Article());
|
||||||
|
model.addAttribute("retrait", new Retrait());
|
||||||
return "newArticle";
|
return "newArticle";
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/new/add")
|
@PostMapping("/new")
|
||||||
public String newArticle(@ModelAttribute("article") Article article) {
|
public String newArticle(@RequestParam("article") Article article, @RequestParam("retrait") Retrait retrait) {
|
||||||
articleService.saveArticle(article);
|
//Récupérer l'utilisateur pour set
|
||||||
return "redirect:/accueil";
|
System.out.println(article.getNumCategorie());
|
||||||
}
|
if (article.getId() == 0){
|
||||||
|
//Création d'un article
|
||||||
@PostMapping("/update")
|
} else {
|
||||||
public String updateArticle() {
|
//Mise à jour d'un article
|
||||||
return "redirect:/accueil";
|
}
|
||||||
}
|
//articleService.saveArticle(article);
|
||||||
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public String deleteArticle() {
|
|
||||||
return "redirect:/accueil";
|
return "redirect:/accueil";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
|||||||
|
|
||||||
@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");
|
StringBuilder sql = new StringBuilder("SELECT * FROM ARTICLES_VENDUS WHERE 1 = 1 AND isDelete = 0");
|
||||||
|
|
||||||
List<Object> params = new ArrayList<>();
|
List<Object> params = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
8
src/main/java/fr/eni/enchere/dal/RetraitRepository.java
Normal file
8
src/main/java/fr/eni/enchere/dal/RetraitRepository.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package fr.eni.enchere.dal;
|
||||||
|
|
||||||
|
import fr.eni.enchere.bo.Retrait;
|
||||||
|
|
||||||
|
public interface RetraitRepository {
|
||||||
|
Retrait findById(int id);
|
||||||
|
void save(Retrait retrait);
|
||||||
|
}
|
||||||
20
src/main/java/fr/eni/enchere/dal/RetraitRepositoryImpl.java
Normal file
20
src/main/java/fr/eni/enchere/dal/RetraitRepositoryImpl.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package fr.eni.enchere.dal;
|
||||||
|
|
||||||
|
import fr.eni.enchere.bo.Retrait;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Primary
|
||||||
|
public class RetraitRepositoryImpl implements RetraitRepository {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Retrait findById(int id) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(Retrait retrait) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,7 @@ public class WebSecurityConfig{
|
|||||||
.requestMatchers("/", "/accueil").permitAll()
|
.requestMatchers("/", "/accueil").permitAll()
|
||||||
.requestMatchers("/accueil", "/login", "/inscription/**", "/searchArticle", "/article/**", "/change-language").permitAll()
|
.requestMatchers("/accueil", "/login", "/inscription/**", "/searchArticle", "/article/**", "/change-language").permitAll()
|
||||||
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**").permitAll()
|
.requestMatchers("/css/**", "/images/**", "/assets/**", "/img/**", "/js/**", "/assets/**").permitAll()
|
||||||
.requestMatchers("/profil/**", "/article/new/**", "/article/update", "/article/delete").authenticated()
|
.requestMatchers("/profil/**", "/article/new/**").authenticated()
|
||||||
.requestMatchers("/admin").hasRole("ADMIN")
|
.requestMatchers("/admin").hasRole("ADMIN")
|
||||||
.anyRequest().authenticated())
|
.anyRequest().authenticated())
|
||||||
.formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true))
|
.formLogin((form) -> form.loginPage("/login").defaultSuccessUrl("/", true))
|
||||||
|
|||||||
@@ -3,79 +3,78 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container-main">
|
<div id="container-main">
|
||||||
<h1>Nouvelle vente</h1>
|
<h1>Nouvelle vente</h1>
|
||||||
<form action="/articles/add" method="post" enctype="multipart/form-data">
|
<form th:action="@{/article/new}" method="post" enctype="multipart/form-data">
|
||||||
<!-- Nom de l'article -->
|
<!-- Nom de l'article -->
|
||||||
<div>
|
<div>
|
||||||
<label for="nom">Article:</label>
|
<label for="nom">Article:</label>
|
||||||
<input type="text" id="nom" name="nom" required>
|
<input type="text" id="nom" th:field="*{article.nom}" required>
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Description -->
|
|
||||||
<div>
|
|
||||||
<label for="description">Description:</label>
|
|
||||||
<textarea id="description" name="description" required></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Catégorie -->
|
|
||||||
<div>
|
|
||||||
<label for="categorie">Catégorie:</label>
|
|
||||||
<select id="categorie" name="categorie" required>
|
|
||||||
<option value="categorie1">Catégorie 1</option>
|
|
||||||
<option value="categorie2">Catégorie 2</option>
|
|
||||||
<!-- Ajoutez d'autres options si nécessaire -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Photo -->
|
|
||||||
<div>
|
|
||||||
<label for="photo">Photo de l'article:</label>
|
|
||||||
<input type="file" id="photo" name="photo" accept="image/jpeg" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Mise à prix -->
|
|
||||||
<div>
|
|
||||||
<label for="prix">Mise à prix:</label>
|
|
||||||
<input type="number" id="prix" name="prix" min="0" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Date début enchère -->
|
|
||||||
<div>
|
|
||||||
<label for="dateDebut">Date début enchère:</label>
|
|
||||||
<input type="date" id="dateDebut" name="dateDebut" min="<?php echo date('Y-m-d'); ?>" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Date fin enchère -->
|
|
||||||
<div>
|
|
||||||
<label for="dateFin">Date fin enchère:</label>
|
|
||||||
<input type="date" id="dateFin" name="dateFin" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Lieu de retrait -->
|
|
||||||
<h2>Retrait</h2>
|
|
||||||
<div>
|
|
||||||
<label for="rue">Rue:</label>
|
|
||||||
<input type="text" id="rue" name="rue" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="codePostal">Code postal:</label>
|
|
||||||
<input type="text" id="codePostal" name="codePostal" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="ville">Ville:</label>
|
|
||||||
<input type="text" id="ville" name="ville" required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Bouton Enregistrer -->
|
|
||||||
<div>
|
|
||||||
<button type="submit">Enregistrer</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<form th:action="@{/accueil}" method="post">
|
|
||||||
<button type="submit">Annuler</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
|
||||||
|
<!-- Description -->
|
||||||
|
<div>
|
||||||
|
<label for="description">Description:</label>
|
||||||
|
<textarea id="description" th:field="*{article.desc}" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Catégorie -->
|
||||||
|
<div>
|
||||||
|
<label for="categorie">Catégorie:</label>
|
||||||
|
<select id="categorie" th:field="*{article.numCategorie}" required>
|
||||||
|
<!-- Boucle sur les catégories pour générer les options -->
|
||||||
|
<option th:each="categorie : ${categories}" th:value="${categorie.id}" th:text="${categorie.libelle}"></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Photo -->
|
||||||
|
<div>
|
||||||
|
<label for="photo">Photo de l'article:</label>
|
||||||
|
<input type="file" id="photo" th:field="*{article.photo}" accept="image/jpeg" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Mise à prix -->
|
||||||
|
<div>
|
||||||
|
<label for="prix">Mise à prix:</label>
|
||||||
|
<input type="number" id="prix" th:field="*{article.prixInitial}" min="0" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Date début enchère -->
|
||||||
|
<div>
|
||||||
|
<label for="dateDebut">Date début enchère:</label>
|
||||||
|
<input type="date" id="dateDebut" th:field="*{article.dateDebutEnch}" min="today" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Date fin enchère -->
|
||||||
|
<div>
|
||||||
|
<label for="dateFin">Date fin enchère:</label>
|
||||||
|
<input type="date" id="dateFin" th:field="*{article.dateFinEnch}" min="today" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Lieu de retrait -->
|
||||||
|
<h4>Retrait</h4>
|
||||||
|
<div>
|
||||||
|
<label for="rue">Rue:</label>
|
||||||
|
<input type="text" id="rue" th:field="*{retrait.rue}" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="codePostal">Code postal:</label>
|
||||||
|
<input type="text" id="codePostal" th:field="*{retrait.code_postale}" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="ville">Ville:</label>
|
||||||
|
<input type="text" id="ville" th:field="*{retrait.ville}" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bouton Enregistrer -->
|
||||||
|
<div>
|
||||||
|
<button type="submit">Enregistrer</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<form th:action="@{/accueil}" method="post">
|
||||||
|
<button type="submit">Annuler</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user