test
This commit is contained in:
@@ -3,6 +3,6 @@ package fr.eni.enchere.bll;
|
||||
import fr.eni.enchere.bo.Retrait;
|
||||
|
||||
public interface RetraitService {
|
||||
Retrait retraitByNumarticle(int id);
|
||||
Retrait findByNumArticle(int id);
|
||||
void setRetrait(Retrait retrait);
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ public class RetraitServiceImpl implements RetraitService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Retrait retraitByNumarticle(int id) {
|
||||
return null;
|
||||
public Retrait findByNumArticle(int idArticle) {
|
||||
return retraitRepository.findByNumArticle(idArticle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ArticleController {
|
||||
Article article = articleService.findArticleById(id);
|
||||
UserProfil user = userService.utilisateurById(article.getUtilisateur());
|
||||
Categorie cate = categorieService.findCategorieById(article.getNumCategorie());
|
||||
Retrait retrait = retraitService.retraitByNumarticle(article.getId());
|
||||
Retrait retrait = retraitService.findByNumArticle(article.getId());
|
||||
article.setPseudoUtilisateur(user.getPseudo());
|
||||
List<Enchere> lastEnchere = this.enchereService.enchereByArticle(article.getId());
|
||||
Optional<Float> maxMontantEnchere = lastEnchere.stream()
|
||||
@@ -231,9 +231,9 @@ public class ArticleController {
|
||||
@GetMapping("/edit")
|
||||
public String edit(Model model, @RequestParam()int id) {
|
||||
Article article = this.articleService.findArticleById(id);
|
||||
Retrait retrait = this.retraitService.retraitByNumarticle(id);
|
||||
System.out.println(article.getNom());
|
||||
Retrait retrait = this.retraitService.findByNumArticle(id);
|
||||
|
||||
System.out.println(retrait.getRue());
|
||||
model.addAttribute("article", article);
|
||||
model.addAttribute("retrait", retrait);
|
||||
model.addAttribute("categories", this.categorieService.findAllCategories());
|
||||
|
||||
@@ -4,5 +4,6 @@ import fr.eni.enchere.bo.Retrait;
|
||||
|
||||
public interface RetraitRepository {
|
||||
Retrait findById(int id);
|
||||
Retrait findByNumArticle(int idArticle);
|
||||
void save(Retrait retrait);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,16 @@ package fr.eni.enchere.dal;
|
||||
import fr.eni.enchere.bo.Retrait;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||
import org.springframework.jdbc.support.KeyHolder;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
@Repository
|
||||
@Primary
|
||||
public class RetraitRepositoryImpl implements RetraitRepository {
|
||||
@@ -21,11 +25,31 @@ public class RetraitRepositoryImpl implements RetraitRepository {
|
||||
this.namedJdbcTemplate = namedJdbcTemplate;
|
||||
}
|
||||
|
||||
public class RetraitRowMapper implements RowMapper<Retrait> {
|
||||
|
||||
@Override
|
||||
public Retrait mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
Retrait retrait = new Retrait();
|
||||
retrait.setRue(rs.getString("rue"));
|
||||
retrait.setVille(rs.getString("ville"));
|
||||
retrait.setCode_postale(rs.getString("code_postal"));
|
||||
retrait.setNumArticle(rs.getInt("no_article"));
|
||||
return retrait;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Retrait findById(int id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Retrait findByNumArticle(int numArticle) {
|
||||
String sql = "select * from RETRAITS where no_article = ?";
|
||||
Retrait retrait = jdbcTemplate.queryForObject(sql, new RetraitRowMapper(), numArticle);
|
||||
return retrait;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Retrait retrait) {
|
||||
String sqlIsUpdate = "SELECT COUNT(*) FROM RETRAITS WHERE no_article = :numArticle";
|
||||
|
||||
@@ -112,3 +112,7 @@ article.details.label.amount = Amount
|
||||
article.details.button.bid = Bid
|
||||
article.details.address.unknown = Unknown address
|
||||
article.details.validation.amount.required = Bid amount is required.
|
||||
|
||||
edit.article.title = Edit my article
|
||||
edit.article.update = Edit
|
||||
edit.article.back = Back
|
||||
|
||||
@@ -117,3 +117,5 @@ article.details.validation.amount.required = Le montant de l'ench\u00E8re est re
|
||||
|
||||
|
||||
edit.article.title = Modifier mon article
|
||||
edit.article.update = Modifier
|
||||
edit.article.back = Retour
|
||||
BIN
src/main/resources/static/images/articles/no-data.jpg
Normal file
BIN
src/main/resources/static/images/articles/no-data.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -122,7 +122,7 @@
|
||||
<div class="card shadow-sm h-100 card-article">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4 d-flex align-items-center justify-content-center p-3">
|
||||
<img th:src="${'images/articles/' + article.id + '.jpg'}" alt="Image de l'article" class="img-fluid rounded">
|
||||
<img th:src="${'images/articles/' + article.id + '.jpg'} ? ${'images/articles/' + article.id + '.jpg'} : ${'images/articles/no-data.jpg'}" alt="Image de l'article" class="img-fluid rounded">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body d-flex flex-column ">
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
</span>
|
||||
<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 th:if="${#strings.equals(user.getPseudo(), article.pseudoUtilisateur)}" class="btn btn-primary" th:href="@{/article/edit(id=${article.id})}" th:text="#{edit.article.update}"></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,16 +8,59 @@
|
||||
<div id="container-main" class="container mt-5">
|
||||
<h1 th:text="#{edit.article.title}"></h1>
|
||||
<form th:action="@{/article/new}" th:object="${article}">
|
||||
<!-- Titre article-->
|
||||
<div class="mb-3">
|
||||
<label for="nom" class="form-label">Titre</label>
|
||||
<strong><label for="nom" class="form-label">Titre</label></strong>
|
||||
<input type="text" class="form-control" th:field="*{nom}" id="nom">
|
||||
</div>
|
||||
<!-- Description article-->
|
||||
<div class="mb-3">
|
||||
<label for="categorie" class="form-label">Catégorie:</label>
|
||||
<strong><label for="desc" class="form-label">Description</label></strong>
|
||||
<input type="text" class="form-control" th:field="*{desc}" id="desc">
|
||||
</div>
|
||||
<!-- Catégorie article-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="categorie" class="form-label">Catégorie:</label></strong>
|
||||
<select class="form-control" th:field="*{numCategorie}" id="categorie" required>
|
||||
<option th:each="categorie : ${categories}" th:value="${categorie.id}" th:text="${categorie.libelle}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback">Veuillez sélectionner une catégorie.</div>
|
||||
</div>
|
||||
<!-- Photo article-->
|
||||
<div class="mb-3">
|
||||
<label for="photo" class="form-label" th:text="#{article.add.form.label.photo}">Photo de l'article:</label>
|
||||
<input type="file" class="form-control" th:field="*{photo}" id="photo" accept="image/jpeg">
|
||||
</div>
|
||||
<!-- Prix de l'article-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="price" class="form-label">Prix initial</label></strong>
|
||||
<input type="text" class="form-control" th:field="*{prixInitial}" id="price">
|
||||
</div>
|
||||
<!-- Date début enchère-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="dateStart" class="form-label">Date début d'enchère</label></strong>
|
||||
<input type="date" class="form-control" th:field="*{dateDebutEnch}" id="dateStart">
|
||||
</div>
|
||||
<!-- Date fin enchère-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="dateEnd" class="form-label">Date fin d'enchère</label></strong>
|
||||
<input type="date" class="form-control" th:field="*{dateFinEnch}" id="dateEnd">
|
||||
</div>
|
||||
<!-- Retrait-->
|
||||
<h4 th:text="#{article.add.form.label.removal}">Retrait</h4>
|
||||
<!-- Rue-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="street" class="form-label">Rue</label></strong>
|
||||
<input type="text" class="form-control" th:field="${retrait.rue}" id="street">
|
||||
</div>
|
||||
<!-- Code postal-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="cp" class="form-label">Code postal</label></strong>
|
||||
<input type="text" class="form-control" th:field="${retrait.code_postale}" id="cp">
|
||||
</div>
|
||||
<!-- Ville-->
|
||||
<div class="mb-3">
|
||||
<strong><label for="city" class="form-label">Ville</label></strong>
|
||||
<input type="text" class="form-control" th:field="${retrait.ville}" id="city">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user