Commit 85949b1aabae6da6bcdde705aae403b829778917
Merge remote-tracking branch 'origin/master'
Showing
7 changed files
with
81 additions
and
15 deletions
Show diff stats
PFE06/src/main/java/com/PFE/ServerManager/Customer.java
@@ -29,9 +29,20 @@ public class Customer{ | @@ -29,9 +29,20 @@ public class Customer{ | ||
29 | @JoinTable(name = "customer_role", joinColumns = @JoinColumn(name = "customer_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) | 29 | @JoinTable(name = "customer_role", joinColumns = @JoinColumn(name = "customer_id"), inverseJoinColumns = @JoinColumn(name = "role_id")) |
30 | private Set<Role> roles; | 30 | private Set<Role> roles; |
31 | 31 | ||
32 | + @ManyToMany(cascade = CascadeType.ALL) | ||
33 | + @JoinTable(name = "customer_maj", joinColumns = @JoinColumn(name = "customer_id"), inverseJoinColumns = @JoinColumn(name = "maj_id")) | ||
34 | + private Set<Maj> maj; | ||
35 | + | ||
32 | public void setRoles(Set<Role> roles) { this.roles = roles; } | 36 | public void setRoles(Set<Role> roles) { this.roles = roles; } |
33 | public Set<Role> getRoles() { return roles; } | 37 | public Set<Role> getRoles() { return roles; } |
34 | 38 | ||
39 | + public void setMaj(Set<Maj> maj) { | ||
40 | + this.maj = maj; | ||
41 | + } | ||
42 | + public Set<Maj> getMaj() { | ||
43 | + return maj; | ||
44 | + } | ||
45 | + | ||
35 | public String getRole(){ | 46 | public String getRole(){ |
36 | return roles.iterator().next().getRole(); | 47 | return roles.iterator().next().getRole(); |
37 | } | 48 | } |
PFE06/src/main/java/com/PFE/ServerManager/MainController.java
@@ -28,6 +28,9 @@ public class MainController { | @@ -28,6 +28,9 @@ public class MainController { | ||
28 | RoleRepository roleRepository; | 28 | RoleRepository roleRepository; |
29 | 29 | ||
30 | @Autowired | 30 | @Autowired |
31 | + MajRepository majRepository; | ||
32 | + | ||
33 | + @Autowired | ||
31 | BCryptPasswordEncoder bCryptPasswordEncoder; | 34 | BCryptPasswordEncoder bCryptPasswordEncoder; |
32 | 35 | ||
33 | @GetMapping(value="/") | 36 | @GetMapping(value="/") |
@@ -190,9 +193,20 @@ public class MainController { | @@ -190,9 +193,20 @@ public class MainController { | ||
190 | } | 193 | } |
191 | 194 | ||
192 | @PostMapping(path="/test") | 195 | @PostMapping(path="/test") |
193 | - public String test() { | ||
194 | - //ModelAndView modelAndView = new ModelAndView(); | ||
195 | - //modelAndView.setViewName("test"); | ||
196 | - return "test"; | 196 | + public ModelAndView addNewUser(@RequestParam String maj, @RequestParam String date, @RequestParam String set1, @RequestParam String set2){ |
197 | + ModelAndView modelAndView = new ModelAndView(); | ||
198 | + modelAndView.setViewName("test"); | ||
199 | + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); | ||
200 | + Customer customer = customerRepository.findByEmail(auth.getName()); | ||
201 | + Maj maj_c = new Maj(); | ||
202 | + maj_c.setMaj(maj); | ||
203 | + maj_c.setDate(date); | ||
204 | + String nodes=set1+';'+set2; | ||
205 | + maj_c.setNodes(nodes); | ||
206 | + maj_c.setMaj_id((int)(majRepository.count() + 1)); | ||
207 | + majRepository.save(maj_c); // ajouter la mise a jour dans la table | ||
208 | + customer.setMaj(new HashSet<Maj>(Arrays.asList(maj_c))); | ||
209 | + customerRepository.save(customer); // permet de rendre effective la jointure entre customer et maj | ||
210 | + return modelAndView; | ||
197 | } | 211 | } |
198 | } | 212 | } |
199 | \ No newline at end of file | 213 | \ No newline at end of file |
PFE06/src/main/java/com/PFE/ServerManager/Maj.java
@@ -16,11 +16,16 @@ public class Maj { | @@ -16,11 +16,16 @@ public class Maj { | ||
16 | @Column(name = "date") | 16 | @Column(name = "date") |
17 | private String date; | 17 | private String date; |
18 | 18 | ||
19 | + /* | ||
19 | @Column(name = "nodes") | 20 | @Column(name = "nodes") |
20 | private String nodes; | 21 | private String nodes; |
21 | 22 | ||
22 | @Column(name = "file") | 23 | @Column(name = "file") |
23 | private String file; | 24 | private String file; |
25 | + */ | ||
26 | + | ||
27 | + @Column(name = "nodes") | ||
28 | + private String nodes; | ||
24 | 29 | ||
25 | public void setMaj_id(Integer maj_id) { this.maj_id = maj_id; } | 30 | public void setMaj_id(Integer maj_id) { this.maj_id = maj_id; } |
26 | public Integer getMaj_id() { return maj_id; } | 31 | public Integer getMaj_id() { return maj_id; } |
@@ -30,6 +35,17 @@ public class Maj { | @@ -30,6 +35,17 @@ public class Maj { | ||
30 | } | 35 | } |
31 | public String getMaj() { return maj; } | 36 | public String getMaj() { return maj; } |
32 | 37 | ||
38 | + public void setDate(String date) { | ||
39 | + this.date = date; | ||
40 | + } | ||
41 | + public String getDate() { | ||
42 | + return date; | ||
43 | + } | ||
33 | 44 | ||
34 | - | 45 | + public void setNodes(String nodes) { |
46 | + this.nodes = nodes; | ||
47 | + } | ||
48 | + public String getNodes() { | ||
49 | + return nodes; | ||
50 | + } | ||
35 | } | 51 | } |
PFE06/src/main/java/com/PFE/ServerManager/MajRepository.java
0 → 100644
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +package com.PFE.ServerManager; | ||
2 | + | ||
3 | +import org.springframework.data.jpa.repository.JpaRepository; | ||
4 | +import org.springframework.stereotype.Repository; | ||
5 | + | ||
6 | +@Repository | ||
7 | +public interface MajRepository extends JpaRepository<Maj, Integer> { | ||
8 | + | ||
9 | + //Customer findByEmail(String email); | ||
10 | + | ||
11 | +} |
PFE06/src/main/resources/templates/home.html
@@ -34,6 +34,7 @@ | @@ -34,6 +34,7 @@ | ||
34 | <a class="dropdown-item" th:href="@{/registration}">Enregistrer des utilisateurs</a> | 34 | <a class="dropdown-item" th:href="@{/registration}">Enregistrer des utilisateurs</a> |
35 | <a class="dropdown-item" th:href="@{/all}">Listes des utilisateurs</a> | 35 | <a class="dropdown-item" th:href="@{/all}">Listes des utilisateurs</a> |
36 | <a class="dropdown-item" th:href="@{/session}">Paramétrer une mise à jour</a> | 36 | <a class="dropdown-item" th:href="@{/session}">Paramétrer une mise à jour</a> |
37 | + <a class="dropdown-item" th:href="@{/test}">test maj</a> | ||
37 | </div> | 38 | </div> |
38 | <div th:case="'USER'"> | 39 | <div th:case="'USER'"> |
39 | <a class="dropdown-item" th:href="@{/session}">Paramétrer une mise à jour</a> | 40 | <a class="dropdown-item" th:href="@{/session}">Paramétrer une mise à jour</a> |
PFE06/src/main/resources/templates/registration.html
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | 58 | ||
59 | <form id="Login" th:action="@{/registration}" method="POST"> | 59 | <form id="Login" th:action="@{/registration}" method="POST"> |
60 | <div class="form-group"> | 60 | <div class="form-group"> |
61 | - <input type="text" v-model="user.login" class="form-control" id="username" placeholder="Entrer le pseudo" name="pseudo"> | 61 | + <input type="text" v-model="user.login" class="form-control" id="username" placeholder="Entrer le pseudo" name="email"> |
62 | </div> | 62 | </div> |
63 | <div class="form-group"> | 63 | <div class="form-group"> |
64 | <input type="password" v-model="user.password" class="form-control" id="password" placeholder="Entrer le mot de passe" name="password"> | 64 | <input type="password" v-model="user.password" class="form-control" id="password" placeholder="Entrer le mot de passe" name="password"> |
PFE06/src/main/resources/templates/test.html
1 | <!DOCTYPE html> | 1 | <!DOCTYPE html> |
2 | +<html xmlns:th="http://www.thymeleaf.org"> | ||
2 | <html lang="en"> | 3 | <html lang="en"> |
3 | -<head> | ||
4 | - <meta charset="UTF-8"> | ||
5 | - <title>Data from js test</title> | ||
6 | -</head> | ||
7 | -<body> | ||
8 | - <div> | ||
9 | - | ||
10 | - </div> | ||
11 | -</body> | 4 | + <head> |
5 | + <meta charset="UTF-8"> | ||
6 | + <title>Data from js test</title> | ||
7 | + </head> | ||
8 | + <body> | ||
9 | + <form id="Login" th:action="@{/test}" method="POST"> | ||
10 | + <div class="form-group"> | ||
11 | + <input type="text" class="form-control" id="maj" placeholder="Entrer le nom de la maj" name="maj"> | ||
12 | + </div> | ||
13 | + <div class="form-group"> | ||
14 | + <input type="text" class="form-control" id="date" placeholder="Entrer la date" name="date"> | ||
15 | + </div> | ||
16 | + <div class="form-group"> | ||
17 | + <input type="text" class="form-control" id="set1" placeholder="set1" name="set1"> | ||
18 | + </div> | ||
19 | + <div class="form-group"> | ||
20 | + <input type="text" class="form-control" id="set2" placeholder="set2" name="set2"> | ||
21 | + </div> | ||
22 | + <button @click.prevent="registration" type="submit" class="btn btn-primary">Ajouter</button> | ||
23 | + </form> | ||
24 | + </body> | ||
12 | </html> | 25 | </html> |
13 | \ No newline at end of file | 26 | \ No newline at end of file |