Merge branch 'dev' of https://github.com/HediMjid/Organizee into aline
This commit is contained in:
commit
0f55e66702
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@ -7,6 +7,7 @@
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="Organizee" />
|
||||
<module name="organizee" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
|
@ -1,10 +1,7 @@
|
||||
package fr.organizee.controller;
|
||||
|
||||
import fr.organizee.model.Contact;
|
||||
import fr.organizee.model.Membre;
|
||||
import fr.organizee.model.Team;
|
||||
import fr.organizee.repository.ContactRepository;
|
||||
import fr.organizee.repository.TeamRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -0,0 +1,37 @@
|
||||
package fr.organizee.controller;
|
||||
|
||||
import fr.organizee.model.Evenement;
|
||||
import fr.organizee.model.Membre;
|
||||
import fr.organizee.model.Team;
|
||||
import fr.organizee.repository.EvenementRepository;
|
||||
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.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
@RequestMapping("/evenements")
|
||||
public class EvenementController {
|
||||
|
||||
@Autowired
|
||||
private EvenementRepository evenementRepo;
|
||||
|
||||
// Recupérer tout les evenements pour une team {id}
|
||||
@GetMapping(value = "/all/{id}")
|
||||
public ResponseEntity<?> getAll(){
|
||||
List<Evenement> liste = null;
|
||||
try
|
||||
{
|
||||
liste = evenementRepo.findAll();
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||
}
|
||||
}
|
@ -5,14 +5,13 @@ import fr.organizee.dto.MembreDto;
|
||||
import fr.organizee.exception.ExistingUsernameException;
|
||||
import fr.organizee.exception.InvalidCredentialsException;
|
||||
import fr.organizee.model.Membre;
|
||||
//import fr.organizee.model.Team;
|
||||
import fr.organizee.repository.MembreRepository;
|
||||
//import fr.organizee.repository.TeamRepository;
|
||||
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;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
@ -32,10 +31,9 @@ public class MembreController {
|
||||
@Autowired
|
||||
private MembreService membreService;
|
||||
|
||||
// @Autowired
|
||||
// private TeamRepository teamRepo;
|
||||
@Autowired
|
||||
private BCryptPasswordEncoder passwordEncoder;
|
||||
|
||||
// @RequestMapping("/membres")
|
||||
@ResponseBody
|
||||
public String home()
|
||||
{
|
||||
@ -45,6 +43,7 @@ public class MembreController {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// Récupère tout les membres de la base
|
||||
@GetMapping(value = "/all")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> getAll(){
|
||||
@ -65,22 +64,49 @@ public class MembreController {
|
||||
return membreService.findAllUsers().stream().map(appUser -> new MembreDto(appUser.getEmail(), appUser.getRoleList())).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
//cette methode ne fonctionne pas parce que ça affiche "trouvé" dans tous les cas
|
||||
@GetMapping("/forgot-password")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> findUserByEmail(@RequestBody Membre findUserByEmail) {
|
||||
|
||||
// @GetMapping(value = "/team/all")
|
||||
// public ResponseEntity<?> getAllTeam(){
|
||||
// List<Team> liste = null;
|
||||
// try
|
||||
// {
|
||||
// liste = teamRepo.findAll();
|
||||
// } catch (Exception e) {
|
||||
// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
// }
|
||||
//
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||
// }
|
||||
try {
|
||||
this.membreService.findUserByEmail(findUserByEmail);
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Email trouvé !");
|
||||
|
||||
} catch (EntityNotFoundException e) {
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Email introuvable !");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PutMapping("/reset-password/{email}")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
|
||||
public ResponseEntity<?> updatePassword(@RequestBody String password, @PathVariable String email) throws Exception {
|
||||
Membre resultMembre;
|
||||
try {
|
||||
resultMembre = this.membreService.chercheEmail(email);
|
||||
|
||||
System.out.println(resultMembre);
|
||||
|
||||
resultMembre.setPassword(passwordEncoder.encode(password));
|
||||
|
||||
System.out.println(password);
|
||||
|
||||
this.membreRepo.save(resultMembre);
|
||||
System.out.println(resultMembre.getPassword());
|
||||
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(resultMembre);
|
||||
}
|
||||
|
||||
|
||||
//Récupérer les informations d'un membre par son 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){
|
||||
Optional<Membre> membre = null;
|
||||
try
|
||||
@ -93,15 +119,9 @@ public class MembreController {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(membre);
|
||||
}
|
||||
|
||||
// @GetMapping(value = "/membres/delete/{id}")
|
||||
// public void deleteMembreId(@PathVariable("id") Integer id) {
|
||||
//
|
||||
// membreRepo.deleteById(id);
|
||||
//
|
||||
// }
|
||||
|
||||
//Efface un membre par son ID
|
||||
@DeleteMapping(value = "/delete/{id}")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> deleteMembre(@PathVariable int id){
|
||||
try {
|
||||
membreRepo.delete(membreRepo.getById(id));
|
||||
@ -114,6 +134,7 @@ public class MembreController {
|
||||
}
|
||||
}
|
||||
|
||||
//Ajouter un membre et inscription
|
||||
@PostMapping("/sign-up")
|
||||
public ResponseEntity<JsonWebToken> signUp(@RequestBody Membre membre) {
|
||||
try {
|
||||
@ -123,6 +144,7 @@ public class MembreController {
|
||||
}
|
||||
}
|
||||
|
||||
//Login
|
||||
@PostMapping("/sign-in")
|
||||
public ResponseEntity<JsonWebToken> signIn(@RequestBody Membre membre) {
|
||||
try {
|
||||
@ -132,8 +154,9 @@ public class MembreController {
|
||||
}
|
||||
}
|
||||
|
||||
//Met a jour les informations d'un membre par son ID
|
||||
@PutMapping("/update/{id}")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> updateMembre(@RequestBody Membre membre, @PathVariable Integer id) throws Exception {
|
||||
Membre resultMembre = null;
|
||||
try {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package fr.organizee.controller;
|
||||
|
||||
import fr.organizee.model.Contact;
|
||||
import fr.organizee.model.Menu;
|
||||
import fr.organizee.repository.MenuRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -21,8 +20,9 @@ public class MenuController {
|
||||
@Autowired
|
||||
private MenuRepository menuRepository;
|
||||
|
||||
//Récupère les infos d'un menu par son 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){
|
||||
Optional<Menu> menu = null;
|
||||
try
|
||||
@ -35,8 +35,9 @@ public class MenuController {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(menu);
|
||||
}
|
||||
|
||||
//Récupère les infos des menus par la 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) {
|
||||
List<Menu> menus = null;
|
||||
try {
|
||||
@ -47,8 +48,9 @@ public class MenuController {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(menus);
|
||||
}
|
||||
|
||||
//Ajoute un nouveau menu
|
||||
@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){
|
||||
Menu resultMenu = null;
|
||||
try {
|
||||
@ -60,8 +62,9 @@ public class MenuController {
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(resultMenu);
|
||||
}
|
||||
|
||||
//Mise a jour d'un menu par son ID
|
||||
@PutMapping("/update/{id}")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> updateMenu(@RequestBody Menu menu, @PathVariable Integer id) throws Exception {
|
||||
Menu resultMenu = null;
|
||||
try {
|
||||
@ -71,11 +74,12 @@ public class MenuController {
|
||||
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}")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> deleteMenu(@PathVariable int id){
|
||||
try {
|
||||
menuRepository.delete(menuRepository.getById(id));
|
||||
|
103
src/main/java/fr/organizee/controller/TacheController.java
Normal file
103
src/main/java/fr/organizee/controller/TacheController.java
Normal file
@ -0,0 +1,103 @@
|
||||
package fr.organizee.controller;
|
||||
|
||||
import fr.organizee.model.Tache;
|
||||
import fr.organizee.repository.TacheRepository;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin("*")
|
||||
@RequestMapping("/taches")
|
||||
public class TacheController {
|
||||
@Autowired
|
||||
private TacheRepository tacheRepo;
|
||||
|
||||
// Récupère toutes les taches de toutes la base toutes team confondu
|
||||
@GetMapping(value = "/all")
|
||||
public ResponseEntity<?> getAll(){
|
||||
List<Tache> liste = null;
|
||||
try
|
||||
{
|
||||
liste = tacheRepo.findAll();
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(liste);
|
||||
}
|
||||
|
||||
// Récupère les infos d'une tache avec son ID
|
||||
@GetMapping(value = "/{id}")
|
||||
public ResponseEntity<?> findById(@PathVariable int id){
|
||||
Optional<Tache> tache = null;
|
||||
try
|
||||
{
|
||||
tache = tacheRepo.findById(id);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(tache);
|
||||
}
|
||||
|
||||
// Efface une tache avec son ID
|
||||
@DeleteMapping(value = "/delete/{id}")
|
||||
public ResponseEntity<?> deleteTache(@PathVariable int id){
|
||||
try {
|
||||
tacheRepo.delete(tacheRepo.getById(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Tache effacée !");
|
||||
|
||||
} catch (EntityNotFoundException e) {
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body("Tache introuvable !");
|
||||
}
|
||||
}
|
||||
|
||||
// Ajoute une tache
|
||||
@PostMapping(value="/add", produces="application/json", consumes="application/json")
|
||||
public ResponseEntity<?> addTache(@RequestBody Tache tache){
|
||||
Tache resultTache = null;
|
||||
try {
|
||||
resultTache = tacheRepo.saveAndFlush(tache);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(resultTache);
|
||||
}
|
||||
|
||||
//Met a jour les informations d'une date avec son ID
|
||||
@PutMapping("/update/{id}")
|
||||
public ResponseEntity<?> updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception {
|
||||
Tache resultTache = null;
|
||||
try {
|
||||
resultTache = tacheRepo.save(tache);
|
||||
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import fr.organizee.model.Membre;
|
||||
import fr.organizee.model.Team;
|
||||
import fr.organizee.repository.TeamRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -34,7 +33,7 @@ public class TeamController {
|
||||
|
||||
// Récupération de toutes les teams
|
||||
@GetMapping(value = "/all")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> getAllTeam(){
|
||||
List<Team> liste = null;
|
||||
try
|
||||
@ -48,7 +47,7 @@ public class TeamController {
|
||||
}
|
||||
|
||||
@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){
|
||||
Optional<Team> liste = null;
|
||||
try
|
||||
@ -62,7 +61,7 @@ public class TeamController {
|
||||
}
|
||||
|
||||
@PostMapping(value="/add", produces="application/json", consumes="application/json")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> addTeam(@RequestBody Team team){
|
||||
Team resultTeam = null;
|
||||
try {
|
||||
@ -75,7 +74,7 @@ public class TeamController {
|
||||
}
|
||||
|
||||
@PutMapping("/update/{id}")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> updateTeam(@RequestBody Team team, @PathVariable Integer id) throws Exception {
|
||||
Team resultTeam = null;
|
||||
try {
|
||||
@ -89,7 +88,7 @@ public class TeamController {
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/delete/{id}")
|
||||
@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
//@PreAuthorize("hasRole('ROLE_PARENT')")
|
||||
public ResponseEntity<?> deleteTeam(@PathVariable int id){
|
||||
try {
|
||||
teamRepo.delete(teamRepo.getById(id));
|
||||
|
@ -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 adresse;
|
||||
private LocalDate dateNaissance;
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JsonIgnoreProperties("contact")
|
||||
private Team team;
|
||||
|
107
src/main/java/fr/organizee/model/Evenement.java
Normal file
107
src/main/java/fr/organizee/model/Evenement.java
Normal file
@ -0,0 +1,107 @@
|
||||
package fr.organizee.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Entity
|
||||
public class Evenement {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private LocalDateTime eventDebut;
|
||||
private LocalDateTime eventFin;
|
||||
private int allDay;
|
||||
private String libelle;
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@JoinColumn(name="MEMBRE_ID")
|
||||
@JsonIgnoreProperties("evenement")
|
||||
private Membre membre;
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JsonIgnoreProperties("evenement")
|
||||
private Team team;
|
||||
|
||||
public Evenement() {
|
||||
}
|
||||
|
||||
public Evenement(int id, LocalDateTime eventDebut, LocalDateTime eventFin, int allDay, String libelle, Membre membre, Team team) {
|
||||
this.id = id;
|
||||
this.eventDebut = eventDebut;
|
||||
this.eventFin = eventFin;
|
||||
this.allDay = allDay;
|
||||
this.libelle = libelle;
|
||||
this.membre = membre;
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalDateTime getEventDebut() {
|
||||
return eventDebut;
|
||||
}
|
||||
|
||||
public void setEventDebut(LocalDateTime eventDebut) {
|
||||
this.eventDebut = eventDebut;
|
||||
}
|
||||
|
||||
public LocalDateTime getEventFin() {
|
||||
return eventFin;
|
||||
}
|
||||
|
||||
public void setEventFin(LocalDateTime eventFin) {
|
||||
this.eventFin = eventFin;
|
||||
}
|
||||
|
||||
public int getAllDay() {
|
||||
return allDay;
|
||||
}
|
||||
|
||||
public void setAllDay(int allDay) {
|
||||
this.allDay = allDay;
|
||||
}
|
||||
|
||||
public String getLibelle() {
|
||||
return libelle;
|
||||
}
|
||||
|
||||
public void setLibelle(String libelle) {
|
||||
this.libelle = libelle;
|
||||
}
|
||||
|
||||
public Membre getMembre() {
|
||||
return membre;
|
||||
}
|
||||
|
||||
public void setMembre(Membre membre) {
|
||||
this.membre = membre;
|
||||
}
|
||||
|
||||
public Team getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void setTeam(Team team) {
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Evenement{" +
|
||||
"id=" + id +
|
||||
", eventDebut=" + eventDebut +
|
||||
", eventFin=" + eventFin +
|
||||
", allDay=" + allDay +
|
||||
", libelle='" + libelle + '\'' +
|
||||
", membre=" + membre +
|
||||
", team=" + team +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -33,10 +33,10 @@ public class Membre {
|
||||
private String isAdmin;
|
||||
private String couleur;
|
||||
private String smiley;
|
||||
// @ManyToOne
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name="TEAM_ID")
|
||||
// @JsonIgnore
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JsonIgnoreProperties("membre")
|
||||
private Team team;
|
||||
@ -44,24 +44,17 @@ public class Membre {
|
||||
public Membre() {
|
||||
}
|
||||
|
||||
public Membre(String nom, String prenom, LocalDate dateNaissance, @NotNull String email, @NotNull String password, String isAdmin, String couleur, String smiley, Team team, List<Role> roleList) {
|
||||
public Membre(String nom, String prenom, String couleur, LocalDate dateNaissance, Team team, @NotNull String email, @NotNull String password, List<Role> roleList) {
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.couleur = couleur;
|
||||
this.dateNaissance = dateNaissance;
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.isAdmin = isAdmin;
|
||||
this.couleur = couleur;
|
||||
this.smiley = smiley;
|
||||
this.team = team;
|
||||
this.roleList=roleList;
|
||||
}
|
||||
|
||||
public Membre(@NotNull String email, @NotNull String password, List<Role> roleList) {
|
||||
this.email = email;
|
||||
this.password = password;
|
||||
this.roleList=roleList;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
@ -73,6 +66,12 @@ public class Membre {
|
||||
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;
|
||||
}
|
||||
@ -114,22 +113,6 @@ public class Membre {
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
public String getCouleur() {
|
||||
return couleur;
|
||||
}
|
||||
|
||||
public void setCouleur(String couleur) {
|
||||
this.couleur = couleur;
|
||||
}
|
||||
|
||||
public String getSmiley() {
|
||||
return smiley;
|
||||
}
|
||||
|
||||
public void setSmiley(String smiley) {
|
||||
this.smiley = smiley;
|
||||
}
|
||||
|
||||
public List<Role> getRoleList() {
|
||||
return roleList;
|
||||
}
|
||||
|
@ -13,20 +13,19 @@ public class Menu {
|
||||
private String libelle;
|
||||
private LocalDate dateMenu;
|
||||
private int validationProposition;
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JsonIgnoreProperties("menu")
|
||||
private Team team;
|
||||
@ManyToOne
|
||||
private Membre membre;
|
||||
|
||||
public Menu() {
|
||||
}
|
||||
|
||||
public Menu(String libelle, LocalDate dateMenu, int validationProposition) {
|
||||
public Menu(String libelle, LocalDate dateMenu, int validationProposition, Team team) {
|
||||
this.libelle = libelle;
|
||||
this.dateMenu = dateMenu;
|
||||
this.validationProposition=validationProposition;
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
@ -53,12 +52,30 @@ public class Menu {
|
||||
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
|
||||
public String toString() {
|
||||
return "Menu{" +
|
||||
"id=" + id +
|
||||
", libelle='" + libelle + '\'' +
|
||||
", dateMenu=" + dateMenu +
|
||||
", validationProposition=" + validationProposition +
|
||||
", team=" + team +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ public class Tache {
|
||||
private int id;
|
||||
private String texte;
|
||||
private Boolean etat;
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TODOLIST_ID")
|
||||
@JsonIgnoreProperties("tache")
|
||||
private TodoList todolist;
|
||||
|
@ -12,16 +12,16 @@ public class Team {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private String nom;
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JsonIgnoreProperties("team")
|
||||
private List<Membre> membres = new ArrayList<>();
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JsonIgnoreProperties("team")
|
||||
private List<Contact> contacts = new ArrayList<>();
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JsonIgnoreProperties("team")
|
||||
private List<TodoList> todolists = new ArrayList<>();
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY)
|
||||
@OneToMany(mappedBy = "team", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JsonIgnoreProperties("team")
|
||||
private List<Menu> menus = new ArrayList<>();
|
||||
|
||||
|
@ -12,10 +12,13 @@ public class TodoList {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private int id;
|
||||
private String nom;
|
||||
@ManyToOne(cascade = CascadeType.MERGE)
|
||||
@ManyToOne
|
||||
@JoinColumn(name="TEAM_ID")
|
||||
@JsonIgnoreProperties("todolist")
|
||||
private Team team;
|
||||
@OneToMany(mappedBy = "todolist", fetch=FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JsonIgnoreProperties("todolist")
|
||||
private List<Tache> taches = new ArrayList<>();
|
||||
|
||||
public TodoList() {
|
||||
}
|
||||
@ -40,11 +43,26 @@ public class TodoList {
|
||||
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
|
||||
public String toString() {
|
||||
return "TodoList{" +
|
||||
"id=" + id +
|
||||
", nom='" + nom + '\'' +
|
||||
'}';
|
||||
", nom='" + nom + ", taches='" + taches + "}";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package fr.organizee.repository;
|
||||
|
||||
import fr.organizee.model.Evenement;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EvenementRepository extends JpaRepository<Evenement, Integer> {
|
||||
}
|
@ -1,9 +1,13 @@
|
||||
package fr.organizee.repository;
|
||||
|
||||
import fr.organizee.model.Contact;
|
||||
import fr.organizee.model.Membre;
|
||||
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 java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@ -12,7 +16,12 @@ public interface MembreRepository extends JpaRepository<Membre, Integer> {
|
||||
|
||||
Optional<Membre> findByEmail(String email);
|
||||
|
||||
@Query(value = "select * from membre where email = :email", nativeQuery = true)
|
||||
Membre chercheEmail(@Param("email") String email);
|
||||
|
||||
boolean existsByEmail(String email);
|
||||
|
||||
void deleteByEmail(String email);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,17 @@
|
||||
package fr.organizee.repository;
|
||||
|
||||
public interface TacheRepository {
|
||||
import fr.organizee.model.Tache;
|
||||
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 java.util.List;
|
||||
|
||||
@Repository
|
||||
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;
|
||||
|
||||
import fr.organizee.model.Menu;
|
||||
import fr.organizee.model.TodoList;
|
||||
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 java.util.List;
|
||||
|
||||
@Repository
|
||||
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);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import fr.organizee.model.Membre;
|
||||
public interface MembreService {
|
||||
|
||||
/**
|
||||
* Methode qui permet à un utilisateur de se connecter.
|
||||
* Methode qui permet à un utilisateur de se connecter.
|
||||
* @param email : nom de l'utilisateur.
|
||||
* @param password : mot de passe de l'utilisateur.
|
||||
* @returnun JWT si credentials est valide, throws InvalidCredentialsException otherwise.
|
||||
@ -24,11 +24,12 @@ public interface MembreService {
|
||||
/**
|
||||
* Methode qui permet de s'inscrire.
|
||||
* @param membre nouvel utilisateur.
|
||||
* @return un JWT si user n'existe pas déjà !
|
||||
* @return un JWT si user n'existe pas déjà !
|
||||
* @throws ExistingUsernameException
|
||||
*/
|
||||
String signup(Membre membre) throws ExistingUsernameException;
|
||||
|
||||
|
||||
/**
|
||||
* Methode qui retourne tous les utilisateurs de la bd
|
||||
* @return the list of all application users.
|
||||
@ -36,10 +37,14 @@ public interface MembreService {
|
||||
List<Membre> findAllUsers();
|
||||
|
||||
/**
|
||||
* Methode qui retourne un utilisateur à partir de son username
|
||||
* Methode qui retourne un utilisateur à partir de son username
|
||||
* @param email the username to look for.
|
||||
* @return an Optional object containing user if found, empty otherwise.
|
||||
*/
|
||||
Optional<Membre> findUserByEmail(String email);
|
||||
Optional<Membre> findUserByEmail(Membre membre);
|
||||
Optional<Membre> findByEmail(String email);
|
||||
|
||||
Membre chercheEmail(String email);
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class MembreServiceImpl implements MembreService {
|
||||
@Override
|
||||
public String signup(Membre membre) throws ExistingUsernameException {
|
||||
if (!membreRepository.existsByEmail(membre.getEmail())) {
|
||||
Membre membreToSave = new Membre(membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList());
|
||||
Membre membreToSave = new Membre(membre.getNom(), membre.getPrenom(), membre.getCouleur(), membre.getDateNaissance(), membre.getTeam(), membre.getEmail(), passwordEncoder.encode(membre.getPassword()), membre.getRoleList());
|
||||
membreRepository.save(membreToSave);
|
||||
return jwtTokenProvider.createToken(membre.getEmail(), membre.getRoleList());
|
||||
} else {
|
||||
@ -62,8 +62,20 @@ public class MembreServiceImpl implements MembreService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Membre> findUserByEmail(String email) {
|
||||
return membreRepository.findByEmail(email);
|
||||
public Optional<Membre> findUserByEmail(Membre membre) {
|
||||
return this.membreRepository.findByEmail(membre.getEmail());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Membre> findByEmail(String email) {
|
||||
return this.membreRepository.findByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Membre chercheEmail(String email) {
|
||||
return this.membreRepository.chercheEmail(email);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user