Package com.homannsoftware.tasks.task
Class TaskController
java.lang.Object
com.homannsoftware.tasks.task.TaskController
Maps task HTTP requests to use cases and returns explicit API DTOs.
-
Constructor Summary
ConstructorsConstructorDescriptionTaskController(TaskService tasks) Receives the application service through constructor injection. -
Method Summary
Modifier and TypeMethodDescriptioncomplete(long id) Sets completion using an idempotent HTTP operation with no request body.org.springframework.http.ResponseEntity<TaskView> create(@Valid CreateTask request) Creates a task after Spring MVC validates the request body.org.springframework.http.ResponseEntity<Void> delete(long id) Removes an existing task.get(long id) Reads a task identified by a URL path segment.list()Lists the tutorial dataset.
-
Constructor Details
-
TaskController
Receives the application service through constructor injection.- Parameters:
tasks- service implementing task use cases
-
-
Method Details
-
create
@PostMapping public org.springframework.http.ResponseEntity<TaskView> create(@Valid @RequestBody @Valid CreateTask request) Creates a task after Spring MVC validates the request body.- Parameters:
request- validated title input- Returns:
- HTTP 201 with the created task and its resource Location
-
list
Lists the tutorial dataset.- Returns:
- HTTP response body listing all tasks in ascending ID order
-
get
Reads a task identified by a URL path segment.- Parameters:
id- requested task identity- Returns:
- HTTP response body describing the task
- Throws:
TaskNotFound- if no task has that identity; mapped to HTTP 404
-
complete
Sets completion using an idempotent HTTP operation with no request body.- Parameters:
id- requested task identity- Returns:
- HTTP response body showing the completed task
- Throws:
TaskNotFound- if no task has that identity; mapped to HTTP 404
-
delete
@DeleteMapping("/{id}") public org.springframework.http.ResponseEntity<Void> delete(@PathVariable long id) Removes an existing task.- Parameters:
id- requested task identity- Returns:
- HTTP 204 with no response body
- Throws:
TaskNotFound- if no task has that identity; mapped to HTTP 404
-