Skip to content

Commit 2d89add

Browse files
committed
feat: added logic layer service, documentation swagger and javadoc, log
1 parent 7a7576e commit 2d89add

26 files changed

+741
-141
lines changed

.idea/dataSources/f04243a9-2346-4975-b5d1-b9ee4bd49928.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/pom.xml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.springframework.boot</groupId>
99
<artifactId>spring-boot-starter-parent</artifactId>
10-
<version>3.4.4</version>
10+
<version>3.2.5</version>
1111
<relativePath/> <!-- lookup parent from repository -->
1212
</parent>
1313
<groupId>service.task.manager</groupId>
@@ -23,11 +23,6 @@
2323
<lombok.version>1.18.34</lombok.version>
2424
</properties>
2525
<dependencies>
26-
<dependency>
27-
<groupId>io.swagger.core.v3</groupId>
28-
<artifactId>swagger-annotations</artifactId>
29-
<version>2.1.10</version>
30-
</dependency>
3126
<dependency>
3227
<groupId>org.springframework.boot</groupId>
3328
<artifactId>spring-boot-starter-web</artifactId>
@@ -101,6 +96,25 @@
10196
</annotationProcessorPaths>
10297
</configuration>
10398
</plugin>
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-javadoc-plugin</artifactId>
102+
<version>3.6.0</version>
103+
<executions>
104+
<execution>
105+
<id>generate-javadoc</id>
106+
<phase>generate-resources</phase>
107+
<goals>
108+
<goal>javadoc</goal>
109+
</goals>
110+
</execution>
111+
</executions>
112+
<configuration>
113+
<source>21</source>
114+
<doclint>none</doclint>
115+
<outputDirectory>${project.basedir}/docs/javadoc</outputDirectory>
116+
</configuration>
117+
</plugin>
104118
</plugins>
105119
</build>
106120

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package service.task.manager.controller;
22

