Merge branch 'dev' into sana

This commit is contained in:
AlineRinquin 2022-02-18 18:01:46 +01:00 committed by GitHub
commit 6cabcc4d22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 12 deletions

View File

@ -20,6 +20,8 @@ public class ContactController {
@Autowired @Autowired
private ContactRepository contactRepo; private ContactRepository contactRepo;
//Récupère les infos d'un contact 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){
@ -34,6 +36,7 @@ public class ContactController {
return ResponseEntity.status(HttpStatus.OK).body(contact); return ResponseEntity.status(HttpStatus.OK).body(contact);
} }
//Récupère les infos d'un contact 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){
@ -44,10 +47,10 @@ public class ContactController {
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
} }
return ResponseEntity.status(HttpStatus.OK).body(contacts); return ResponseEntity.status(HttpStatus.OK).body(contacts);
} }
//Ajoute un nouveau contact
@PostMapping(value="/add") @PostMapping(value="/add")
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> addContact(@RequestBody Contact contact){ public ResponseEntity<?> addContact(@RequestBody Contact contact){
@ -61,6 +64,7 @@ public class ContactController {
return ResponseEntity.status(HttpStatus.CREATED).body(resultContact); return ResponseEntity.status(HttpStatus.CREATED).body(resultContact);
} }
//Mise à jour du contact par son ID
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> updateContact(@RequestBody Contact contact, @PathVariable Integer id) throws Exception { public ResponseEntity<?> updateContact(@RequestBody Contact contact, @PathVariable Integer id) throws Exception {
@ -75,6 +79,7 @@ public class ContactController {
return ResponseEntity.status(HttpStatus.OK).body(resultContact); return ResponseEntity.status(HttpStatus.OK).body(resultContact);
} }
//Efface le contact par on ID
@DeleteMapping(value = "/delete/{id}") @DeleteMapping(value = "/delete/{id}")
//@PreAuthorize("hasRole('ROLE_PARENT')") //@PreAuthorize("hasRole('ROLE_PARENT')")
public ResponseEntity<?> deleteContact(@PathVariable int id){ public ResponseEntity<?> deleteContact(@PathVariable int id){

View File

@ -28,13 +28,14 @@ public class MembreController {
@Autowired @Autowired
private MembreRepository membreRepo; private MembreRepository membreRepo;
@Autowired @Autowired
private MembreService membreService; private MembreService membreService;
@Autowired @Autowired
private BCryptPasswordEncoder passwordEncoder; private BCryptPasswordEncoder passwordEncoder;
public MembreController() {} public MembreController() {}
@ResponseBody @ResponseBody
public String home() public String home()
{ {
@ -176,8 +177,6 @@ public class MembreController {
} }
/********************* Gestion Mot de Passe ************************************/ /********************* Gestion Mot de Passe ************************************/
//cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas //cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas
@GetMapping("/forgot-password") @GetMapping("/forgot-password")
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
@ -216,7 +215,4 @@ public class MembreController {
return ResponseEntity.status(HttpStatus.OK).body(resultMembre); return ResponseEntity.status(HttpStatus.OK).body(resultMembre);
} }
} }

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

@ -21,7 +21,7 @@ public class TeamController {
@Autowired @Autowired
private TeamRepository teamRepo; private TeamRepository teamRepo;
// @RequestMapping("/teams") // @RequestMapping("/teams")
@ResponseBody @ResponseBody
public String home() public String home()
{ {

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 +
'}'; '}';
} }
} }