8
8
import io .swagger .v3 .oas .annotations .Operation ;
9
9
import io .swagger .v3 .oas .annotations .tags .Tag ;
10
10
import jakarta .validation .Valid ;
11
+ import java .time .ZonedDateTime ;
11
12
import java .util .List ;
12
13
import java .util .UUID ;
13
14
import lombok .RequiredArgsConstructor ;
22
23
@ Tag (name = "Checklists" , description = "Creating, reading and deleting Checklists." )
23
24
public class ChecklistController {
24
25
26
+ public static final String CHECKLIST_ID = "checklistID" ;
27
+ public static final String SERVICE_ID = "serviceID" ;
28
+ public static final String PATH_VAR_CHECKLIST_ID = "/{" + CHECKLIST_ID + "}" ;
29
+ public static final String PATH_VAR_SERVICE_ID = "/{" + SERVICE_ID + "}" ;
30
+
25
31
private final ChecklistService checklistService ;
26
32
private final ChecklistMapper checklistMapper ;
27
33
@@ -33,10 +39,10 @@ public List<ChecklistReadDTO> getChecklists() {
33
39
return checklists .stream ().map (checklistMapper ::toReadDTO ).toList ();
34
40
}
35
41
36
- @ GetMapping (path = "/{checklistID}" )
42
+ @ GetMapping (path = PATH_VAR_CHECKLIST_ID )
37
43
@ Operation (summary = "Get specific checklist by checklist-id." , description = "Returns a checklist by checklistId" )
38
44
@ ResponseStatus (HttpStatus .OK )
39
- public ChecklistReadDTO getChecklist (@ PathVariable ("checklistID" ) final UUID checklistID ) {
45
+ public ChecklistReadDTO getChecklist (@ PathVariable (CHECKLIST_ID ) final UUID checklistID ) {
40
46
return checklistMapper .toReadDTO (checklistService .getChecklist (checklistID ));
41
47
}
42
48
@@ -48,18 +54,34 @@ public ChecklistReadDTO createChecklist(@Valid @RequestBody final ChecklistCreat
48
54
.toReadDTO (checklistService .createChecklist (checklistMapper .toCreateChecklist (checklistCreateDTO )));
49
55
}
50
56
51
- @ PutMapping ("/{checklistID}" )
57
+ @ PutMapping (PATH_VAR_CHECKLIST_ID )
52
58
@ Operation (summary = "Update a checklist" , description = "Updates a checklist using the provided checklist details." )
53
59
@ ResponseStatus (HttpStatus .OK )
54
60
public ChecklistReadDTO updateChecklist (@ Valid @ RequestBody final ChecklistUpdateDTO checklistUpdateDTO ,
55
- @ PathVariable ("checklistID" ) final UUID checklistID ) {
61
+ @ PathVariable (CHECKLIST_ID ) final UUID checklistID ) {
56
62
return checklistMapper .toReadDTO (checklistService .updateChecklist (checklistMapper .toUpdateChecklist (checklistUpdateDTO ), checklistID ));
57
63
}
58
64
59
- @ DeleteMapping ("/{checklistID}" )
65
+ @ DeleteMapping (PATH_VAR_CHECKLIST_ID )
60
66
@ Operation (summary = "Delete a checklist" , description = "Deletes a checklist by checklistId." )
61
67
@ ResponseStatus (HttpStatus .OK )
62
- public void deleteChecklist (@ PathVariable ("checklistID" ) final UUID checklistID ) {
68
+ public void deleteChecklist (@ PathVariable (CHECKLIST_ID ) final UUID checklistID ) {
63
69
checklistService .deleteChecklist (checklistID );
64
70
}
71
+
72
+ @ PostMapping (PATH_VAR_CHECKLIST_ID + PATH_VAR_SERVICE_ID + "/check" )
73
+ @ Operation (summary = "Check a Checklist-Entry" , description = "Checks a checklist-entry." )
74
+ @ ResponseStatus (HttpStatus .OK )
75
+ public ChecklistReadDTO checkChecklistEntry (@ PathVariable (CHECKLIST_ID ) final UUID checklistID ,
76
+ @ PathVariable (SERVICE_ID ) final String serviceID ) {
77
+ return checklistMapper .toReadDTO (checklistService .changeChecklistEntry (checklistID , serviceID , ZonedDateTime .now ()));
78
+ }
79
+
80
+ @ PostMapping (PATH_VAR_CHECKLIST_ID + PATH_VAR_SERVICE_ID + "/uncheck" )
81
+ @ Operation (summary = "Uncheck a Checklist-Entry" , description = "Unchecks a checklist-entry." )
82
+ @ ResponseStatus (HttpStatus .OK )
83
+ public ChecklistReadDTO uncheckChecklistEntry (@ PathVariable (CHECKLIST_ID ) final UUID checklistID ,
84
+ @ PathVariable (SERVICE_ID ) final String serviceID ) {
85
+ return checklistMapper .toReadDTO (checklistService .changeChecklistEntry (checklistID , serviceID , null ));
86
+ }
65
87
}
0 commit comments