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";
|
||||
|
||||
Reference in New Issue
Block a user