@@ -13,14 +13,13 @@ public class TaskController {
1313
1414 private final TaskService taskService ;
1515
16- public TaskController (TaskService taskService ){
16+ public TaskController (TaskService taskService ) {
1717 this .taskService = taskService ;
1818 }
1919
2020 @ PostMapping ("/tasks" )
21- public ResponseEntity <Task > addTask (@ RequestBody Map <String , String > request ){
22- try
23- {
21+ public ResponseEntity <Task > addTask (@ RequestBody Map <String , String > request ) {
22+ try {
2423 String name = request .get ("name" );
2524 String description = request .get ("description" );
2625
@@ -32,19 +31,26 @@ public ResponseEntity<Task> addTask(@RequestBody Map<String, String> request){
3231 }
3332
3433 @ GetMapping ("/tasks" )
35- public ResponseEntity <List <Task >> getAllTasks (){
34+ public ResponseEntity <List <Task >> getAllTasks () {
3635 return ResponseEntity .ok (taskService .getAllTasks ());
3736 }
3837
3938 @ GetMapping ("/tasks/{id}" )
40- public ResponseEntity <Task > getTask (@ PathVariable String id ){
39+ public ResponseEntity <Task > getTask (@ PathVariable String id ) {
4140 return taskService .getTask (id )
4241 .map (ResponseEntity ::ok )
4342 .orElse (ResponseEntity .notFound ().build ());
4443 }
4544
45+ @ PatchMapping ("/tasks/{id}/complete" )
46+ public ResponseEntity <Task > completeTask (@ PathVariable String id ) {
47+ return taskService .completeTask (id )
48+ .map (ResponseEntity ::ok )
49+ .orElse (ResponseEntity .notFound ().build ());
50+ }
51+
4652 @ DeleteMapping ("/tasks/{id}" )
47- public ResponseEntity <Void > deleteTask (@ PathVariable String id ){
53+ public ResponseEntity <Void > deleteTask (@ PathVariable String id ) {
4854 taskService .deleteTask (id );
4955 return ResponseEntity .notFound ().build ();
5056 }
0 commit comments