Skip to content
Snippets Groups Projects
Commit ad4172a0 authored by TalatAltan's avatar TalatAltan
Browse files

lect09 Aufgabe 2.1

parent b7781d58
No related branches found
No related tags found
No related merge requests found
......@@ -65,4 +65,15 @@ public class AccountServiceController {
log.info("Updated registered user to: {\n{}}", updatedUser.toString());
return new ResponseEntity<>(updatedUser, HttpStatus.OK);
}
@DeleteMapping("/{id}")
public ResponseEntity<User> delete(@PathVariable("id") long userId){
final User task = ephemeralStorage.deleteUserById(userId);
if (task == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
log.info("Returning task: {\n{}}", task.toString());
return new ResponseEntity<>(task, HttpStatus.OK);
}
}
......@@ -35,6 +35,17 @@ public class TaskServiceController {
return ephemeralStorage.getTasks();
}
@GetMapping("/user/{id}")
public ResponseEntity<List<Task>> GetUserById(@PathVariable("id") long userId) {
final List<Task> task = ephemeralStorage.getTasksForUserWithId(userId);
if (task == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
log.info("Returning task: {\n{}}", task.toString());
return new ResponseEntity<>(task, HttpStatus.OK);
}
@PostMapping
public ResponseEntity add(@RequestBody TaskRequestModel taskRequestModel) {
final User userByIdFromAccountService = restService.getUserByIdFromAccountService(taskRequestModel.getUserId());
......@@ -77,4 +88,15 @@ public class TaskServiceController {
log.info("Updated tasks of user to assignment limit: {\n{}}", updatedTasks.toString());
return new ResponseEntity<>(updatedTasks, HttpStatus.OK);
}
@DeleteMapping("/user/{id}")
public ResponseEntity<List<Task>> delete(@PathVariable("id") long userId){
final List<Task> task = ephemeralStorage.deleteTasksForUserWithId(userId);
if (task == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
log.info("Returning task: {\n{}}", task.toString());
return new ResponseEntity<>(task, HttpStatus.OK);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment