From 90498a2cd1362692e3a79668f169772f4a70c715 Mon Sep 17 00:00:00 2001
From: Blandine Bajard <83599148+BlandineBajard@users.noreply.github.com>
Date: Wed, 19 Jan 2022 16:01:44 +0100
Subject: [PATCH] menu controller et repo
---
.../organizee/controller/MenuController.java | 90 +++++++++++++++++++
src/main/java/fr/organizee/model/Menu.java | 4 +-
.../organizee/repository/MenuRepository.java | 15 +++-
3 files changed, 107 insertions(+), 2 deletions(-)
create mode 100644 src/main/java/fr/organizee/controller/MenuController.java
diff --git a/src/main/java/fr/organizee/controller/MenuController.java b/src/main/java/fr/organizee/controller/MenuController.java
new file mode 100644
index 0000000..f4e4ec8
--- /dev/null
+++ b/src/main/java/fr/organizee/controller/MenuController.java
@@ -0,0 +1,90 @@
+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;
+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("/menus")
+public class MenuController {
+
+ @Autowired
+ private MenuRepository menuRepository;
+
+ @GetMapping(value = "/{id}")
+ @PreAuthorize("hasRole('ROLE_PARENT') or hasRole('ROLE_ENFANT')")
+ public ResponseEntity> findById(@PathVariable int id){
+ Optional