1010import java .util .Map ;
1111
1212@ RestController
13+ @ RequestMapping ("/tasks" )
1314public class TaskController {
1415
1516 private final TaskService taskService ;
@@ -18,45 +19,45 @@ public TaskController(TaskService taskService) {
1819 this .taskService = taskService ;
1920 }
2021
21- @ PostMapping ( "/tasks" )
22+ @ PostMapping
2223 public ResponseEntity <Task > addTask (@ RequestBody Map <String , String > request ) {
2324 String name = request .get ("name" );
2425 String description = request .get ("description" );
2526
2627 return ResponseEntity .ok (taskService .addTask (name , description ));
2728 }
2829
29- @ GetMapping ( "/tasks" )
30+ @ GetMapping
3031 public ResponseEntity <List <Task >> getAllTasks () {
3132 return ResponseEntity .ok (taskService .getAllTasks ());
3233 }
3334
34- @ GetMapping ("/tasks/ {id}" )
35+ @ GetMapping ("/{id}" )
3536 public ResponseEntity <Task > getTask (@ PathVariable String id ) {
3637 return ResponseEntity .ok (taskService .getTask (id ));
3738 }
3839
39- @ GetMapping ("/tasks/ search/{name}" )
40+ @ GetMapping ("/search/{name}" )
4041 public ResponseEntity <Task > searchTaskByName (@ PathVariable String name ) {
4142 return ResponseEntity .ok (taskService .searchTaskByName (name ));
4243 }
4344
44- @ GetMapping ("/tasks/ search/status/{status}" )
45+ @ GetMapping ("/search/status/{status}" )
4546 public ResponseEntity <List <Task >> searchTaskByStatus (@ PathVariable TaskStatus status ) {
4647 return ResponseEntity .ok (taskService .searchTaskByStatus (status ));
4748 }
4849
49- @ PatchMapping ("/tasks/ {id}/complete" )
50+ @ PatchMapping ("/{id}/complete" )
5051 public ResponseEntity <Task > completeTask (@ PathVariable String id ) {
5152 return ResponseEntity .ok (taskService .completeTask (id ));
5253 }
5354
54- @ DeleteMapping ("/tasks/ {id}" )
55+ @ DeleteMapping ("/{id}" )
5556 public ResponseEntity <Task > deleteTask (@ PathVariable String id ) {
5657 return ResponseEntity .ok (taskService .deleteTask (id ));
5758 }
5859
59- @ PatchMapping ("/tasks/ {id}" )
60+ @ PatchMapping ("/{id}" )
6061 public ResponseEntity <Task > undoDelete (@ PathVariable String id ) {
6162 return ResponseEntity .ok (taskService .undoDelete (id ));
6263 }
0 commit comments