|
|
@@ -5,6 +5,7 @@ import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
@@ -71,6 +72,20 @@ public class ApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @DeleteMapping("/evenements/history/{uuid}/content/{id}")
|
|
|
+ boolean deleteHistoryEvenement(@PathVariable String uuid, @PathVariable Long id) {
|
|
|
+ Optional<Evenement> evt = repository.findById(id);
|
|
|
+ if (evt.isEmpty()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (evt.get().getUuid().equals(uuid)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ repositoryLob.deleteById(id);
|
|
|
+ repository.deleteById(id);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/evenements")
|
|
|
Evenement newEvenement(Principal principal, @RequestBody EvenementData evt) {
|
|
|
if (repository.findFirst1ByUuidOrderByLastModifiedDesc(evt.getUuid()).size() > 0) {
|
|
|
@@ -98,6 +113,16 @@ public class ApiController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @DeleteMapping("/evenements/{uuid}")
|
|
|
+ boolean deleteEvenement(Principal principal, @PathVariable String uuid) {
|
|
|
+ List<Evenement> list = repository.findByUuid(uuid);
|
|
|
+ for (Evenement evenement : list) {
|
|
|
+ repositoryLob.deleteById(evenement.getId());
|
|
|
+ }
|
|
|
+ repository.deleteAll(list);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
private Evenement saveEvenementData(EvenementData evt, String username) {
|
|
|
CustomUser customUser = repositoryUser.findByUsername(username);
|
|
|
Evenement newEvenement = new Evenement();
|