Formulaire incription utilisateur
This commit is contained in:
@@ -22,7 +22,7 @@ dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-validation'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
|
||||
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.4'
|
||||
implementation 'org.mariadb.jdbc:mariadb-java-client:2.2.0'
|
||||
}
|
||||
|
||||
tasks.named('test') {
|
||||
|
||||
@@ -8,6 +8,5 @@ public interface UserService {
|
||||
List<User> listeUtilisateurs();
|
||||
User utilisateur(int id);
|
||||
void setUtilisateur(User utilisateur);
|
||||
void editUtilisateur(int id);
|
||||
void deleteUtilisateur(int id);
|
||||
}
|
||||
|
||||
@@ -30,11 +30,6 @@ public class UserServiceImpl implements UserService {
|
||||
userRepository.save(utilisateur);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editUtilisateur(int id) {
|
||||
userRepository.edit(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUtilisateur(int id) {
|
||||
userRepository.delete(id);
|
||||
|
||||
@@ -27,8 +27,7 @@ public class InscriptionController {
|
||||
|
||||
@PostMapping("/newUser")
|
||||
public String setUser(@ModelAttribute User user) {
|
||||
System.out.println(user.getId());
|
||||
//userService.setUtilisateur(user);
|
||||
userService.setUtilisateur(user);
|
||||
return "redirect:/accueil";
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,5 @@ public interface UserRepository {
|
||||
List<User> findAll();
|
||||
User findById(int id);
|
||||
void save(User utilisateur);
|
||||
void edit(int id);
|
||||
void delete(int id);
|
||||
}
|
||||
|
||||
@@ -49,19 +49,14 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
parameters.addValue("code_postal", utilisateur.getCode_postal());
|
||||
parameters.addValue("ville", utilisateur.getVille());
|
||||
parameters.addValue("mot_de_passe", utilisateur.getPassword());
|
||||
|
||||
jdbcTemplate.update(sql, parameters, keyHolder ,new String[] {"id"} );
|
||||
utilisateur.setId(keyHolder.getKey().intValue());
|
||||
System.out.println(keyHolder);
|
||||
jdbcTemplate.update(sql, parameters);
|
||||
//utilisateur.setId(keyHolder.getKey().intValue());
|
||||
}else {
|
||||
//Mettre à jour
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(int id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(int id) {
|
||||
|
||||
|
||||
@@ -2,4 +2,3 @@
|
||||
spring.datasource.url=jdbc:mariadb://91.121.54.36:3306/eni_enchere
|
||||
spring.datasource.username=eni
|
||||
spring.datasource.password=Pa$$w0rd
|
||||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
|
||||
@@ -6,7 +6,7 @@
|
||||
<body>
|
||||
<!-- Ajouter la page de nav bar -->
|
||||
<div id="container-main">
|
||||
<form th:action="@{/newUser}" method="post" th:object="${user}">
|
||||
<form th:action="@{/inscription/newUser}" method="post" th:object="${user}">
|
||||
<!--<div class="erreur-saisie" th:if="${#fields.hasErrors('*')}" >
|
||||
<p th:text="#{index.erreurs}">Message d'erreur</p>
|
||||
</div>-->
|
||||
@@ -62,7 +62,7 @@
|
||||
<div class="champ-saisie">
|
||||
<label for="telephone">Téléphone: </label>
|
||||
<div>
|
||||
<input type="tel" th:field="*{telephone}" id="telephone" />
|
||||
<input type="text" th:field="*{telephone}" id="telephone" />
|
||||
</div>
|
||||
<span style="color: red;" th:if="${#fields.hasErrors('telephone')}">
|
||||
<ul>
|
||||
@@ -86,7 +86,7 @@
|
||||
<div class="champ-saisie">
|
||||
<label for="code_postal">Code postal: </label>
|
||||
<div>
|
||||
<input type="number" th:field="*{code_postal}" id="code_postal" />
|
||||
<input type="text" th:field="*{code_postal}" id="code_postal" />
|
||||
</div>
|
||||
<span style="color: red;" th:if="${#fields.hasErrors('code_postal')}">
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user