3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.Parameter;
5+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
6+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
38
import jakarta.validation.Valid;
49
import jakarta.validation.constraints.NotNull;
510
import jakarta.validation.constraints.Positive;
611
import lombok.RequiredArgsConstructor;
712
import lombok.extern.slf4j.Slf4j;
13+
import org.springframework.http.HttpStatus;
14+
import org.springframework.http.ResponseEntity;
815
import org.springframework.web.bind.annotation.*;
916
import service.task.manager.dto.epic.EpicRequestCreatedDto;
1017
import service.task.manager.dto.epic.EpicRequestUpdatedDto;
@@ -18,31 +25,66 @@
1825
@RestController
1926
@RequiredArgsConstructor
2027
@RequestMapping("/epic")
28+
@Tag(name = "Epic API", description = "API for managing epics")
2129
public class EpicController {
2230
private final EpicService service;
2331

2432
@PostMapping
25-
public void create(@RequestBody @Valid EpicRequestCreatedDto dto) {
33+
@Operation(summary = "Create a new epic", description = "Creates a new epic with the provided data.")
34+
@ApiResponses(value = {
35+
@ApiResponse(responseCode = "201", description = "Epic created successfully"),
36+
@ApiResponse(responseCode = "409", description = "Epic with the same name already exists")
37+
})
38+
public ResponseEntity<Void> create(@RequestBody @Valid EpicRequestCreatedDto dto) {
39+
log.info("Creating epic with name: {}", dto.name());
2640
service.create(dto);
41+
return ResponseEntity.status(HttpStatus.CREATED).build();
2742
}
2843

2944
@PutMapping
30-
public EpicResponseDto update(@RequestBody @Valid EpicRequestUpdatedDto dto) {
31-
return service.update(dto);
45+
@Operation(summary = "Update an existing epic", description = "Updates an epic with the provided data.")
46+
@ApiResponses(value = {
47+
@ApiResponse(responseCode = "200", description = "Epic updated successfully"),
48+
@ApiResponse(responseCode = "404", description = "Epic not found")
49+
})
50+
public ResponseEntity<EpicResponseDto> update(@RequestBody @Valid EpicRequestUpdatedDto dto) {
51+
log.info("Updating epic with ID: {}", dto.id());
52+
EpicResponseDto updatedEpic = service.update(dto);
53+
return ResponseEntity.ok(updatedEpic);
3254
}
3355

3456
@GetMapping("/{id}")
35-
public EpicResponseDto findById(@PathVariable @Positive @NotNull Long id) {
36-
return service.findById(id);
57+
@Operation(summary = "Get an epic by ID", description = "Retrieves an epic by its ID, including its subtasks.")
58+
@ApiResponses(value = {
59+
@ApiResponse(responseCode = "200", description = "Epic retrieved successfully"),
60+
@ApiResponse(responseCode = "404", description = "Epic not found")
61+
})
62+
public ResponseEntity<EpicResponseDto> findById(
63+
@Parameter(description = "ID of the epic to retrieve") @PathVariable @Positive @NotNull Long id) {
64+
log.info("Fetching epic with ID: {}", id);
65+
EpicResponseDto epic = service.findById(id);
66+
return ResponseEntity.ok(epic);
3767
}
3868

3969
@GetMapping
40-
public List<EpicResponseDto> findAll() {
41-
return service.findAll();
70+
@Operation(summary = "Get all epics", description = "Retrieves a list of all epics.")
71+
@ApiResponse(responseCode = "200", description = "List of epics retrieved successfully")
72+
public ResponseEntity<List<EpicResponseDto>> findAll() {
73+
log.info("Fetching all epics");
74+
List<EpicResponseDto> epics = service.findAll();
75+
return ResponseEntity.ok(epics);
4276
}
4377

4478
@DeleteMapping("/{id}")
45-
public void delete(@PathVariable @Positive @NotNull Long id) {
79+
@Operation(summary = "Delete an epic by ID", description = "Deletes an epic by its ID.")
80+
@ApiResponses(value = {
81+
@ApiResponse(responseCode = "204", description = "Epic deleted successfully"),
82+
@ApiResponse(responseCode = "404", description = "Epic not found")
83+
})
84+
public ResponseEntity<Void> delete(
85+
@Parameter(description = "ID of the epic to delete") @PathVariable @Positive @NotNull Long id) {
86+
log.info("Deleting epic with ID: {}", id);
4687
service.delete(id);
88+
return ResponseEntity.noContent().build();
4789
}
48-
}
90+
}
Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package service.task.manager.controller;
22

3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.Parameter;
5+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
6+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
38
import jakarta.validation.Valid;
49
import jakarta.validation.constraints.NotNull;
510
import jakarta.validation.constraints.Positive;
611
import lombok.RequiredArgsConstructor;
712
import lombok.extern.slf4j.Slf4j;
13+
import org.springframework.http.HttpStatus;
14+
import org.springframework.http.ResponseEntity;
815
import org.springframework.web.bind.annotation.*;
916
import service.task.manager.dto.subtask.SubtaskRequestCreatedDto;
1017
import service.task.manager.dto.subtask.SubtaskRequestUpdatedDto;
@@ -18,31 +25,67 @@
1825
@RestController
1926
@RequiredArgsConstructor
2027
@RequestMapping("/subtask")
28+
@Tag(name = "Subtask API", description = "API for managing subtasks")
2129
public class SubtaskController {
2230
private final SubtaskService service;
2331

2432
@PostMapping
25-
public void create(@RequestBody @Valid SubtaskRequestCreatedDto dto) {
33+
@Operation(summary = "Create a new subtask", description = "Creates a new subtask with the provided data, associated with an epic.")
34+
@ApiResponses(value = {
35+
@ApiResponse(responseCode = "201", description = "Subtask created successfully"),
36+
@ApiResponse(responseCode = "404", description = "Associated epic not found"),
37+
@ApiResponse(responseCode = "409", description = "Subtask with the same name already exists")
38+
})
39+
public ResponseEntity<Void> create(@RequestBody @Valid SubtaskRequestCreatedDto dto) {
40+
log.info("Creating subtask with name: {}", dto.name());
2641
service.create(dto);
42+
return ResponseEntity.status(HttpStatus.CREATED).build();
2743
}
2844

2945
@PutMapping
30-
public void update(@RequestBody @Valid SubtaskRequestUpdatedDto dto) {
31-
service.update(dto);
46+
@Operation(summary = "Update an existing subtask", description = "Updates an existing subtask with the provided data.")
47+
@ApiResponses(value = {
48+
@ApiResponse(responseCode = "200", description = "Subtask updated successfully"),
49+
@ApiResponse(responseCode = "404", description = "Subtask not found")
50+
})
51+
public ResponseEntity<SubtaskResponseDto> update(@RequestBody @Valid SubtaskRequestUpdatedDto dto) {
52+
log.info("Updating subtask with ID: {}", dto.id());
53+
SubtaskResponseDto updatedSubtask = service.update(dto);
54+
return ResponseEntity.ok(updatedSubtask);
3255
}
3356

3457
@GetMapping("/{id}")
35-
public SubtaskResponseDto findById(@PathVariable @Positive @NotNull Long id) {
36-
return service.findById(id);
58+
@Operation(summary = "Get a subtask by ID", description = "Retrieves a subtask by its ID.")
59+
@ApiResponses(value = {
60+
@ApiResponse(responseCode = "200", description = "Subtask retrieved successfully"),
61+
@ApiResponse(responseCode = "404", description = "Subtask not found")
62+
})
63+
public ResponseEntity<SubtaskResponseDto> findById(
64+
@Parameter(description = "ID of the subtask to retrieve") @PathVariable @Positive @NotNull Long id) {
65+
log.info("Fetching subtask with ID: {}", id);
66+
SubtaskResponseDto subtask = service.findById(id);
67+
return ResponseEntity.ok(subtask);
3768
}
3869

3970
@GetMapping
40-
public List<SubtaskResponseDto> findAll() {
41-
return service.findAll();
71+
@Operation(summary = "Get all subtasks", description = "Retrieves a list of all subtasks.")
72+
@ApiResponse(responseCode = "200", description = "List of subtasks retrieved successfully")
73+
public ResponseEntity<List<SubtaskResponseDto>> findAll() {
74+
log.info("Fetching all subtasks");
75+
List<SubtaskResponseDto> subtasks = service.findAll();
76+
return ResponseEntity.ok(subtasks);
4277
}
4378

4479
@DeleteMapping("/{id}")
45-
public void delete(@PathVariable @Positive @NotNull Long id) {
80+
@Operation(summary = "Delete a subtask by ID", description = "Deletes a subtask by its ID.")
81+
@ApiResponses(value = {
82+
@ApiResponse(responseCode = "204", description = "Subtask deleted successfully"),
83+
@ApiResponse(responseCode = "404", description = "Subtask not found")
84+
})
85+
public ResponseEntity<Void> delete(
86+
@Parameter(description = "ID of the subtask to delete") @PathVariable @Positive @NotNull Long id) {
87+
log.info("Deleting subtask with ID: {}", id);
4688
service.delete(id);
89+
return ResponseEntity.noContent().build();
4790
}
48-
}
91+
}
Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
package service.task.manager.controller;
22

3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.Parameter;
5+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
6+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
7+
import io.swagger.v3.oas.annotations.tags.Tag;
38
import jakarta.validation.Valid;
49
import jakarta.validation.constraints.NotNull;
510
import jakarta.validation.constraints.Positive;
611
import lombok.RequiredArgsConstructor;
712
import lombok.extern.slf4j.Slf4j;
13+
import org.springframework.http.HttpStatus;
14+
import org.springframework.http.ResponseEntity;
815
import org.springframework.web.bind.annotation.*;
916
import service.task.manager.dto.task.TaskRequestCreatedDto;
1017
import service.task.manager.dto.task.TaskRequestUpdatedDto;
@@ -18,31 +25,66 @@
1825
@RestController
1926
@RequiredArgsConstructor
2027
@RequestMapping("/task")
28+
@Tag(name = "Task API", description = "API for managing tasks")
2129
public class TaskController {
2230
private final TaskService service;
2331

2432
@PostMapping
25-
public void create(@RequestBody @Valid TaskRequestCreatedDto dto) {
33+
@Operation(summary = "Create a new task", description = "Creates a new task with the provided data.")
34+
@ApiResponses(value = {
35+
@ApiResponse(responseCode = "201", description = "Task created successfully"),
36+
@ApiResponse(responseCode = "409", description = "Task with the same name already exists")
37+
})
38+
public ResponseEntity<Void> create(@RequestBody @Valid TaskRequestCreatedDto dto) {
39+
log.info("Creating task with name: {}", dto.name());
2640
service.create(dto);
41+
return ResponseEntity.status(HttpStatus.CREATED).build();
2742
}
2843

2944
@PutMapping
30-
public void update(@RequestBody @Valid TaskRequestUpdatedDto dto) {
31-
service.update(dto);
45+
@Operation(summary = "Update an existing task", description = "Updates an existing task with the provided data.")
46+
@ApiResponses(value = {
47+
@ApiResponse(responseCode = "200", description = "Task updated successfully"),
48+
@ApiResponse(responseCode = "404", description = "Task not found")
49+
})
50+
public ResponseEntity<TaskResponseDto> update(@RequestBody @Valid TaskRequestUpdatedDto dto) {
51+
log.info("Updating task with ID: {}", dto.id());
52+
TaskResponseDto updatedTask = service.update(dto);
53+
return ResponseEntity.ok(updatedTask);
3254
}
3355

3456
@GetMapping("/{id}")
35-
public TaskResponseDto get(@PathVariable @Positive @NotNull Long id) {
36-
return service.findById(id);
57+
@Operation(summary = "Get a task by ID", description = "Retrieves a task by its ID.")
58+
@ApiResponses(value = {
59+
@ApiResponse(responseCode = "200", description = "Task retrieved successfully"),
60+
@ApiResponse(responseCode = "404", description = "Task not found")
61+
})
62+
public ResponseEntity<TaskResponseDto> get(
63+
@Parameter(description = "ID of the task to retrieve") @PathVariable @Positive @NotNull Long id) {
64+
log.info("Fetching task with ID: {}", id);
65+
TaskResponseDto task = service.findById(id);
66+
return ResponseEntity.ok(task);
3767
}
3868

3969
@GetMapping
40-
public List<TaskResponseDto> getAll(){
41-
return service.findAll();
70+
@Operation(summary = "Get all tasks", description = "Retrieves a list of all tasks.")
71+
@ApiResponse(responseCode = "200", description = "List of tasks retrieved successfully")
72+
public ResponseEntity<List<TaskResponseDto>> getAll() {
73+
log.info("Fetching all tasks");
74+
List<TaskResponseDto> tasks = service.findAll();
75+
return ResponseEntity.ok(tasks);
4276
}
4377

4478
@DeleteMapping("/{id}")
45-
public void delete(@PathVariable @Positive @NotNull Long id) {
79+
@Operation(summary = "Delete a task by ID", description = "Deletes a task by its ID.")
80+
@ApiResponses(value = {
81+
@ApiResponse(responseCode = "204", description = "Task deleted successfully"),
82+
@ApiResponse(responseCode = "404", description = "Task not found")
83+
})
84+
public ResponseEntity<Void> delete(
85+
@Parameter(description = "ID of the task to delete") @PathVariable @Positive @NotNull Long id) {
86+
log.info("Deleting task with ID: {}", id);
4687
service.delete(id);
88+
return ResponseEntity.noContent().build();
4789
}
48-
}
90+
}
Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package service.task.manager.dto.epic;
22

3+
import io.swagger.v3.oas.annotations.media.Schema;
34
import jakarta.validation.constraints.NotBlank;
45
import jakarta.validation.constraints.NotNull;
56
import lombok.Builder;
@@ -8,15 +9,25 @@
89
import java.time.LocalDateTime;
910

1011
/**
11-
* DTO for {@link service.task.manager.model.Epic}
12+
* DTO for creating a new epic.
1213
*/
14+
@Schema(description = "DTO for creating a new epic")
1315
@Builder
14-
public record EpicRequestCreatedDto(@NotBlank
15-
String name,
16-
@NotBlank(message = "blank description")
17-
String description,
18-
@NotNull(message = "null start time")
19-
LocalDateTime startTime,
20-
@NotNull(message = "null duration")
21-
Duration duration) {
16+
public record EpicRequestCreatedDto(
17+
@Schema(description = "Name of the epic", example = "Project Planning", required = true)
18+
@NotBlank(message = "blank name")
19+
String name,
20+
21+
@Schema(description = "Description of the epic", example = "Planning phase of the project", required = true)
22+
@NotBlank(message = "blank description")
23+
String description,
24+
25+
@Schema(description = "Start time of the epic", example = "2025-04-27T10:00:00", required = true)
26+
@NotNull(message = "null start time")
27+
LocalDateTime startTime,
28+
29+
@Schema(description = "Duration of the epic", example = "PT24H", required = true)
30+
@NotNull(message = "null duration")
31+
Duration duration
32+
) {
2233
}

0 commit comments

Comments
 (0)