Début de la page admin
This commit is contained in:
@@ -9,5 +9,6 @@ import java.util.List;
|
||||
public interface CategorieService {
|
||||
List<fr.eni.enchere.bo.Categorie> findAllCategories();
|
||||
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);
|
||||
}
|
||||
|
||||
@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.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.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -20,7 +26,21 @@ public class AdminController {
|
||||
@GetMapping( "/admin")
|
||||
public String viewAdminPanel(Model model) {
|
||||
model.addAttribute("categories", categorieService.findAllCategories());
|
||||
//model.addAttribute("userProfil", userService.f);
|
||||
model.addAttribute("userProfil", userService.listeUtilisateurs());
|
||||
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 {
|
||||
List<Categorie> findAllCategories();
|
||||
Categorie findCategorieById(int id);
|
||||
void saveCategorie(Categorie categorie);
|
||||
void deleteCategorie(int id);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CategorieRepositoryImpl implements CategorieRepository {
|
||||
|
||||
@Override
|
||||
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());
|
||||
return categories;
|
||||
}
|
||||
@@ -46,4 +46,14 @@ public class CategorieRepositoryImpl implements CategorieRepository {
|
||||
Categorie categorie = jdbcTemplate.queryForObject(sql, new CategorieRowMapper(), id);
|
||||
return categorie;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCategorie(Categorie categorie) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCategorie(int id) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,9 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user