Début de la page admin
This commit is contained in:
@@ -9,5 +9,6 @@ import java.util.List;
|
|||||||
public interface CategorieService {
|
public interface CategorieService {
|
||||||
List<fr.eni.enchere.bo.Categorie> findAllCategories();
|
List<fr.eni.enchere.bo.Categorie> findAllCategories();
|
||||||
Categorie findCategorieById(int id);
|
Categorie findCategorieById(int id);
|
||||||
|
void saveCategorie(Categorie categorie);
|
||||||
|
void deleteCategorie(int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,15 @@ public class CategorieServiceImpl implements CategorieService {
|
|||||||
return categorieRepository.findCategorieById(id);
|
return categorieRepository.findCategorieById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveCategorie(Categorie categorie) {
|
||||||
|
categorieRepository.saveCategorie(categorie);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCategorie(int id) {
|
||||||
|
categorieRepository.deleteCategorie(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ package fr.eni.enchere.controllers;
|
|||||||
|
|
||||||
import fr.eni.enchere.bll.CategorieService;
|
import fr.eni.enchere.bll.CategorieService;
|
||||||
import fr.eni.enchere.bll.UserService;
|
import fr.eni.enchere.bll.UserService;
|
||||||
|
import fr.eni.enchere.bo.Article;
|
||||||
|
import fr.eni.enchere.bo.Retrait;
|
||||||
|
import fr.eni.enchere.bo.UserProfil;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
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.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -20,7 +26,21 @@ public class AdminController {
|
|||||||
@GetMapping( "/admin")
|
@GetMapping( "/admin")
|
||||||
public String viewAdminPanel(Model model) {
|
public String viewAdminPanel(Model model) {
|
||||||
model.addAttribute("categories", categorieService.findAllCategories());
|
model.addAttribute("categories", categorieService.findAllCategories());
|
||||||
//model.addAttribute("userProfil", userService.f);
|
model.addAttribute("userProfil", userService.listeUtilisateurs());
|
||||||
return "admin";
|
return "admin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @GetMapping("/admin")
|
||||||
|
// public String newArticleForm(HttpServletRequest request, Model model) {
|
||||||
|
// model.addAttribute("categories", categorieService.findAllCategories());
|
||||||
|
// model.addAttribute("article", new Article());
|
||||||
|
// model.addAttribute("retrait", new Retrait());
|
||||||
|
// model.addAttribute("requestURI", request.getRequestURI());
|
||||||
|
// //Récupérer l'utilisateur pour set le retrait à son adresse par defaut
|
||||||
|
// Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
// String username = authentication.getName();
|
||||||
|
// UserProfil userProfile = userService.utilisateurByName(username);
|
||||||
|
// model.addAttribute("user", userProfile);
|
||||||
|
// return "admin";
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,6 @@ import java.util.List;
|
|||||||
public interface CategorieRepository {
|
public interface CategorieRepository {
|
||||||
List<Categorie> findAllCategories();
|
List<Categorie> findAllCategories();
|
||||||
Categorie findCategorieById(int id);
|
Categorie findCategorieById(int id);
|
||||||
|
void saveCategorie(Categorie categorie);
|
||||||
|
void deleteCategorie(int id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class CategorieRepositoryImpl implements CategorieRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Categorie> findAllCategories() {
|
public List<Categorie> findAllCategories() {
|
||||||
String sql = "SELECT * FROM CATEGORIES";
|
String sql = "SELECT * FROM CATEGORIES WHERE isDelete = 0";
|
||||||
List<Categorie> categories = jdbcTemplate.query(sql, new CategorieRowMapper());
|
List<Categorie> categories = jdbcTemplate.query(sql, new CategorieRowMapper());
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
@@ -46,4 +46,14 @@ public class CategorieRepositoryImpl implements CategorieRepository {
|
|||||||
Categorie categorie = jdbcTemplate.queryForObject(sql, new CategorieRowMapper(), id);
|
Categorie categorie = jdbcTemplate.queryForObject(sql, new CategorieRowMapper(), id);
|
||||||
return categorie;
|
return categorie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveCategorie(Categorie categorie) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCategorie(int id) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ public class UserRepositoryImpl implements UserRepository {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UserProfil> findAll() {
|
public List<UserProfil> findAll() {
|
||||||
return List.of();
|
String sql = "SELECT * FROM UTILISATEURS WHERE isDelete = 0";
|
||||||
|
List<UserProfil> users = jdbcTemplate.query(sql, new UserRowMapper());
|
||||||
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,9 +2,68 @@
|
|||||||
<html th:replace="~{modele-page :: layout('Panel administrateur',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
|
<html th:replace="~{modele-page :: layout('Panel administrateur',~{::link} , ~{::#container-main})}" xmlns:th="http://www.thymeleaf.org">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css"> <!-- Ajoutez le lien vers votre fichier CSS si nécessaire -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="container-main">
|
<div id="container-main">
|
||||||
|
<h2>Liste des catégories modifiées</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Nom</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="categorie : ${categories}">
|
||||||
|
<td>
|
||||||
|
<form th:action="@{/admin/new}" th:object="${categorie}" method="post">
|
||||||
|
<input type="text" th:field="*{libelle}" id="categorie" th:value="${categorie.libelle}">
|
||||||
|
<button>Sauvegarder</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form th:action="@{/admin/catDelete}" method="post">
|
||||||
|
<input type="hidden" name="idCategorie" id="idCategorie" th:value="${categorie.id}">
|
||||||
|
<button>Supprimer</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
<td th:text="${categorie.libelle}"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2>Liste des utilisateurs</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Pseudo</th>
|
||||||
|
<th>Nom</th>
|
||||||
|
<th>Prénom</th>
|
||||||
|
<th>Email</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr th:each="user : ${userProfil}">
|
||||||
|
<td th:text="${user.id}"></td>
|
||||||
|
<td th:text="${user.pseudo}"></td>
|
||||||
|
<td th:text="${user.nom}"></td>
|
||||||
|
<td th:text="${user.prenom}"></td>
|
||||||
|
<td th:text="${user.email}"></td>
|
||||||
|
<td>
|
||||||
|
<form th:action="@{/admin/disabled}" method="post">
|
||||||
|
<input type="hidden" name="userDisabled" id="userDisabled" th:value="${user.id}">
|
||||||
|
<button >Désactiver</button>
|
||||||
|
</form>
|
||||||
|
<form th:action="@{/admin/delete}" method="post">
|
||||||
|
<input type="hidden" name="userDelete" id="userDelete" th:value="${user.id}">
|
||||||
|
<button>Supprimer</button>
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user