|
@@ -11,7 +11,7 @@ import org.springframework.core.io.ByteArrayResource;
|
|
|
import org.springframework.core.io.Resource;
|
|
import org.springframework.core.io.Resource;
|
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
|
-//import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -38,7 +38,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
@CrossOrigin(origins = "http://localhost:4200")
|
|
@CrossOrigin(origins = "http://localhost:4200")
|
|
|
@RestController
|
|
@RestController
|
|
|
-@RequestMapping("/demovote-api/v1/production")
|
|
|
|
|
|
|
+@RequestMapping("/production")
|
|
|
public class ProductionController
|
|
public class ProductionController
|
|
|
{
|
|
{
|
|
|
|
|
|
|
@@ -53,7 +53,7 @@ public class ProductionController
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/list")
|
|
@GetMapping(value = "/list")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public List<Production> getList(@RequestParam(required = false) String type)
|
|
public List<Production> getList(@RequestParam(required = false) String type)
|
|
|
{
|
|
{
|
|
|
List<ProductionShort> prods = productionRepository.findAllWithoutArchive();
|
|
List<ProductionShort> prods = productionRepository.findAllWithoutArchive();
|
|
@@ -66,6 +66,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping(value = "/file/{id}")
|
|
@GetMapping(value = "/file/{id}")
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public ResponseEntity<Resource> getFile(@PathVariable int id)
|
|
public ResponseEntity<Resource> getFile(@PathVariable int id)
|
|
|
{
|
|
{
|
|
@@ -86,7 +87,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping(value = "/form/{id}")
|
|
@GetMapping(value = "/form/{id}")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public ResponseEntity<Production> getForm(@PathVariable int id)
|
|
public ResponseEntity<Production> getForm(@PathVariable int id)
|
|
|
{
|
|
{
|
|
|
ProductionShort p = productionRepository.findByIdWithoutArchive(id);
|
|
ProductionShort p = productionRepository.findByIdWithoutArchive(id);
|
|
@@ -97,7 +98,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping(value = "/formfile/{id}")
|
|
@GetMapping(value = "/formfile/{id}")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public ResponseEntity<ProductionFile> getFormFile(@PathVariable int id)
|
|
public ResponseEntity<ProductionFile> getFormFile(@PathVariable int id)
|
|
|
{
|
|
{
|
|
|
ProductionFile p = productionRepository.findByIdForUpload(id);
|
|
ProductionFile p = productionRepository.findByIdForUpload(id);
|
|
@@ -108,7 +109,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping(value = "/create")
|
|
@PostMapping(value = "/create")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public ResponseEntity<Map<String, Boolean>> create(@RequestBody(required = true) ProductionTransfer production, HttpServletRequest request)
|
|
public ResponseEntity<Map<String, Boolean>> create(@RequestBody(required = true) ProductionTransfer production, HttpServletRequest request)
|
|
|
{
|
|
{
|
|
|
Participant participant = participantRepository.findById(production.numeroParticipant());
|
|
Participant participant = participantRepository.findById(production.numeroParticipant());
|
|
@@ -152,7 +153,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PutMapping(value = "/update/{id}")
|
|
@PutMapping(value = "/update/{id}")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public ResponseEntity<Map<String, Boolean>> update(@PathVariable int id, @RequestBody(required = true) ProductionUpdate production)
|
|
public ResponseEntity<Map<String, Boolean>> update(@PathVariable int id, @RequestBody(required = true) ProductionUpdate production)
|
|
|
{
|
|
{
|
|
|
Production found = productionRepository.findById(id);
|
|
Production found = productionRepository.findById(id);
|
|
@@ -197,7 +198,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PutMapping(value = "/upload/{id}")
|
|
@PutMapping(value = "/upload/{id}")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public ResponseEntity<Map<String, Boolean>> update(@PathVariable int id, @RequestBody(required = true) ProductionFile production)
|
|
public ResponseEntity<Map<String, Boolean>> update(@PathVariable int id, @RequestBody(required = true) ProductionFile production)
|
|
|
{
|
|
{
|
|
|
Production found = productionRepository.findById(id);
|
|
Production found = productionRepository.findById(id);
|
|
@@ -234,7 +235,7 @@ public class ProductionController
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@DeleteMapping(value = "/delete/{id}")
|
|
@DeleteMapping(value = "/delete/{id}")
|
|
|
- //@PreAuthorize("hasAnyRole('LISTE_PRODUCTIONS_ADMIN', 'LISTE_PRODUCTIONS_USER')")
|
|
|
|
|
|
|
+ @PreAuthorize("hasAuthority('Administrateur')")
|
|
|
public ResponseEntity<Map<String, Boolean>> disableProduction(@PathVariable int id)
|
|
public ResponseEntity<Map<String, Boolean>> disableProduction(@PathVariable int id)
|
|
|
{
|
|
{
|
|
|
Production found = productionRepository.getReferenceById(id);
|
|
Production found = productionRepository.getReferenceById(id);
|