1 package fr.tiogars.chat.domains.task.controllers;
2
3 import org.springframework.http.ResponseEntity;
4 import org.springframework.web.bind.annotation.DeleteMapping;
5 import org.springframework.web.bind.annotation.PathVariable;
6 import org.springframework.web.bind.annotation.RestController;
7
8 import fr.tiogars.chat.domains.task.services.TaskDeleteService;
9 import io.swagger.v3.oas.annotations.Operation;
10 import io.swagger.v3.oas.annotations.Parameter;
11 import io.swagger.v3.oas.annotations.responses.ApiResponse;
12 import io.swagger.v3.oas.annotations.responses.ApiResponses;
13 import io.swagger.v3.oas.annotations.tags.Tag;
14
15
16
17
18
19
20 @Tag(name = "Tasks", description = "CRUD operations for the Task business object.")
21 @RestController
22 public class TaskDeleteController {
23
24 private final TaskDeleteService service;
25
26
27
28
29
30
31 public TaskDeleteController(TaskDeleteService service) {
32 this.service = service;
33 }
34
35
36
37
38
39
40
41 @Operation(
42 summary = "Soft-delete a Task",
43 description = "Archives the row and allows its code to be reused with a new identifier."
44 )
45 @ApiResponses(value = {
46 @ApiResponse(responseCode = "204", description = "The record was archived."),
47 @ApiResponse(responseCode = "404", description = "No active record exists for the supplied identifier.")
48 })
49 @DeleteMapping("/api/v1/task/{id}")
50 public ResponseEntity<Void> deleteTask(
51 @Parameter(description = "Persistent template identifier.", required = true, example = "42")
52 @PathVariable Long id) {
53 return service.delete(id)
54 ? ResponseEntity.noContent().build()
55 : ResponseEntity.notFound().build();
56 }
57 }