fix: pb update en cascade, ajout de Tache et Todolist (class et repository)
This commit is contained in:
parent
6c69774bb1
commit
c33d1282c7
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@ -7,6 +7,7 @@
|
|||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="Organizee" />
|
<module name="Organizee" />
|
||||||
|
<module name="organizee" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
</component>
|
</component>
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
package fr.organizee.controller;
|
package fr.organizee.controller;
|
||||||
|
|
||||||
import fr.organizee.model.Contact;
|
import fr.organizee.model.Contact;
|
||||||
import fr.organizee.model.Membre;
|
|
||||||
import fr.organizee.model.Team;
|
|
||||||
import fr.organizee.repository.ContactRepository;
|
import fr.organizee.repository.ContactRepository;
|
||||||
import fr.organizee.repository.TeamRepository;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.organizee.controller;
|
package fr.organizee.controller;
|
||||||
|
|
||||||
import fr.organizee.model.Contact;
|
|
||||||
import fr.organizee.model.Menu;
|
import fr.organizee.model.Menu;
|
||||||
import fr.organizee.repository.MenuRepository;
|
import fr.organizee.repository.MenuRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -21,8 +20,9 @@ public class MenuController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MenuRepository menuRepository;
|
private MenuRepository menuRepository;
|
||||||
|
|
||||||
|
//Récupère les infos d'un menu par son ID
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||||
public ResponseEntity<?> findById(@PathVariable int id){
|
public ResponseEntity<?> findById(@PathVariable int id){
|
||||||
Optional<Menu> menu = null;
|
Optional<Menu> menu = null;
|
||||||
try
|
try
|
||||||
@ -35,8 +35,9 @@ public class MenuController {
|
|||||||
return ResponseEntity.status(HttpStatus.OK).body(menu);
|
return ResponseEntity.status(HttpStatus.OK).body(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Récupère les infos des menus par la team ID
|
||||||
@GetMapping(value = "team/{team_id}")
|
@GetMapping(value = "team/{team_id}")
|
||||||
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||||
public ResponseEntity<?> findByTeamId(@PathVariable int team_id) {
|
public ResponseEntity<?> findByTeamId(@PathVariable int team_id) {
|
||||||
List<Menu> menus = null;
|
List<Menu> menus = null;
|
||||||
try {
|
try {
|
||||||
@ -47,8 +48,9 @@ public class MenuController {
|
|||||||
return ResponseEntity.status(HttpStatus.OK).body(menus);
|
return ResponseEntity.status(HttpStatus.OK).body(menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Ajoute un nouveau menu
|
||||||
@PostMapping(value="/add")
|
@PostMapping(value="/add")
|
||||||
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||||
public ResponseEntity<?> addMenu(@RequestBody Menu menu){
|
public ResponseEntity<?> addMenu(@RequestBody Menu menu){
|
||||||
Menu resultMenu = null;
|
Menu resultMenu = null;
|
||||||
try {
|
try {
|
||||||
@ -60,8 +62,9 @@ public class MenuController {
|
|||||||
return ResponseEntity.status(HttpStatus.CREATED).body(resultMenu);
|
return ResponseEntity.status(HttpStatus.CREATED).body(resultMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Mise a jour d'un menu par son ID
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||||
public ResponseEntity<?> updateMenu(@RequestBody Menu menu, @PathVariable Integer id) throws Exception {
|
public ResponseEntity<?> updateMenu(@RequestBody Menu menu, @PathVariable Integer id) throws Exception {
|
||||||
Menu resultMenu = null;
|
Menu resultMenu = null;
|
||||||
try {
|
try {
|
||||||
@ -71,11 +74,12 @@ public class MenuController {
|
|||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(menuRepository);
|
return ResponseEntity.status(HttpStatus.OK).body(resultMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Efface un menu par son ID
|
||||||
@DeleteMapping(value = "/delete/{id}")
|
@DeleteMapping(value = "/delete/{id}")
|
||||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||||
public ResponseEntity<?> deleteMenu(@PathVariable int id){
|
public ResponseEntity<?> deleteMenu(@PathVariable int id){
|
||||||
try {
|
try {
|
||||||
menuRepository.delete(menuRepository.getById(id));
|
menuRepository.delete(menuRepository.getById(id));
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package fr.organizee.controller;
|
package fr.organizee.controller;
|
||||||
|
|
||||||
import fr.organizee.model.Membre;
|
|
||||||
import fr.organizee.model.Tache;
|
import fr.organizee.model.Tache;
|
||||||
import fr.organizee.repository.MembreRepository;
|
|
||||||
import fr.organizee.repository.TacheRepository;
|
import fr.organizee.repository.TacheRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
@ -20,6 +19,7 @@ public class TacheController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TacheRepository tacheRepo;
|
private TacheRepository tacheRepo;
|
||||||
|
|
||||||
|
// Récupère toutes les taches de toutes la base toutes team confondu
|
||||||
@GetMapping(value = "/all")
|
@GetMapping(value = "/all")
|
||||||
public ResponseEntity<?> getAll(){
|
public ResponseEntity<?> getAll(){
|
||||||
List<Tache> liste = null;
|
List<Tache> liste = null;
|
||||||
@ -33,6 +33,7 @@ public class TacheController {
|
|||||||
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Récupère les infos d'une tache avec son ID
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
public ResponseEntity<?> findById(@PathVariable int id){
|
public ResponseEntity<?> findById(@PathVariable int id){
|
||||||
Optional<Tache> tache = null;
|
Optional<Tache> tache = null;
|
||||||
@ -46,6 +47,7 @@ public class TacheController {
|
|||||||
return ResponseEntity.status(HttpStatus.OK).body(tache);
|
return ResponseEntity.status(HttpStatus.OK).body(tache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Efface une tache avec son ID
|
||||||
@DeleteMapping(value = "/delete/{id}")
|
@DeleteMapping(value = "/delete/{id}")
|
||||||
public ResponseEntity<?> deleteTache(@PathVariable int id){
|
public ResponseEntity<?> deleteTache(@PathVariable int id){
|
||||||
try {
|
try {
|
||||||
@ -58,6 +60,7 @@ public class TacheController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ajoute une tache
|
||||||
@PostMapping(value="/add", produces="application/json", consumes="application/json")
|
@PostMapping(value="/add", produces="application/json", consumes="application/json")
|
||||||
public ResponseEntity<?> addTache(@RequestBody Tache tache){
|
public ResponseEntity<?> addTache(@RequestBody Tache tache){
|
||||||
Tache resultTache = null;
|
Tache resultTache = null;
|
||||||
@ -70,6 +73,7 @@ public class TacheController {
|
|||||||
return ResponseEntity.status(HttpStatus.CREATED).body(resultTache);
|
return ResponseEntity.status(HttpStatus.CREATED).body(resultTache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Met a jour les informations d'une date avec son ID
|
||||||
@PutMapping("/update/{id}")
|
@PutMapping("/update/{id}")
|
||||||
public ResponseEntity<?> updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception {
|
public ResponseEntity<?> updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception {
|
||||||
Tache resultTache = null;
|
Tache resultTache = null;
|
||||||
@ -82,4 +86,18 @@ public class TacheController {
|
|||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(resultTache);
|
return ResponseEntity.status(HttpStatus.OK).body(resultTache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//A revoir, résultat a chier, passez par la todolist
|
||||||
|
@GetMapping(value = "team/{team_id}")
|
||||||
|
public ResponseEntity<?> findByTeamId(@PathVariable int team_id){
|
||||||
|
List<Tache> taches = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
taches = tacheRepo.FindTachesByTeam(team_id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(taches);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package fr.organizee.controller;
|
package fr.organizee.controller;
|
||||||
|
|
||||||
import fr.organizee.model.Membre;
|
|
||||||
import fr.organizee.model.Team;
|
import fr.organizee.model.Team;
|
||||||
import fr.organizee.repository.TeamRepository;
|
import fr.organizee.repository.TeamRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -48,7 +47,7 @@ public class TeamController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||||
public ResponseEntity<?> findTeamById(@PathVariable int id){
|
public ResponseEntity<?> findTeamById(@PathVariable int id){
|
||||||
Optional<Team> liste = null;
|
Optional<Team> liste = null;
|
||||||
try
|
try
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
package fr.organizee.controller;
|
||||||
|
|
||||||
|
import fr.organizee.model.TodoList;
|
||||||
|
import fr.organizee.repository.TodoListRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.persistence.EntityNotFoundException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RequestMapping("/todolist")
|
||||||
|
public class TodoListController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TodoListRepository todolistRepo;
|
||||||
|
|
||||||
|
@GetMapping(value = "/all")
|
||||||
|
public ResponseEntity<?> getAll(){
|
||||||
|
List<TodoList> liste = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
liste = todolistRepo.findAll();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping(value = "/delete/{id}")
|
||||||
|
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||||
|
public ResponseEntity<?> deleteTodolist(@PathVariable int id){
|
||||||
|
try {
|
||||||
|
todolistRepo.delete(todolistRepo.getById(id));
|
||||||
|
//membreRepo.deleteById(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body("Todolist effacée !");
|
||||||
|
|
||||||
|
} catch (EntityNotFoundException e) {
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body("Todolist introuvable !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping(value = "/team/{team_id}")
|
||||||
|
public ResponseEntity<?> findByTeamId(@PathVariable int team_id){
|
||||||
|
List<TodoList> todoLists = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
todoLists = todolistRepo.FindTodolistByTeam(team_id);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(todoLists);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Met a jour les informations d'une date avec son ID
|
||||||
|
@PutMapping("/update/{id}")
|
||||||
|
public ResponseEntity<?> updateTodolist(@RequestBody TodoList todolist, @PathVariable Integer id) throws Exception {
|
||||||
|
TodoList resultTodolist = null;
|
||||||
|
try {
|
||||||
|
resultTodolist = todolistRepo.save(todolist);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(resultTodolist);
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ public class Contact {
|
|||||||
private String email;
|
private String email;
|
||||||
private String adresse;
|
private String adresse;
|
||||||
private LocalDate dateNaissance;
|
private LocalDate dateNaissance;
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
@ManyToOne
|
||||||
@JoinColumn(name="TEAM_ID")
|
@JoinColumn(name="TEAM_ID")
|
||||||
@JsonIgnoreProperties("contact")
|
@JsonIgnoreProperties("contact")
|
||||||
private Team team;
|
private Team team;
|
||||||
|
@ -36,7 +36,7 @@ public class Membre {
|
|||||||
// @ManyToOne
|
// @ManyToOne
|
||||||
// @JoinColumn(name="TEAM_ID")
|
// @JoinColumn(name="TEAM_ID")
|
||||||
// @JsonIgnore
|
// @JsonIgnore
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
@ManyToOne
|
||||||
@JoinColumn(name="TEAM_ID")
|
@JoinColumn(name="TEAM_ID")
|
||||||
@JsonIgnoreProperties("membre")
|
@JsonIgnoreProperties("membre")
|
||||||
private Team team;
|
private Team team;
|
||||||
|
@ -13,20 +13,19 @@ public class Menu {
|
|||||||
private String libelle;
|
private String libelle;
|
||||||
private LocalDate dateMenu;
|
private LocalDate dateMenu;
|
||||||
private int validationProposition;
|
private int validationProposition;
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
@ManyToOne
|
||||||
@JoinColumn(name="TEAM_ID")
|
@JoinColumn(name="TEAM_ID")
|
||||||
@JsonIgnoreProperties("menu")
|
@JsonIgnoreProperties("menu")
|
||||||
private Team team;
|
private Team team;
|
||||||
@ManyToOne
|
|
||||||
private Membre membre;
|
|
||||||
|
|
||||||
public Menu() {
|
public Menu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Menu(String libelle, LocalDate dateMenu, int validationProposition) {
|
public Menu(String libelle, LocalDate dateMenu, int validationProposition, Team team) {
|
||||||
this.libelle = libelle;
|
this.libelle = libelle;
|
||||||
this.dateMenu = dateMenu;
|
this.dateMenu = dateMenu;
|
||||||
this.validationProposition=validationProposition;
|
this.validationProposition=validationProposition;
|
||||||
|
this.team = team;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@ -53,12 +52,30 @@ public class Menu {
|
|||||||
this.dateMenu = dateMenu;
|
this.dateMenu = dateMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getValidationProposition() {
|
||||||
|
return validationProposition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidationProposition(int validationProposition) {
|
||||||
|
this.validationProposition = validationProposition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Team getTeam() {
|
||||||
|
return team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeam(Team team) {
|
||||||
|
this.team = team;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Menu{" +
|
return "Menu{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", libelle='" + libelle + '\'' +
|
", libelle='" + libelle + '\'' +
|
||||||
", dateMenu=" + dateMenu +
|
", dateMenu=" + dateMenu +
|
||||||
|
", validationProposition=" + validationProposition +
|
||||||
|
", team=" + team +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class Tache {
|
|||||||
private int id;
|
private int id;
|
||||||
private String texte;
|
private String texte;
|
||||||
private Boolean etat;
|
private Boolean etat;
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
@ManyToOne
|
||||||
@JoinColumn(name="TODOLIST_ID")
|
@JoinColumn(name="TODOLIST_ID")
|
||||||
@JsonIgnoreProperties("tache")
|
@JsonIgnoreProperties("tache")
|
||||||
private TodoList todolist;
|
private TodoList todolist;
|
||||||
|
@ -12,16 +12,16 @@ public class Team {
|
|||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private int id;
|
private int id;
|
||||||
private String nom;
|
private String nom;
|
||||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
@JsonIgnoreProperties("team")
|
@JsonIgnoreProperties("team")
|
||||||
private List<Membre> membres = new ArrayList<>();
|
private List<Membre> membres = new ArrayList<>();
|
||||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
@JsonIgnoreProperties("team")
|
@JsonIgnoreProperties("team")
|
||||||
private List<Contact> contacts = new ArrayList<>();
|
private List<Contact> contacts = new ArrayList<>();
|
||||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
@JsonIgnoreProperties("team")
|
@JsonIgnoreProperties("team")
|
||||||
private List<TodoList> todolists = new ArrayList<>();
|
private List<TodoList> todolists = new ArrayList<>();
|
||||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
@JsonIgnoreProperties("team")
|
@JsonIgnoreProperties("team")
|
||||||
private List<Menu> menus = new ArrayList<>();
|
private List<Menu> menus = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -12,10 +12,13 @@ public class TodoList {
|
|||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private int id;
|
private int id;
|
||||||
private String nom;
|
private String nom;
|
||||||
@ManyToOne(cascade = CascadeType.MERGE)
|
@ManyToOne
|
||||||
@JoinColumn(name="TEAM_ID")
|
@JoinColumn(name="TEAM_ID")
|
||||||
@JsonIgnoreProperties("todolist")
|
@JsonIgnoreProperties("todolist")
|
||||||
private Team team;
|
private Team team;
|
||||||
|
@OneToMany(mappedBy = "todolist", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||||
|
@JsonIgnoreProperties("todolist")
|
||||||
|
private List<Tache> taches = new ArrayList<>();
|
||||||
|
|
||||||
public TodoList() {
|
public TodoList() {
|
||||||
}
|
}
|
||||||
@ -40,11 +43,26 @@ public class TodoList {
|
|||||||
this.nom = nom;
|
this.nom = nom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Tache> getTaches() {
|
||||||
|
return taches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaches(List<Tache> taches) {
|
||||||
|
this.taches = taches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Team getTeam() {
|
||||||
|
return team;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeam(Team team) {
|
||||||
|
this.team = team;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "TodoList{" +
|
return "TodoList{" +
|
||||||
"id=" + id +
|
"id=" + id +
|
||||||
", nom='" + nom + '\'' +
|
", nom='" + nom + ", taches='" + taches + "}";
|
||||||
'}';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,16 @@ package fr.organizee.repository;
|
|||||||
|
|
||||||
import fr.organizee.model.Tache;
|
import fr.organizee.model.Tache;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface TacheRepository extends JpaRepository<Tache, Integer> {
|
public interface TacheRepository extends JpaRepository<Tache, Integer> {
|
||||||
|
|
||||||
|
// N'est plus utilisé normalement
|
||||||
|
@Query(value = "select * from todo_list, tache where todo_list.team_id = :team_id and todo_list.id = tache.todolist_id", nativeQuery = true)
|
||||||
|
List<Tache> FindTachesByTeam(@Param("team_id") int team_id);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
package fr.organizee.repository;
|
package fr.organizee.repository;
|
||||||
|
|
||||||
|
import fr.organizee.model.Menu;
|
||||||
import fr.organizee.model.TodoList;
|
import fr.organizee.model.TodoList;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface TodoListRepository extends JpaRepository<TodoList, Integer> {
|
public interface TodoListRepository extends JpaRepository<TodoList, Integer> {
|
||||||
|
@Query(value = "select * from todo_list where team_id = :team_id", nativeQuery = true)
|
||||||
|
List<TodoList> FindTodolistByTeam(@Param("team_id") int team_id);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user