This commit is contained in:
Blandine Bajard 2022-02-18 17:29:51 +01:00
commit a8f693a5cb
8 changed files with 14 additions and 40 deletions

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.Contact; import fr.organizee.model.Contact;
import fr.organizee.repository.ContactRepository; import fr.organizee.repository.ContactRepository;
@ -20,6 +20,7 @@ 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 +35,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 +46,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 +63,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 +78,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

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.Evenement; import fr.organizee.model.Evenement;
import fr.organizee.model.Menu; import fr.organizee.model.Menu;

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.Mail; import fr.organizee.model.Mail;
import fr.organizee.service.SendMailService; import fr.organizee.service.SendMailService;

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.dto.JsonWebToken; import fr.organizee.dto.JsonWebToken;
import fr.organizee.dto.MembreDto; import fr.organizee.dto.MembreDto;
@ -59,7 +59,7 @@ public class MembreController {
} }
@GetMapping("/admin/all") @GetMapping("/admin/all")
@PreAuthorize("hasRole('ROLE_PARENT')") //@PreAuthorize("hasRole('ROLE_PARENT')")
public List<MembreDto> getAllAdminUsers() { public List<MembreDto> getAllAdminUsers() {
return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList()); return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList());
@ -168,34 +168,4 @@ public class MembreController {
return ResponseEntity.status(HttpStatus.OK).body(resultMembre); return ResponseEntity.status(HttpStatus.OK).body(resultMembre);
} }
// UPDATE SUR UN CHAMPS
// @PutMapping("/update/{id}")
// public ResponseEntity<?> updateMembre(@RequestBody Membre membre, @PathVariable Integer id) throws Exception {
// Membre resultMembre = null;
// Membre oldMembre = membreRepo.getById(id);
// oldMembre.setNom(membre.getNom());
// //Membre resultMembre = membreRepo.getById(id);
// try {
// resultMembre = membreRepo.save(oldMembre);
//
// } catch (Exception e) {
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
// }
//
// return ResponseEntity.status(HttpStatus.OK).body(resultMembre);
// }
// @GetMapping(value = "/team/{id}")
// public ResponseEntity<?> findTeamById(@PathVariable int id){
// Optional<Team> 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);
// }
} }

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.Menu; import fr.organizee.model.Menu;
import fr.organizee.model.Team; import fr.organizee.model.Team;

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.Tache; import fr.organizee.model.Tache;
import fr.organizee.model.TodoList; import fr.organizee.model.TodoList;

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.Team; import fr.organizee.model.Team;
import fr.organizee.repository.TeamRepository; import fr.organizee.repository.TeamRepository;

View File

@ -1,4 +1,4 @@
package fr.organizee.controller; package fr.organizee.dto.controller;
import fr.organizee.model.TodoList; import fr.organizee.model.TodoList;
import fr.organizee.repository.TodoListRepository; import fr.organizee.repository.TodoListRepository;