Skip to content

Commit 2f06011

Browse files
Fix - first review
1 parent 8d92a08 commit 2f06011

22 files changed

+405
-310
lines changed

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ WORKDIR /
44

55
COPY / .
66

7-
ENV SPRING_PROFILES_ACTIVE=dev
7+
RUN gradle installDist
88

9-
RUN ./gradlew --no-daemon clean build --info
10-
11-
CMD ["java", "-jar", "build/libs/app-0.0.1-SNAPSHOT.jar"]
9+
CMD ./build/install/app/bin/app

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Actions Status](https://github.com/VictorGotsenko/java-project-99/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/VictorGotsenko/java-project-99/actions)
22
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=VictorGotsenko_java-project-99&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=VictorGotsenko_java-project-99)
3+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=VictorGotsenko_java-project-99&metric=coverage)](https://sonarcloud.io/summary/new_code?id=VictorGotsenko_java-project-99)
34

45
## Task manager
56

src/main/java/hexlet/code/controller/LabelController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import hexlet.code.dto.label.LabelCreateDTO;
44
import hexlet.code.dto.label.LabelDTO;
55
import hexlet.code.dto.label.LabelUpdateDTO;
6-
import hexlet.code.service.LabelService;
6+
import hexlet.code.service.LabelServiceImpl;
77
import jakarta.validation.Valid;
88
import lombok.AllArgsConstructor;
99
import org.springframework.http.HttpStatus;
@@ -24,15 +24,15 @@
2424
@RequestMapping("/api/labels")
2525
@AllArgsConstructor
2626
public class LabelController {
27-
private final LabelService labelService;
27+
private final LabelServiceImpl labelServiceImpl;
2828

2929
/**
3030
*
3131
* @return List
3232
*/
3333
@GetMapping(path = "")
3434
public ResponseEntity<List<LabelDTO>> index() {
35-
var result = labelService.getAll();
35+
var result = labelServiceImpl.getAll();
3636
return ResponseEntity.ok().header("X-Total-Count", String.valueOf(result.size())).body(result);
3737
}
3838

@@ -44,7 +44,7 @@ public ResponseEntity<List<LabelDTO>> index() {
4444
@GetMapping(path = "/{id}")
4545
@ResponseStatus(HttpStatus.OK)
4646
public LabelDTO show(@PathVariable long id) {
47-
return labelService.getById(id);
47+
return labelServiceImpl.getById(id);
4848
}
4949

5050
/**
@@ -55,7 +55,7 @@ public LabelDTO show(@PathVariable long id) {
5555
@PostMapping(path = "")
5656
@ResponseStatus(HttpStatus.CREATED)
5757
public LabelDTO create(@Valid @RequestBody LabelCreateDTO dto) {
58-
return labelService.create(dto);
58+
return labelServiceImpl.create(dto);
5959
}
6060

6161
/**
@@ -67,7 +67,7 @@ public LabelDTO create(@Valid @RequestBody LabelCreateDTO dto) {
6767
@PutMapping(path = "/{id}")
6868
@ResponseStatus(HttpStatus.OK)
6969
public LabelDTO update(@PathVariable("id") Long id, @Valid @RequestBody LabelUpdateDTO dto) {
70-
return labelService.update(id, dto);
70+
return labelServiceImpl.update(id, dto);
7171
}
7272

7373
/**
@@ -77,6 +77,6 @@ public LabelDTO update(@PathVariable("id") Long id, @Valid @RequestBody LabelUpd
7777
@DeleteMapping(path = "/{id}")
7878
@ResponseStatus(HttpStatus.NO_CONTENT)
7979
public void delete(@PathVariable long id) {
80-
labelService.delete(id);
80+
labelServiceImpl.delete(id);
8181
}
8282
}

src/main/java/hexlet/code/controller/TaskController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import hexlet.code.dto.task.TaskDTO;
55
import hexlet.code.dto.task.TaskParamsDTO;
66
import hexlet.code.dto.task.TaskUpdateDTO;
7-
import hexlet.code.service.TaskService;
7+
import hexlet.code.service.TaskServiceImpl;
88
import hexlet.code.specification.TaskSpecification;
99
import jakarta.validation.Valid;
1010
import lombok.AllArgsConstructor;
@@ -27,7 +27,7 @@
2727
@AllArgsConstructor
2828
public class TaskController {
2929

30-
private final TaskService taskService;
30+
private final TaskServiceImpl taskServiceImpl;
3131
private final TaskSpecification specBuilder;
3232

3333
/**
@@ -36,7 +36,7 @@ public class TaskController {
3636
*/
3737
@GetMapping(path = "")
3838
public ResponseEntity<List<TaskDTO>> index(TaskParamsDTO dto) {
39-
var result = taskService.getAll(dto);
39+
var result = taskServiceImpl.getAll(dto);
4040
return ResponseEntity.ok().header("X-Total-Count", String.valueOf(result.size())).body(result);
4141
}
4242

@@ -47,7 +47,7 @@ public ResponseEntity<List<TaskDTO>> index(TaskParamsDTO dto) {
4747
@GetMapping(path = "/{id}")
4848
@ResponseStatus(HttpStatus.OK)
4949
public TaskDTO show(@PathVariable long id) {
50-
return taskService.getById(id);
50+
return taskServiceImpl.getById(id);
5151
}
5252

5353
/**
@@ -57,7 +57,7 @@ public TaskDTO show(@PathVariable long id) {
5757
@PostMapping(path = "")
5858
@ResponseStatus(HttpStatus.CREATED)
5959
public TaskDTO create(@Valid @RequestBody TaskCreateDTO dto) {
60-
return taskService.create(dto);
60+
return taskServiceImpl.create(dto);
6161
}
6262

6363
/**
@@ -68,7 +68,7 @@ public TaskDTO create(@Valid @RequestBody TaskCreateDTO dto) {
6868
@PutMapping(path = "/{id}")
6969
@ResponseStatus(HttpStatus.OK)
7070
public TaskDTO update(@PathVariable("id") Long id, @Valid @RequestBody TaskUpdateDTO dto) {
71-
return taskService.update(id, dto);
71+
return taskServiceImpl.update(id, dto);
7272
}
7373

7474
/**
@@ -77,6 +77,6 @@ public TaskDTO update(@PathVariable("id") Long id, @Valid @RequestBody TaskUpdat
7777
@DeleteMapping(path = "/{id}")
7878
@ResponseStatus(HttpStatus.NO_CONTENT)
7979
public void delete(@PathVariable long id) {
80-
taskService.delete(id);
80+
taskServiceImpl.delete(id);
8181
}
8282
}

src/main/java/hexlet/code/controller/TaskStatusController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import hexlet.code.dto.taskstatus.TaskStatusDTO;
66
import hexlet.code.dto.taskstatus.TaskStatusUpdateDTO;
77
import hexlet.code.repository.TaskStatusRepository;
8-
import hexlet.code.service.TaskStatusService;
8+
import hexlet.code.service.TaskStatusServiceImpl;
99
import jakarta.validation.Valid;
1010
import lombok.AllArgsConstructor;
1111
import org.springframework.http.HttpStatus;
@@ -27,14 +27,14 @@
2727
@AllArgsConstructor
2828
public class TaskStatusController {
2929
private final TaskStatusRepository taskStatusRepository;
30-
private final TaskStatusService taskStatusService;
30+
private final TaskStatusServiceImpl taskStatusServiceImpl;
3131

3232
/**
3333
* @return List<TaskStatusDTO>
3434
*/
3535
@GetMapping(path = "")
3636
public ResponseEntity<List<TaskStatusDTO>> index() {
37-
var result = taskStatusService.getAll();
37+
var result = taskStatusServiceImpl.getAll();
3838
return ResponseEntity.ok().header("X-Total-Count", String.valueOf(result.size())).body(result);
3939
}
4040

@@ -45,7 +45,7 @@ public ResponseEntity<List<TaskStatusDTO>> index() {
4545
@GetMapping(path = "/{id}")
4646
@ResponseStatus(HttpStatus.OK)
4747
public TaskStatusDTO show(@PathVariable long id) {
48-
return taskStatusService.getById(id);
48+
return taskStatusServiceImpl.getById(id);
4949
}
5050

5151
/**
@@ -55,7 +55,7 @@ public TaskStatusDTO show(@PathVariable long id) {
5555
@PostMapping(path = "")
5656
@ResponseStatus(HttpStatus.CREATED)
5757
public TaskStatusDTO create(@Valid @RequestBody TaskStatusCreateDTO dto) {
58-
return taskStatusService.create(dto);
58+
return taskStatusServiceImpl.create(dto);
5959
}
6060

6161
/**
@@ -66,7 +66,7 @@ public TaskStatusDTO create(@Valid @RequestBody TaskStatusCreateDTO dto) {
6666
@PutMapping(path = "/{id}")
6767
@ResponseStatus(HttpStatus.OK)
6868
public TaskStatusDTO update(@PathVariable("id") Long id, @Valid @RequestBody TaskStatusUpdateDTO dto) {
69-
return taskStatusService.update(id, dto);
69+
return taskStatusServiceImpl.update(id, dto);
7070
}
7171

7272
/**
@@ -75,6 +75,6 @@ public TaskStatusDTO update(@PathVariable("id") Long id, @Valid @RequestBody Tas
7575
@DeleteMapping(path = "/{id}")
7676
@ResponseStatus(HttpStatus.NO_CONTENT)
7777
public void delete(@PathVariable long id) {
78-
taskStatusService.delete(id);
78+
taskStatusServiceImpl.delete(id);
7979
}
8080
}

src/main/java/hexlet/code/controller/UserController.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import hexlet.code.dto.user.UserCreateDTO;
55
import hexlet.code.dto.user.UserUpdateDTO;
66
import hexlet.code.repository.UserRepository;
7-
import hexlet.code.service.UserService;
7+
import hexlet.code.service.UserServiceImpl;
88
import io.swagger.v3.oas.annotations.Operation;
99
import io.swagger.v3.oas.annotations.responses.ApiResponse;
1010
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -35,15 +35,15 @@
3535
public class UserController {
3636

3737
private final UserRepository userRepository;
38-
private final UserService userService;
38+
private final UserServiceImpl userServiceImpl;
3939

4040
/**
4141
* @return List<UserDTO>
4242
*/
4343
@GetMapping(path = "")
4444
// @ResponseStatus(HttpStatus.OK)
4545
public ResponseEntity<List<UserDTO>> index() {
46-
var result = userService.getAll();
46+
var result = userServiceImpl.getAll();
4747
return ResponseEntity.ok().header("X-Total-Count", String.valueOf(result.size())).body(result);
4848
}
4949

@@ -54,7 +54,7 @@ public ResponseEntity<List<UserDTO>> index() {
5454
@GetMapping(path = "/{id}")
5555
@ResponseStatus(HttpStatus.OK)
5656
public UserDTO show(@PathVariable long id) {
57-
return userService.getById(id);
57+
return userServiceImpl.getById(id);
5858
}
5959

6060

@@ -67,7 +67,7 @@ public UserDTO show(@PathVariable long id) {
6767
@PostMapping(path = "")
6868
@ResponseStatus(HttpStatus.CREATED)
6969
public UserDTO create(@Valid @RequestBody UserCreateDTO dto) {
70-
return userService.create(dto);
70+
return userServiceImpl.create(dto);
7171
}
7272

7373
/**
@@ -79,7 +79,7 @@ public UserDTO create(@Valid @RequestBody UserCreateDTO dto) {
7979
@PutMapping(path = "/{id}")
8080
@ResponseStatus(HttpStatus.OK)
8181
public UserDTO update(@PathVariable("id") Long id, @Valid @RequestBody UserUpdateDTO dto) {
82-
return userService.update(id, dto);
82+
return userServiceImpl.update(id, dto);
8383
}
8484

8585
/**
@@ -90,7 +90,7 @@ public UserDTO update(@PathVariable("id") Long id, @Valid @RequestBody UserUpdat
9090
@DeleteMapping(path = "/{id}")
9191
@ResponseStatus(HttpStatus.NO_CONTENT)
9292
public void delete(@PathVariable long id) {
93-
userService.delete(id);
93+
userServiceImpl.delete(id);
9494
}
9595

9696

src/main/java/hexlet/code/dto/label/LabelDTO.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package hexlet.code.dto.label;
22

3-
import java.time.LocalDateTime;
3+
import java.time.LocalDate;
4+
45
import com.fasterxml.jackson.annotation.JsonFormat;
56
import lombok.Getter;
67
import lombok.Setter;
@@ -11,5 +12,5 @@ public class LabelDTO {
1112
private Long id;
1213
private String name;
1314
@JsonFormat(pattern = "yyyy-MM-dd")
14-
private LocalDateTime createdAt;
15+
private LocalDate createdAt;
1516
}

src/main/java/hexlet/code/mapper/LabelMapper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
unmappedTargetPolicy = ReportingPolicy.IGNORE)
1717
public abstract class LabelMapper {
1818

19-
public abstract LabelDTO map(Label model);
20-
2119
public abstract Label map(LabelCreateDTO dto);
2220

21+
public abstract LabelDTO map(Label model);
22+
public abstract Label map(LabelDTO model);
23+
2324
public abstract void update(LabelUpdateDTO dto, @MappingTarget Label model);
2425
}

src/main/java/hexlet/code/mapper/ReferenceMapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
import hexlet.code.model.BaseEntity;
44
import jakarta.persistence.EntityManager;
5+
import jakarta.persistence.PersistenceContext;
56
import org.mapstruct.Mapper;
67
import org.mapstruct.MappingConstants;
78
import org.mapstruct.TargetType;
8-
import org.springframework.beans.factory.annotation.Autowired;
99

1010
@Mapper(
1111
componentModel = MappingConstants.ComponentModel.SPRING
1212
)
13-
@SuppressWarnings("java:S6813")
13+
1414
public abstract class ReferenceMapper {
15-
@Autowired
15+
@PersistenceContext
1616
private EntityManager entityManager;
1717

1818
/**

src/main/java/hexlet/code/mapper/TaskMapper.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.springframework.beans.factory.annotation.Autowired;
1818

1919
import java.util.HashSet;
20+
import java.util.List;
21+
import java.util.Optional;
2022
import java.util.Set;
2123
import java.util.stream.Collectors;
2224

@@ -71,8 +73,11 @@ public Set<Label> toLabels(Set<Long> taskLabelIds) {
7173
return new HashSet<>();
7274
} else {
7375
Set<Label> result = new HashSet<>();
76+
List<Label> listLabels = labelRepository.findAll();
7477
for (Long n : taskLabelIds) {
75-
var value = labelRepository.findById(n);
78+
Optional<Label> value = listLabels.stream()
79+
.filter(v -> (v.getId() == n))
80+
.findFirst();
7681
if (value.isPresent()) {
7782
result.add(value.get());
7883
}

0 commit comments

Comments
 (0)