diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java
index d62951a..d96e0a9 100644
--- a/src/main/java/fr/organizee/controller/MembreController.java
+++ b/src/main/java/fr/organizee/controller/MembreController.java
@@ -1,16 +1,17 @@
package fr.organizee.controller;
import fr.organizee.model.Membre;
+import fr.organizee.model.Team;
import fr.organizee.repository.MembreRepository;
+import fr.organizee.repository.TeamRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
import java.util.List;
+import java.util.Optional;
+
/* toto */
@RestController
@CrossOrigin("*")
@@ -19,17 +20,20 @@ public class MembreController {
@Autowired
private MembreRepository membreRepo;
+ @Autowired
+ private TeamRepository teamRepo;
+
@GetMapping("/")
@ResponseBody
public String home()
{
StringBuilder sb = new StringBuilder();
sb.append("
Affichages des membres
");
- sb.append("- Liste des membres
");
+ sb.append("- Liste des membres
");
return sb.toString();
}
- @GetMapping(value = "/membres")
+ @GetMapping(value = "/membres/all")
public ResponseEntity> getAll(){
List liste = null;
try
@@ -41,4 +45,50 @@ public class MembreController {
return ResponseEntity.status(HttpStatus.OK).body(liste);
}
+
+ @GetMapping(value = "/team/all")
+ public ResponseEntity> getAllTeam(){
+ List liste = null;
+ try
+ {
+ liste = teamRepo.findAll();
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+ }
+
+ return ResponseEntity.status(HttpStatus.OK).body(liste);
+ }
+
+ @GetMapping(value = "/membres/{id}")
+ public ResponseEntity> findById(@PathVariable int id){
+ Optional membre = null;
+ try
+ {
+ membre = membreRepo.findById(id);
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+ }
+
+ return ResponseEntity.status(HttpStatus.OK).body(membre);
+ }
+
+ @GetMapping(value = "/membres/delete/{id}")
+ public void deleteMembreId(@PathVariable("id") Integer id) {
+
+ membreRepo.deleteById(id);
+
+ }
+
+ @GetMapping(value = "/team/{id}")
+ public ResponseEntity> findTeamById(@PathVariable int id){
+ Optional liste = null;
+ try
+ {
+ liste = teamRepo.findById(id);
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+ }
+
+ return ResponseEntity.status(HttpStatus.OK).body(liste);
+ }
}
diff --git a/src/main/java/fr/organizee/model/Membre.java b/src/main/java/fr/organizee/model/Membre.java
index c485e14..7924e70 100644
--- a/src/main/java/fr/organizee/model/Membre.java
+++ b/src/main/java/fr/organizee/model/Membre.java
@@ -16,16 +16,15 @@ public class Membre {
private String password;
private String isAdmin;
private String couleur;
-/* @ManyToOne(fetch= FetchType.EAGER)
+ private String smiley;
+ @ManyToOne
@JoinColumn(name="TEAM_ID")
- private Team team;*/
-// @ManyToOne
-// private Smiley smiley;
+ private Team team;
public Membre() {
}
- public Membre(String nom, String prenom, LocalDate dateNaissance, String email, String password, String isAdmin, String couleur, Team team) {
+ public Membre(String nom, String prenom, LocalDate dateNaissance, String email, String password, String isAdmin, String couleur, String smiley, Team team) {
this.nom = nom;
this.prenom = prenom;
this.dateNaissance = dateNaissance;
@@ -33,6 +32,7 @@ public class Membre {
this.password = password;
this.isAdmin = isAdmin;
this.couleur = couleur;
+ this.smiley = smiley;
/* this.team = team;*/
}
@@ -78,12 +78,13 @@ public class Membre {
public void setIsAdmin(String isAdmin) {
this.isAdmin = isAdmin;
}
- /* public Team getTeam() {
+
+ public Team getTeam() {
return team;
}
public void setTeam(Team team) {
this.team = team;
- }*/
+ }
public String getCouleur() {
return couleur;
@@ -93,6 +94,14 @@ public class Membre {
this.couleur = couleur;
}
+ public String getSmiley() {
+ return smiley;
+ }
+
+ public void setSmiley(String smiley) {
+ this.smiley = smiley;
+ }
+
@Override
public String toString() {
return "Membre{" +
@@ -104,6 +113,7 @@ public class Membre {
", password='" + password + '\'' +
", isAdmin='" + isAdmin + '\'' +
", couleur='" + couleur + '\'' +
+ ", smiley='" + smiley + '\'' +
/*", team=" + team +*/
'}';
}
diff --git a/src/main/java/fr/organizee/model/Menu.java b/src/main/java/fr/organizee/model/Menu.java
index 4a4fc92..0444921 100644
--- a/src/main/java/fr/organizee/model/Menu.java
+++ b/src/main/java/fr/organizee/model/Menu.java
@@ -10,7 +10,10 @@ public class Menu {
private int id;
private String libelle;
private LocalDate dateMenu;
-
+ @ManyToOne
+ private Team team;
+ @ManyToOne
+ private Membre membre;
public Menu() {
}
diff --git a/src/main/java/fr/organizee/model/Smiley.java b/src/main/java/fr/organizee/model/Smiley.java
deleted file mode 100644
index 59cb411..0000000
--- a/src/main/java/fr/organizee/model/Smiley.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package fr.organizee.model;
-
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.List;
-
-@Entity
-public class Smiley {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- private String smileyUrl;
- @OneToMany
- private List membres = new ArrayList<>();
-
- public Smiley() {
- }
-
- public Smiley(String smileyUrl) {
- this.smileyUrl = smileyUrl;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getSmileyUrl() {
- return smileyUrl;
- }
-
- public void setSmileyUrl(String smileyUrl) {
- this.smileyUrl = smileyUrl;
- }
-
- @Override
- public String toString() {
- return "Smiley{" +
- "id=" + id +
- ", smileyUrl='" + smileyUrl + '\'' +
- '}';
- }
-}
diff --git a/src/main/java/fr/organizee/model/Team.java b/src/main/java/fr/organizee/model/Team.java
index fb2755c..ce562e2 100644
--- a/src/main/java/fr/organizee/model/Team.java
+++ b/src/main/java/fr/organizee/model/Team.java
@@ -10,7 +10,8 @@ public class Team {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String nom;
- @OneToMany
+ @OneToMany(mappedBy = "team", cascade = CascadeType.ALL, orphanRemoval = true)
+ //@OneToMany
private List membres = new ArrayList<>();
@OneToMany
@JoinTable(name = "repertoire")
@@ -18,6 +19,9 @@ public class Team {
@OneToMany
@JoinTable(name = "team_todolist")
private List todolists = new ArrayList<>();
+ @OneToMany
+ @JoinTable(name="team_menu")
+ private List