aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/encora/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/encora/Main.java')
-rw-r--r--src/main/java/com/encora/Main.java17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/com/encora/Main.java b/src/main/java/com/encora/Main.java
index dbd3364..ac2a609 100644
--- a/src/main/java/com/encora/Main.java
+++ b/src/main/java/com/encora/Main.java
@@ -124,7 +124,7 @@ public class Main {
}
@GetMapping("/todos/{field}/{order}")
@ResponseStatus(value=HttpStatus.OK)
- public List<ToDos> getFilteredToDos(@PathVariable("field") SortingsFields field, @PathVariable("order") SortingOrders order) {
+ public List<ToDos> getSortedToDos(@PathVariable("field") SortingsFields field, @PathVariable("order") SortingOrders order) {
Sort sortingMethod = Sort.by(String.valueOf(field));
if (Objects.equals(String.valueOf(order), "DESC")) {
sortingMethod = sortingMethod.descending();
@@ -132,4 +132,19 @@ public class Main {
return toDosRepository.findAll(sortingMethod);
}
+
+
+ // Getting filtered to dos.
+ record toDoFilters (
+ String name,
+ String priority,
+ String done
+ ) {
+
+ }
+ @GetMapping("/todos/filter")
+ @ResponseStatus(value=HttpStatus.OK)
+ public List<ToDos> getFilteredToDos(@RequestBody toDoFilters filters) throws Exception {
+ return toDosRepository.findAllWithFilter(filters.name(), filters.priority(), filters.done());
+ }
}