This commit is contained in:
Sana EL HIRI 2022-02-18 12:02:04 +01:00
commit 10eea5717b
13 changed files with 59 additions and 32 deletions

3
.idea/misc.xml generated
View File

@ -11,4 +11,7 @@
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project> </project>

13
pom.xml
View File

@ -2,12 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>fr.organizee</groupId> <groupId>fr.organizee</groupId>
<artifactId>organizee</artifactId> <artifactId>organizee</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
@ -16,6 +11,12 @@
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
</properties> </properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

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;

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;

View File

@ -1,6 +1,7 @@
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.repository.MenuRepository; import fr.organizee.repository.MenuRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -49,11 +50,14 @@ public class MenuController {
} }
//Ajoute un nouveau menu //Ajoute un nouveau menu
@PostMapping(value="/add") @PostMapping(value="/add/{team_id}", produces="application/json", consumes= "application/json")
//@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')") //@PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
public ResponseEntity<?> addMenu(@RequestBody Menu menu){ public ResponseEntity<?> addMenu(@RequestBody Menu menu, @PathVariable Integer team_id){
Menu resultMenu = null; Menu resultMenu = null;
try { try {
Team team=new Team();
team.setId(team_id);
menu.setTeam(team);
resultMenu = menuRepository.saveAndFlush(menu); resultMenu = menuRepository.saveAndFlush(menu);
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());

View File

@ -1,6 +1,7 @@
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.repository.TacheRepository; import fr.organizee.repository.TacheRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -61,10 +62,13 @@ public class TacheController {
} }
// Ajoute une tache // Ajoute une tache
@PostMapping(value="/add", produces="application/json", consumes="application/json") @PostMapping(value="/add/{idTodoList}", produces="application/json", consumes="application/json")
public ResponseEntity<?> addTache(@RequestBody Tache tache){ public ResponseEntity<?> addTache(@RequestBody Tache tache,@PathVariable Integer idTodoList){
Tache resultTache = null; Tache resultTache = null;
try { try {
TodoList todolist=new TodoList();
todolist.setId(idTodoList);
tache.setTodolist(todolist);
resultTache = tacheRepo.saveAndFlush(tache); resultTache = tacheRepo.saveAndFlush(tache);
} catch (Exception e) { } catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
@ -73,11 +77,14 @@ public class TacheController {
return ResponseEntity.status(HttpStatus.CREATED).body(resultTache); return ResponseEntity.status(HttpStatus.CREATED).body(resultTache);
} }
//Met a jour les informations d'une date avec son ID //Met a jour les informations d'une tache avec son ID
@PutMapping("/update/{id}") @PutMapping("/update/{id}")
public ResponseEntity<?> updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception { public ResponseEntity<?> updateTache(@RequestBody Tache tache, @PathVariable Integer id) throws Exception {
Tache resultTache = null; Tache resultTache = null;
try { try {
TodoList todolist=new TodoList();
todolist.setId(tacheRepo.findById(tache.getId()).get().getTodolist().getId());
tache.setTodolist(todolist);
resultTache = tacheRepo.save(tache); resultTache = tacheRepo.save(tache);
} catch (Exception e) { } catch (Exception e) {

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;

View File

@ -11,6 +11,7 @@ public class Contact {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private int id; private int id;
private String couleur;
private String nom; private String nom;
private String prenom; private String prenom;
private String telephone; private String telephone;
@ -18,14 +19,15 @@ public class Contact {
private String adresse; private String adresse;
private LocalDate dateNaissance; private LocalDate dateNaissance;
@ManyToOne @ManyToOne
@JoinColumn(name="TEAM_ID") @JoinColumn(name = "TEAM_ID")
@JsonIgnoreProperties({"contact","membre"}) @JsonIgnoreProperties({"contact", "membre"})
private Team team; private Team team;
public Contact() { public Contact() {
} }
public Contact(String nom, String prenom, String telephone, String email, String adresse, LocalDate dateNaissance, Team team) { public Contact(String couleur, String nom, String prenom, String telephone, String email, String adresse, LocalDate dateNaissance, Team team) {
this.couleur = couleur;
this.nom = nom; this.nom = nom;
this.prenom = prenom; this.prenom = prenom;
this.telephone = telephone; this.telephone = telephone;
@ -43,6 +45,14 @@ public class Contact {
this.id = id; this.id = id;
} }
public String getCouleur() {
return couleur;
}
public void setCouleur(String couleur) {
this.couleur = couleur;
}
public String getNom() { public String getNom() {
return nom; return nom;
} }
@ -94,6 +104,7 @@ public class Contact {
public Team getTeam() { public Team getTeam() {
return team; return team;
} }
public void setTeam(Team team) { public void setTeam(Team team) {
this.team = team; this.team = team;
} }
@ -102,6 +113,7 @@ public class Contact {
public String toString() { public String toString() {
return "Contact{" + return "Contact{" +
"id=" + id + "id=" + id +
", couleur='" + couleur + '\'' +
", nom='" + nom + '\'' + ", nom='" + nom + '\'' +
", prenom='" + prenom + '\'' + ", prenom='" + prenom + '\'' +
", telephone='" + telephone + '\'' + ", telephone='" + telephone + '\'' +

View File

@ -12,7 +12,7 @@ public class Menu {
private int id; private int id;
private String libelle; private String libelle;
private LocalDate dateMenu; private LocalDate dateMenu;
private int validationProposition; // private int validationProposition;
@ManyToOne @ManyToOne
@JoinColumn(name="TEAM_ID") @JoinColumn(name="TEAM_ID")
@JsonIgnoreProperties({"menu","membre"}) @JsonIgnoreProperties({"menu","membre"})
@ -21,10 +21,10 @@ public class Menu {
public Menu() { public Menu() {
} }
public Menu(String libelle, LocalDate dateMenu, int validationProposition, Team team) { public Menu(String libelle, LocalDate dateMenu, Team team) {
this.libelle = libelle; this.libelle = libelle;
this.dateMenu = dateMenu; this.dateMenu = dateMenu;
this.validationProposition=validationProposition; //this.validationProposition=validationProposition;
this.team = team; this.team = team;
} }
@ -52,13 +52,13 @@ public class Menu {
this.dateMenu = dateMenu; this.dateMenu = dateMenu;
} }
public int getValidationProposition() { // public int getValidationProposition() {
return validationProposition; // return validationProposition;
} //}
public void setValidationProposition(int validationProposition) { //public void setValidationProposition(int validationProposition) {
this.validationProposition = validationProposition; // this.validationProposition = validationProposition;
} // }
public Team getTeam() { public Team getTeam() {
return team; return team;
@ -74,7 +74,6 @@ public class Menu {
"id=" + id + "id=" + id +
", libelle='" + libelle + '\'' + ", libelle='" + libelle + '\'' +
", dateMenu=" + dateMenu + ", dateMenu=" + dateMenu +
", validationProposition=" + validationProposition +
", team=" + team + ", team=" + team +
'}'; '}';
} }

View File

@ -14,4 +14,5 @@ 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", nativeQuery = true)
List<Menu> FindMenusByTeam(@Param("team_id") int team_id); List<Menu> FindMenusByTeam(@Param("team_id") int team_id);
} }