diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index c75fd2a..a500b21 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -7,6 +7,7 @@
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 06e8b35..2289c27 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,4 +11,7 @@
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index dbaf653..6704f63 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,12 +2,7 @@
4.0.0
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.6.1
-
-
+
fr.organizee
organizee
0.0.1-SNAPSHOT
@@ -16,6 +11,12 @@
11
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.1
+
+
org.springframework.boot
@@ -38,7 +39,10 @@
org.springframework.boot
spring-boot-starter-web
-
+
+ org.springframework.boot
+ spring-boot-starter-mail
+
mysql
mysql-connector-java
diff --git a/src/main/java/fr/organizee/controller/ContactController.java b/src/main/java/fr/organizee/controller/ContactController.java
index 5186d12..e93e926 100644
--- a/src/main/java/fr/organizee/controller/ContactController.java
+++ b/src/main/java/fr/organizee/controller/ContactController.java
@@ -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;
@@ -24,7 +21,7 @@ public class ContactController {
private ContactRepository contactRepo;
@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 contact = null;
try
@@ -38,7 +35,7 @@ public class ContactController {
}
@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 contacts = null;
try
@@ -52,7 +49,7 @@ public class ContactController {
}
@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){
Contact resultContact = null;
try {
@@ -65,7 +62,7 @@ public class ContactController {
}
@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 {
Contact resultContact = null;
try {
@@ -79,7 +76,7 @@ public class ContactController {
}
@DeleteMapping(value = "/delete/{id}")
- @PreAuthorize("hasRole('ROLE_PARENT')")
+ //@PreAuthorize("hasRole('ROLE_PARENT')")
public ResponseEntity> deleteContact(@PathVariable int id){
try {
contactRepo.delete(contactRepo.getById(id));
diff --git a/src/main/java/fr/organizee/controller/EvenementController.java b/src/main/java/fr/organizee/controller/EvenementController.java
new file mode 100644
index 0000000..f6a32a8
--- /dev/null
+++ b/src/main/java/fr/organizee/controller/EvenementController.java
@@ -0,0 +1,78 @@
+package fr.organizee.controller;
+
+import fr.organizee.model.Evenement;
+import fr.organizee.model.Menu;
+import fr.organizee.repository.EvenementRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.persistence.EntityNotFoundException;
+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 {team_id}
+ @GetMapping(value = "/team/{team_id}")
+ public ResponseEntity> findByTeamId(@PathVariable int team_id){
+ List liste = null;
+ try
+ {
+ liste = evenementRepo.FindEvenementsByTeam(team_id);
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
+ }
+
+ return ResponseEntity.status(HttpStatus.OK).body(liste);
+ }
+
+ // Ajoute un evenement au calendrier
+ @PostMapping(value="/add", produces="application/json", consumes="application/json")
+ public ResponseEntity> addTache(@RequestBody Evenement event){
+ Evenement resultEvent = null;
+ try {
+ resultEvent = evenementRepo.saveAndFlush(event);
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
+ }
+
+ return ResponseEntity.status(HttpStatus.CREATED).body(resultEvent);
+ }
+
+ //Mise a jour d'un evenement par son ID
+ @PutMapping("/update/{id}")
+ //@PreAuthorize("hasRole('ROLE_PARENT')")
+ public ResponseEntity> updateEvenement(@RequestBody Evenement event, @PathVariable Integer id) throws Exception {
+ Evenement resultEvenement = null;
+ try {
+ resultEvenement = evenementRepo.save(event);
+
+ } catch (Exception e) {
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
+ }
+
+ return ResponseEntity.status(HttpStatus.OK).body(resultEvenement);
+ }
+
+ //Efface un evenement par son ID
+ @DeleteMapping(value = "/delete/{id}")
+ //@PreAuthorize("hasRole('ROLE_PARENT')")
+ public ResponseEntity> deleteEvenement(@PathVariable int id){
+ try {
+ evenementRepo.delete(evenementRepo.getById(id));
+ return ResponseEntity.status(HttpStatus.OK).body("Evenement effacé !");
+
+ } catch (EntityNotFoundException e) {
+
+ return ResponseEntity.status(HttpStatus.OK).body("Evenement introuvable !");
+ }
+ }
+}
diff --git a/src/main/java/fr/organizee/controller/MailController.java b/src/main/java/fr/organizee/controller/MailController.java
new file mode 100644
index 0000000..3543668
--- /dev/null
+++ b/src/main/java/fr/organizee/controller/MailController.java
@@ -0,0 +1,43 @@
+package fr.organizee.controller;
+
+import fr.organizee.model.Mail;
+import fr.organizee.service.SendMailService;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.mail.MessagingException;
+
+@RestController
+@RequestMapping("/sendmail")
+public class MailController {
+ SendMailService service;
+
+ public MailController(SendMailService service) {
+ this.service = service;
+ }
+
+ // Envoi de mail en text brut
+ @PostMapping("/text")
+ public ResponseEntity sendMail(@RequestBody Mail mail) {
+ service.sendMail(mail);
+ return new ResponseEntity<>("Email Sent successfully", HttpStatus.OK);
+ }
+
+ // Envoi de mail au format HTML
+ @PostMapping("/html")
+ public ResponseEntity sendMailHTML(@RequestBody Mail mail) throws MessagingException {
+ service.sendMailHTML(mail);
+ return new ResponseEntity<>("HTML mail sent successfully", HttpStatus.OK);
+ }
+
+ // Envoi du mail avec une piece jointe
+ @PostMapping("/attachment")
+ public ResponseEntity sendAttachmentEmail(@RequestBody Mail mail) throws MessagingException {
+ service.sendMailWithAttachments(mail);
+ return new ResponseEntity<>("Attachment mail sent successfully", HttpStatus.OK);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/fr/organizee/controller/MembreController.java b/src/main/java/fr/organizee/controller/MembreController.java
index 0ff9b67..6fd0b3c 100644
--- a/src/main/java/fr/organizee/controller/MembreController.java
+++ b/src/main/java/fr/organizee/controller/MembreController.java
@@ -5,9 +5,7 @@ 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;
@@ -36,10 +34,6 @@ public class MembreController {
@Autowired
private BCryptPasswordEncoder passwordEncoder;
-// @Autowired
-// private TeamRepository teamRepo;
-
-// @RequestMapping("/membres")
@ResponseBody
public String home()
{
@@ -49,8 +43,9 @@ 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')")
+ //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity> getAll(){
List liste = null;
try
@@ -109,21 +104,9 @@ public class MembreController {
}
-// @GetMapping(value = "/team/all")
-// public ResponseEntity> getAllTeam(){
-// List liste = null;
-// try
-// {
-// liste = teamRepo.findAll();
-// } catch (Exception e) {
-// return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
-// }
-//
-// return ResponseEntity.status(HttpStatus.OK).body(liste);
-// }
-
+ //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 = null;
try
@@ -136,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));
@@ -157,6 +134,7 @@ public class MembreController {
}
}
+ //Ajouter un membre et inscription
@PostMapping("/sign-up")
public ResponseEntity signUp(@RequestBody Membre membre) {
try {
@@ -166,6 +144,7 @@ public class MembreController {
}
}
+ //Login
@PostMapping("/sign-in")
public ResponseEntity signIn(@RequestBody Membre membre) {
try {
@@ -175,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 {
diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java
index f4e4ec8..4b18a32 100644
--- a/src/main/java/fr/organizee/controller/MenuController.java
+++ b/src/main/java/fr/organizee/controller/MenuController.java
@@ -1,7 +1,7 @@
package fr.organizee.controller;
-import fr.organizee.model.Contact;
import fr.organizee.model.Menu;
+import fr.organizee.model.Team;
import fr.organizee.repository.MenuRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -21,8 +21,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