This commit is contained in:
Sana EL HIRI 2022-02-18 17:46:23 +01:00
commit 4d7fe28e41
2 changed files with 18 additions and 4 deletions

View File

@ -67,11 +67,15 @@ public class MenuController {
} }
//Mise a jour d'un menu par son ID //Mise a jour d'un menu par son ID
@PutMapping("/update/{id}") @PutMapping("/update/{team_id}/{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 team_id, @PathVariable Integer id) throws Exception {
Menu resultMenu = null; Menu resultMenu = null;
try { try {
menu.setId(menuRepository.findById(id).get().getId());
Team team=new Team();
team.setId(team_id);
menu.setTeam(team);
resultMenu = menuRepository.save(menu); resultMenu = menuRepository.save(menu);
} catch (Exception e) { } catch (Exception e) {

View File

@ -12,6 +12,7 @@ public class Menu {
private int id; private int id;
private String libelle; private String libelle;
private LocalDate dateMenu; private LocalDate dateMenu;
private String repas;
// private int validationProposition; // private int validationProposition;
@ManyToOne @ManyToOne
@JoinColumn(name="TEAM_ID") @JoinColumn(name="TEAM_ID")
@ -21,10 +22,10 @@ public class Menu {
public Menu() { public Menu() {
} }
public Menu(String libelle, LocalDate dateMenu, Team team) { public Menu(String libelle, LocalDate dateMenu,String repas, Team team) {
this.libelle = libelle; this.libelle = libelle;
this.dateMenu = dateMenu; this.dateMenu = dateMenu;
//this.validationProposition=validationProposition; this.repas= repas;
this.team = team; this.team = team;
} }
@ -52,6 +53,14 @@ public class Menu {
this.dateMenu = dateMenu; this.dateMenu = dateMenu;
} }
public String getRepas() {
return repas;
}
public void setRepas(String repas) {
this.repas = repas;
}
// public int getValidationProposition() { // public int getValidationProposition() {
// return validationProposition; // return validationProposition;
//} //}
@ -75,6 +84,7 @@ public class Menu {
", libelle='" + libelle + '\'' + ", libelle='" + libelle + '\'' +
", dateMenu=" + dateMenu + ", dateMenu=" + dateMenu +
", team=" + team + ", team=" + team +
", repas=" + repas +
'}'; '}';
} }
} }