Page admin final no css
This commit is contained in:
@@ -35,7 +35,7 @@ public class CategorieServiceImpl implements CategorieService {
|
||||
|
||||
@Override
|
||||
public void updateCategorie(Categorie categorie) {
|
||||
|
||||
categorieRepository.updateCategorie(categorie);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ public interface UserService {
|
||||
List<String> listPseudo();
|
||||
List<String> listEmail();
|
||||
void setUtilisateur(UserProfil utilisateur);
|
||||
void setCredit(float credit, int id);
|
||||
void deleteUtilisateur(int id);
|
||||
void disableUtilisateur(int id);
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ public class UserServiceImpl implements UserService {
|
||||
userRepository.save(utilisateur);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCredit(float credit, int id) {
|
||||
userRepository.updateCredit(credit, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUtilisateur(int id) {
|
||||
userRepository.delete(id);
|
||||
|
||||
@@ -44,7 +44,31 @@ public class AdminController {
|
||||
Categorie categorie = new Categorie();
|
||||
categorie.setLibelle(libelle);
|
||||
categorie.setId(idCategorie);
|
||||
categorieService.updateCategorie(categorie);
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
||||
@PostMapping("/update/credit")
|
||||
public String updateCreditUser(@RequestParam("newCredit") float credit, @RequestParam("idUser") int idUser) {
|
||||
userService.setCredit(credit, idUser);
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
||||
@PostMapping("/deleteC")
|
||||
public String deleteCategorie(@RequestParam("deleteIdCategorie") int id) {
|
||||
categorieService.deleteCategorie(id);
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
public String deleteUser(@RequestParam("userDelete") int id) {
|
||||
userService.deleteUtilisateur(id);
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
||||
@PostMapping("/disabled")
|
||||
public String disabledUser(@RequestParam("userDisabled") int id) {
|
||||
userService.disableUtilisateur(id);
|
||||
return "redirect:/admin";
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,6 @@ public class ArticleController {
|
||||
for (JsonNode node : responseBody) {
|
||||
String cityName = node.get("nomCommune").asText();
|
||||
villeCodePostal.add(cityName);
|
||||
System.out.println(cityName);
|
||||
}
|
||||
} else {
|
||||
redirectAttributes.addAttribute("erreur", "Une erreur est survenue !");
|
||||
|
||||
@@ -50,17 +50,19 @@ public class CategorieRepositoryImpl implements CategorieRepository {
|
||||
|
||||
@Override
|
||||
public void saveCategorie(Categorie categorie) {
|
||||
String sql = "INSERT INTO CATEGORIES (\t=libelle) VALUES (?)";
|
||||
String sql = "INSERT INTO CATEGORIES (libelle) VALUES (?)";
|
||||
jdbcTemplate.update(sql, categorie.getLibelle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCategorie(Categorie categorie) {
|
||||
|
||||
String sql = "UPDATE CATEGORIES SET libelle = ? WHERE no_categorie = ?";
|
||||
jdbcTemplate.update(sql, categorie.getLibelle(), categorie.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCategorie(int id) {
|
||||
|
||||
String sql = "UPDATE CATEGORIES SET isDelete = 1 WHERE no_categorie = ?";
|
||||
jdbcTemplate.update(sql, id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public interface UserRepository {
|
||||
List<String> findAllUsernames();
|
||||
List<String> findAllEmail();
|
||||
void save(UserProfil utilisateur);
|
||||
void updateCredit(float credit, int id);
|
||||
void delete(int id);
|
||||
void disable(int id);
|
||||
}
|
||||
|
||||
@@ -134,6 +134,12 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCredit(float credit, int id) {
|
||||
String sql = "UPDATE UTILISATEURS SET credit = ? WHERE no_utilisateur = ?";
|
||||
jdbcTemplate.update(sql, credit, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(int id) {
|
||||
String sql = "UPDATE UTILISATEURS SET isDelete = 1 WHERE no_utilisateur = ?";
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form th:action="@{/admin/catDelete}" method="post">
|
||||
<form th:action="@{/admin/deleteC}" method="post">
|
||||
<input type="hidden" name="deleteIdCategorie" id="deleteIdCategorie" th:value="${categorie.id}">
|
||||
<button>Supprimer</button>
|
||||
</form>
|
||||
@@ -45,6 +45,7 @@
|
||||
<th>Nom</th>
|
||||
<th>Prénom</th>
|
||||
<th>Email</th>
|
||||
<th>Crédit(s)</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -55,6 +56,13 @@
|
||||
<td th:text="${user.nom}"></td>
|
||||
<td th:text="${user.prenom}"></td>
|
||||
<td th:text="${user.email}"></td>
|
||||
<td>
|
||||
<form th:action="@{/admin/update/credit}" method="post">
|
||||
<input type="number" name="newCredit" id="newCredit" th:value="${user.credit}">
|
||||
<input type="hidden" name="idUser" id="idUser" th:value="${user.id}">
|
||||
<button>Sauvegarder</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>
|
||||
<form th:action="@{/admin/disabled}" method="post">
|
||||
<input type="hidden" name="userDisabled" id="userDisabled" th:value="${user.id}">
|
||||
|
||||
Reference in New Issue
Block a user