delete article
This commit is contained in:
@@ -34,7 +34,7 @@ public class ArticleServiceImpl implements ArticleService{
|
||||
|
||||
@Override
|
||||
public void deleteArticle(int id) {
|
||||
|
||||
articleRepository.deleteArticle(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,17 +6,14 @@ import fr.eni.enchere.bo.*;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpSession;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cglib.core.Local;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.text.ParseException;
|
||||
@@ -368,13 +365,13 @@ public class ArticleController {
|
||||
//Validation du formulaire
|
||||
retrait.setNumArticle(articleService.updateArticle(article));
|
||||
retraitService.updateRetrait(retrait);
|
||||
return "redirect:/accueil";
|
||||
return "redirect:/enchere";
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public String delte(@ModelAttribute("article") Article article) {
|
||||
article.setIsDelete(true);
|
||||
return "";
|
||||
public String deleteArticle(@RequestParam("articleId") int articleId) {
|
||||
this.articleService.deleteArticle(articleId);
|
||||
return "redirect:/enchere";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -330,7 +330,10 @@ public class ArticleRepositoryImpl implements ArticleRepository {
|
||||
|
||||
@Override
|
||||
public void deleteArticle(int id) {
|
||||
|
||||
String sql = "UPDATE ARTICLES_VENDUS " +
|
||||
"SET isDelete = 1 " +
|
||||
"WHERE no_article = ?";
|
||||
jdbcTemplate.update(sql, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div th:each="article : ${articles}" class="col-md-6 mb-4" >
|
||||
<a th:href="@{/article/show(id=${article.id})}" class="text-decoration-none text-dark" id="article-card">
|
||||
<a th:href="@{/article/show(id=${article.id})}" class="text-decoration-none text-dark" id="article-card">
|
||||
<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">
|
||||
|
||||
@@ -65,12 +65,17 @@
|
||||
<input type="text" class="form-control" th:field="*{ville}" id="city">
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-center">
|
||||
<a class="btn btn-danger justify-content-start" th:href="@{/article/delete(id=*{id})}" th:text="#{edit.article.delete}"></a>
|
||||
<a class="btn btn-secondary justify-content-end" th:href="@{/article/show(id=*{id})}" th:text="#{edit.profil.button.cancel}"></a>
|
||||
<button type="submit" class="btn btn-primary border-right ml-2 justify-content-end" th:text="#{edit.profil.button.edit}"></button>
|
||||
<div class="d-flex justify-content-end align-items-center">
|
||||
<button type="submit" class="btn btn-primary border-right" th:text="#{edit.profil.button.edit}"></button>
|
||||
</div>
|
||||
</form>
|
||||
<div class="d-flex justify-content-end align-items-center mt-2">
|
||||
<form th:action="@{/article/delete}" method="post" th:if="">
|
||||
<input type="hidden" name="articleId" id="articleId" th:value="${article.id}">
|
||||
<button type="submit" class="btn btn-danger" th:text="#{edit.article.delete}"></button>
|
||||
</form>
|
||||
<a class="btn btn-secondary ml-2" th:href="@{/article/show(id=${article.id})}" th:text="#{edit.profil.button.cancel}"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user