cecile
This commit is contained in:
commit
ce8c57b5ac
|
@ -6,11 +6,9 @@ import fr.organizee.exception.ExistingUsernameException;
|
|||
import fr.organizee.exception.InvalidCredentialsException;
|
||||
import fr.organizee.exception.MembreNotFoundException;
|
||||
import fr.organizee.model.Membre;
|
||||
import fr.organizee.model.Menu;
|
||||
import fr.organizee.model.Team;
|
||||
import fr.organizee.repository.MembreRepository;
|
||||
import fr.organizee.service.MembreService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
@ -24,42 +22,39 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping(value = "/membres")
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
@RequestMapping(value="/membres")
|
||||
public class MembreController {
|
||||
|
||||
@Autowired
|
||||
private MembreRepository membreRepo;
|
||||
|
||||
@Autowired
|
||||
private MembreRepository membreRepository;
|
||||
private MembreService membreService;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder passwordEncoder;
|
||||
|
||||
public MembreController() {}
|
||||
|
||||
@ResponseBody
|
||||
public String home()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<h1>Affichages des membres</h1>");
|
||||
sb.append("<ul><li><a href='http://localhost:8088/membres/all'>Liste des <strong>membres</strong></a></li>");
|
||||
return sb.toString();
|
||||
/**
|
||||
* Contrôleur Membre
|
||||
*/
|
||||
public MembreController(MembreRepository membreRepository,
|
||||
MembreService membreService,
|
||||
BCryptPasswordEncoder passwordEncoder) {
|
||||
this.membreRepository = membreRepository;
|
||||
this.membreService = membreService;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rechercher tous les membres
|
||||
* @return
|
||||
* http://localhost:8088/membres/all
|
||||
*
|
||||
* @return http://localhost:8088/membres/all
|
||||
*/
|
||||
@GetMapping(value = "/all")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> getAllMembres(){
|
||||
public ResponseEntity<?> getAllMembres() {
|
||||
List<Membre> listeMembres;
|
||||
try
|
||||
{
|
||||
listeMembres = membreRepo.findAll();
|
||||
try {
|
||||
listeMembres = membreRepository.findAll();
|
||||
} catch (Exception e) {
|
||||
MembreNotFoundException commandeNotFoundException = new MembreNotFoundException();
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(commandeNotFoundException.getMessage());
|
||||
|
@ -70,11 +65,11 @@ public class MembreController {
|
|||
|
||||
/**
|
||||
* Rechercher tous les membres admin
|
||||
* @return
|
||||
* http://localhost:8088/membres/admin/all
|
||||
*
|
||||
* @return http://localhost:8088/membres/admin/all
|
||||
*/
|
||||
|
||||
@GetMapping(value="/admin/all")
|
||||
@GetMapping(value = "/admin/all")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public List<MembreDto> getAllAdminUsers() {
|
||||
return membreService.findAllUsers().stream().map(appUser ->
|
||||
|
@ -84,16 +79,16 @@ public class MembreController {
|
|||
|
||||
/**
|
||||
* Rechercher un membre par son Id
|
||||
* @return
|
||||
* http://localhost:8088/membres/1
|
||||
*
|
||||
* @return http://localhost:8088/membres/1
|
||||
*/
|
||||
|
||||
@GetMapping(value="/{id}")
|
||||
@GetMapping(value = "/{id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> getMembreById(@PathVariable int id) {
|
||||
Optional<Membre> membre;
|
||||
try {
|
||||
membre = membreRepo.findById(id);
|
||||
membre = membreRepository.findById(id);
|
||||
if (membre.isPresent()) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(membre);
|
||||
} else {
|
||||
|
@ -107,15 +102,15 @@ public class MembreController {
|
|||
|
||||
/**
|
||||
* Rechercher un membre par l'Id de sa team
|
||||
* @return
|
||||
* http://localhost:8088/membres/1
|
||||
*
|
||||
* @return http://localhost:8088/membres/1
|
||||
*/
|
||||
@GetMapping(value = "team/{team_id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> findByTeamId(@PathVariable int team_id) {
|
||||
List<Membre> membres = null;
|
||||
try {
|
||||
membres = membreRepo.FindMembresByTeam(team_id);
|
||||
membres = membreRepository.FindMembresByTeam(team_id);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
|
@ -124,11 +119,11 @@ public class MembreController {
|
|||
|
||||
/**
|
||||
* Inscription
|
||||
* @return
|
||||
* http://localhost:8088/membres/sign-up
|
||||
*
|
||||
* @return http://localhost:8088/membres/sign-up
|
||||
*/
|
||||
|
||||
@PostMapping(value="/sign-up")
|
||||
@PostMapping(value = "/sign-up")
|
||||
public ResponseEntity<JsonWebToken> signUp(@RequestBody Membre membre) {
|
||||
try {
|
||||
return ResponseEntity.ok(new JsonWebToken(membreService.signup(membre)));
|
||||
|
@ -139,18 +134,18 @@ public class MembreController {
|
|||
|
||||
/**
|
||||
* Ajout d'un membre
|
||||
* @return
|
||||
* http://localhost:8088/membres/add
|
||||
*
|
||||
* @return http://localhost:8088/membres/add/1
|
||||
*/
|
||||
@PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json")
|
||||
@PostMapping(value = "/add/{team_id}", produces = "application/json", consumes = "application/json")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> addMembre(@RequestBody Membre membre, @PathVariable Integer team_id){
|
||||
public ResponseEntity<?> addMembre(@RequestBody Membre membre, @PathVariable Integer team_id) {
|
||||
Membre resultMembre = null;
|
||||
try{
|
||||
try {
|
||||
Team team = new Team();
|
||||
team.setId(team_id);
|
||||
membre.setTeam(team);
|
||||
//resultMembre = membreRepo.saveAndFlush(membre);
|
||||
//resultMembre = membreRepository.saveAndFlush(membre);
|
||||
return ResponseEntity.ok(new JsonWebToken(membreService.signup(membre)));
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
|
@ -160,24 +155,26 @@ public class MembreController {
|
|||
}
|
||||
|
||||
/**
|
||||
* Modifier une commande par son Id
|
||||
* @return
|
||||
* http://localhost:8088/membres/update/1
|
||||
* Modifier un membre par son Id
|
||||
*
|
||||
* @return http://localhost:8088/membres/update/1
|
||||
*/
|
||||
@PutMapping("/update/{id}")
|
||||
@PutMapping("/update/{team_id}/{id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> updateMembre(@RequestBody Membre membre, @PathVariable int id){
|
||||
public ResponseEntity<?> updateMembre(@RequestBody Membre membre, @PathVariable int id, @PathVariable int team_id) {
|
||||
Optional<Membre> membreUpdate;
|
||||
try {
|
||||
membreUpdate = membreRepo.findById(id);
|
||||
membreUpdate = membreRepository.findById(id);
|
||||
// membre trouvé
|
||||
if(membreUpdate.isPresent()){
|
||||
membre.setId(membreUpdate.get().getId());
|
||||
membreRepo.save(membre);
|
||||
if (membreUpdate.isPresent()) {
|
||||
membre.setId(membreRepository.findById(id).get().getId());
|
||||
Team team = new Team();
|
||||
team.setId(team_id);
|
||||
membre.setTeam(team);
|
||||
membreRepository.save(membre);
|
||||
}
|
||||
//membre inconnu
|
||||
else{
|
||||
else {
|
||||
MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id);
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(membreNotFoundException.getMessage());
|
||||
}
|
||||
|
@ -191,15 +188,15 @@ public class MembreController {
|
|||
|
||||
/**
|
||||
* Supprimer un membre par son Id
|
||||
* @return
|
||||
* http://localhost:8088/membres/delete/1
|
||||
*
|
||||
* @return http://localhost:8088/membres/delete/1
|
||||
*/
|
||||
@DeleteMapping(value = "/delete/{id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> deleteMembre(@PathVariable int id){
|
||||
public ResponseEntity<?> deleteMembre(@PathVariable int id) {
|
||||
try {
|
||||
membreRepo.getById(id);
|
||||
membreRepo.deleteById(id);
|
||||
membreRepository.getById(id);
|
||||
membreRepository.deleteById(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Membre supprimé !");
|
||||
} catch (Exception e) {
|
||||
MembreNotFoundException membreNotFoundException = new MembreNotFoundException(id);
|
||||
|
@ -219,16 +216,14 @@ public class MembreController {
|
|||
}
|
||||
|
||||
/********************* Gestion Mot de Passe ************************************/
|
||||
//cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas
|
||||
@PostMapping("/forgot-password")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> findUserByEmail(@RequestBody Membre membre) {
|
||||
Membre resultMembre = null;
|
||||
try {
|
||||
resultMembre = membreRepo.chercheEmail(membre.getEmail());
|
||||
resultMembre = membreRepository.chercheEmail(membre.getEmail());
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
resultMembre.setPassword(uuid);
|
||||
membreRepo.saveAndFlush(resultMembre);
|
||||
membreRepository.saveAndFlush(resultMembre);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(uuid);
|
||||
} catch (EntityNotFoundException e) {
|
||||
|
||||
|
@ -238,13 +233,12 @@ public class MembreController {
|
|||
}
|
||||
|
||||
@PutMapping("/reset-password/{uuid}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> updatePassword(@RequestBody Membre membre, @PathVariable String uuid) throws Exception {
|
||||
Membre resultMembre = null;
|
||||
try {
|
||||
resultMembre = membreRepo.findByUUID(uuid);
|
||||
resultMembre = membreRepository.findByUUID(uuid);
|
||||
resultMembre.setPassword(passwordEncoder.encode(membre.getPassword()));
|
||||
membreRepo.saveAndFlush(resultMembre);
|
||||
membreRepository.saveAndFlush(resultMembre);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class MenuController {
|
|||
}
|
||||
|
||||
//Mise a jour d'un menu par son ID
|
||||
@PutMapping("/update/{team_id}/{id}")
|
||||
@PutMapping(value="/update/{team_id}/{id}", produces="application/json", consumes= "application/json")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> updateMenu(@RequestBody Menu menu, @PathVariable Integer team_id, @PathVariable Integer id) throws Exception {
|
||||
Menu resultMenu = null;
|
||||
|
|
|
@ -2,43 +2,41 @@ package fr.organizee.controller;
|
|||
|
||||
import fr.organizee.model.Team;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/* toto */
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("/teams")
|
||||
@RestController
|
||||
public class TeamController {
|
||||
|
||||
@Autowired
|
||||
private TeamRepository teamRepo;
|
||||
private TeamRepository teamRepository;
|
||||
|
||||
// @RequestMapping("/teams")
|
||||
@ResponseBody
|
||||
public String home()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("<h1>Affichages des teams</h1>");
|
||||
sb.append("<ul><li><a href='http://localhost:8080/teams/all'>Liste des <strong>teams</strong></a></li>");
|
||||
return sb.toString();
|
||||
/**
|
||||
* Contrôleur Team
|
||||
*/
|
||||
public TeamController(TeamRepository teamRepository) {
|
||||
this.teamRepository = teamRepository;
|
||||
}
|
||||
|
||||
// Récupération de toutes les teams
|
||||
|
||||
/**
|
||||
* Rechercher toutes les teams
|
||||
*
|
||||
* @return http://localhost:8088/teams/all
|
||||
*/
|
||||
@GetMapping(value = "/all")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> getAllTeam(){
|
||||
public ResponseEntity<?> getAllTeam() {
|
||||
List<Team> liste = null;
|
||||
try
|
||||
{
|
||||
liste = teamRepo.findAll();
|
||||
try {
|
||||
liste = teamRepository.findAll();
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
|
@ -46,13 +44,18 @@ public class TeamController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Rechercher une team par son Id
|
||||
*
|
||||
* @return http://localhost:8088/teams/1
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> findTeamById(@PathVariable int id){
|
||||
public ResponseEntity<?> findTeamById(@PathVariable int id) {
|
||||
Optional<Team> liste = null;
|
||||
try
|
||||
{
|
||||
liste = teamRepo.findById(id);
|
||||
try {
|
||||
liste = teamRepository.findById(id);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
|
@ -60,12 +63,17 @@ public class TeamController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||
}
|
||||
|
||||
@PostMapping(value="/add", produces="application/json", consumes="application/json")
|
||||
/**
|
||||
* Création d'une team
|
||||
*
|
||||
* @return http://localhost:8088/teams/add
|
||||
*/
|
||||
@PostMapping(value = "/add", produces = "application/json", consumes = "application/json")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> addTeam(@RequestBody Team team){
|
||||
public ResponseEntity<?> addTeam(@RequestBody Team team) {
|
||||
Team resultTeam = null;
|
||||
try {
|
||||
resultTeam = teamRepo.saveAndFlush(team);
|
||||
resultTeam = teamRepository.saveAndFlush(team);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
}
|
||||
|
@ -73,12 +81,17 @@ public class TeamController {
|
|||
return ResponseEntity.status(HttpStatus.CREATED).body(resultTeam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifier une teamm par son Id
|
||||
*
|
||||
* @return http://localhost:8088/teams/update/1
|
||||
*/
|
||||
@PutMapping("/update/{id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> updateTeam(@RequestBody Team team, @PathVariable Integer id) throws Exception {
|
||||
Team resultTeam = null;
|
||||
try {
|
||||
resultTeam = teamRepo.save(team);
|
||||
resultTeam = teamRepository.save(team);
|
||||
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
||||
|
@ -87,12 +100,17 @@ public class TeamController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(resultTeam);
|
||||
}
|
||||
|
||||
/**
|
||||
* Supprimer une team par son Id
|
||||
*
|
||||
* @return http://localhost:8088/teams/delete/1
|
||||
*/
|
||||
@DeleteMapping(value = "/delete/{id}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> deleteTeam(@PathVariable int id){
|
||||
public ResponseEntity<?> deleteTeam(@PathVariable int id) {
|
||||
try {
|
||||
teamRepo.delete(teamRepo.getById(id));
|
||||
//membreRepo.deleteById(id);
|
||||
teamRepository.delete(teamRepository.getById(id));
|
||||
//membreRepository.deleteById(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Team effacée !");
|
||||
|
||||
} catch (EntityNotFoundException e) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package fr.organizee.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.sun.istack.NotNull;
|
||||
import org.hibernate.annotations.SQLDelete;
|
||||
import org.hibernate.annotations.Where;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDate;
|
||||
|
@ -10,6 +11,9 @@ import java.util.List;
|
|||
|
||||
|
||||
@Entity
|
||||
@Table(name = "membre")
|
||||
@SQLDelete(sql = "UPDATE membre SET deleted = true WHERE id=?")
|
||||
@Where(clause = "deleted=false")
|
||||
public class Membre {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
@ -33,14 +37,14 @@ public class Membre {
|
|||
private String isAdmin;
|
||||
private String couleur;
|
||||
private String smiley;
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name="TEAM_ID")
|
||||
// @JsonIgnore
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JoinColumn(name = "TEAM_ID")
|
||||
@JsonIgnoreProperties("membre")
|
||||
private Team team;
|
||||
|
||||
private boolean deleted = Boolean.FALSE;
|
||||
|
||||
public Membre() {
|
||||
}
|
||||
|
||||
|
@ -52,56 +56,77 @@ public class Membre {
|
|||
this.email = email;
|
||||
this.password = password;
|
||||
this.team = team;
|
||||
this.roleList=roleList;
|
||||
this.roleList = roleList;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
public String getCouleur() {
|
||||
return couleur;
|
||||
}
|
||||
public void setCouleur(String couleur) {
|
||||
this.couleur = couleur;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getCouleur() {
|
||||
return couleur;
|
||||
}
|
||||
|
||||
public void setCouleur(String couleur) {
|
||||
this.couleur = couleur;
|
||||
}
|
||||
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public LocalDate getDateNaissance() {
|
||||
return dateNaissance;
|
||||
}
|
||||
|
||||
public void setDateNaissance(LocalDate dateNaissance) {
|
||||
this.dateNaissance = dateNaissance;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getIsAdmin() {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public void setIsAdmin(String isAdmin) {
|
||||
this.isAdmin = isAdmin;
|
||||
}
|
||||
|
@ -109,6 +134,7 @@ public class Membre {
|
|||
public Team getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void setTeam(Team team) {
|
||||
this.team = team;
|
||||
}
|
||||
|
@ -116,6 +142,7 @@ public class Membre {
|
|||
public List<Role> getRoleList() {
|
||||
return roleList;
|
||||
}
|
||||
|
||||
public void setRoleList(List<Role> roleList) {
|
||||
this.roleList = roleList;
|
||||
}
|
||||
|
@ -135,5 +162,4 @@ public class Membre {
|
|||
/*", team=" + team +*/
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,7 @@ public class Menu {
|
|||
private String repasSoir;
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JsonIgnoreProperties({"menu","membre"})
|
||||
@JsonIgnoreProperties({"menu"})
|
||||
private Team team;
|
||||
|
||||
public Menu() {
|
||||
|
|
|
@ -8,8 +8,7 @@ import org.springframework.security.core.GrantedAuthority;
|
|||
public enum Role implements GrantedAuthority {
|
||||
|
||||
ROLE_PARENT, ROLE_ENFANT;
|
||||
|
||||
@Override
|
||||
|
||||
public String getAuthority() {
|
||||
return name();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
@Repository
|
||||
public interface MenuRepository extends JpaRepository <Menu, Integer> {
|
||||
|
||||
@Query(value = "select * from menu where team_id = :team_id", nativeQuery = true)
|
||||
@Query(value = "select * from menu where team_id = :team_id order by date_menu ASC", nativeQuery = true)
|
||||
List<Menu> FindMenusByTeam(@Param("team_id") int team_id);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package fr.organizee.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import fr.organizee.exception.ExistingUsernameException;
|
||||
import fr.organizee.exception.InvalidCredentialsException;
|
||||
import fr.organizee.model.Membre;
|
||||
import fr.organizee.repository.MembreRepository;
|
||||
import fr.organizee.security.JwtTokenProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
@ -10,11 +12,8 @@ import org.springframework.security.core.AuthenticationException;
|
|||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import fr.organizee.exception.ExistingUsernameException;
|
||||
import fr.organizee.exception.InvalidCredentialsException;
|
||||
import fr.organizee.model.Membre;
|
||||
import fr.organizee.repository.MembreRepository;
|
||||
import fr.organizee.security.JwtTokenProvider;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class
|
||||
|
@ -27,7 +26,7 @@ MembreServiceImpl implements MembreService {
|
|||
private BCryptPasswordEncoder passwordEncoder; // permet l'encodage du mot de passe
|
||||
|
||||
@Autowired
|
||||
private JwtTokenProvider jwtTokenProvider; // permet la fourniture du Jeton (Token)
|
||||
private JwtTokenProvider jwtTokenProvider; // permet la fourniture du Jeton (Token)
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager; // gestionnaire d'authentification
|
||||
|
@ -59,6 +58,7 @@ MembreServiceImpl implements MembreService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Membre> findAllUsers() {
|
||||
return membreRepository.findAll();
|
||||
|
@ -80,5 +80,4 @@ MembreServiceImpl implements MembreService {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue