Skip to content

Commit 17c624c

Browse files
Step09 - done
1 parent 28b99a9 commit 17c624c

24 files changed

Lines changed: 152 additions & 97 deletions

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package hexlet.code.controller;
22

3-
43
import hexlet.code.dto.AuthRequest;
54
import hexlet.code.util.JWTUtils;
6-
import org.springframework.beans.factory.annotation.Autowired;
5+
import lombok.AllArgsConstructor;
76
import org.springframework.security.authentication.AuthenticationManager;
87
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
98
import org.springframework.web.bind.annotation.PostMapping;
@@ -13,12 +12,10 @@
1312

1413
@RestController
1514
@RequestMapping("/api/login")
15+
@AllArgsConstructor
1616
public class AuthenticationController {
17-
@Autowired
18-
private JWTUtils jwtUtils;
19-
20-
@Autowired
21-
private AuthenticationManager authenticationManager;
17+
private final JWTUtils jwtUtils;
18+
private final AuthenticationManager authenticationManager;
2219

2320
/**
2421
*

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

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

3-
43
import hexlet.code.dto.task.TaskCreateDTO;
54
import hexlet.code.dto.task.TaskDTO;
5+
import hexlet.code.dto.task.TaskParamsDTO;
66
import hexlet.code.dto.task.TaskUpdateDTO;
77
import hexlet.code.service.TaskService;
8+
import hexlet.code.specification.TaskSpecification;
89
import jakarta.validation.Valid;
910
import lombok.AllArgsConstructor;
1011
import org.springframework.http.HttpStatus;
@@ -27,13 +28,16 @@
2728
public class TaskController {
2829

2930
private final TaskService taskService;
31+
private final TaskSpecification specBuilder;
3032

3133
/**
34+
* @param dto
3235
* @return List<TaskDTO>
3336
*/
3437
@GetMapping(path = "")
35-
public ResponseEntity<List<TaskDTO>> index() {
36-
var result = taskService.getAll();
38+
public ResponseEntity<List<TaskDTO>> index(TaskParamsDTO dto) {
39+
// repository.findAll(/* спецификация */, PageRequest.of(/* текущая страница */, 10));
40+
var result = taskService.getAll(dto);
3741
return ResponseEntity.ok().header("X-Total-Count", String.valueOf(result.size())).body(result);
3842
}
3943

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import hexlet.code.repository.TaskStatusRepository;
88
import hexlet.code.service.TaskStatusService;
99
import jakarta.validation.Valid;
10-
import org.springframework.beans.factory.annotation.Autowired;
10+
import lombok.AllArgsConstructor;
1111
import org.springframework.http.HttpStatus;
1212
import org.springframework.http.ResponseEntity;
1313
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -24,12 +24,10 @@
2424

2525
@RestController
2626
@RequestMapping("/api/task_statuses")
27+
@AllArgsConstructor
2728
public class TaskStatusController {
28-
@Autowired
29-
private TaskStatusRepository taskStatusRepository;
30-
31-
@Autowired
32-
private TaskStatusService taskStatusService;
29+
private final TaskStatusRepository taskStatusRepository;
30+
private final TaskStatusService taskStatusService;
3331

3432
/**
3533
* @return List<TaskStatusDTO>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
@RestController
2828
@RequestMapping("/api/users")
2929
@AllArgsConstructor
30+
//@RequredArgsConstructor
3031
public class UserController {
3132
// private static final String ONLY_OWNER_BY_ID = """
3233
// @userRepository.findById(#id).get().getEmail() == authentication.getName()
3334
// """;
3435

35-
3636
private final UserRepository userRepository;
3737
private final UserService userService;
3838

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
public class LabelCreateDTO {
1111
@NotNull
1212
@Size(min = 3, max = 1000)
13-
String name;
13+
private String name;
1414
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
@Getter
99
@Setter
1010
public class LabelDTO {
11-
Long id;
12-
String name;
11+
private Long id;
12+
private String name;
1313
@JsonFormat(pattern = "yyyy-MM-dd")
1414
private LocalDateTime createdAt;
1515
}

src/main/java/hexlet/code/dto/task/TaskCreateDTO.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ public class TaskCreateDTO {
1414

1515
@NotNull
1616
@Size(min = 1)
17-
String title;
17+
private String title;
1818

19-
String content;
20-
Integer index;
19+
private String content;
20+
private Integer index;
2121

2222
@NotNull
2323
@JsonProperty("status")
24-
String status;
24+
private String status;
2525

2626
@JsonProperty("assignee_id")
27-
Long assigneeId;
27+
private Long assigneeId;
2828

2929
private Set<Long> taskLabelIds;
3030

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package hexlet.code.dto.task;
2+
3+
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
7+
@Getter
8+
@Setter
9+
public class TaskParamsDTO {
10+
11+
private String titleCont; // название задачи содержит подстроку
12+
private Long assigneeId; // идентификатор исполнителя задачи
13+
private String status; // слаг статуса задачи
14+
private Long labelId; // идентификатор метки задачи
15+
16+
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package hexlet.code.mapper;
22

3-
43
import hexlet.code.dto.label.LabelCreateDTO;
54
import hexlet.code.dto.label.LabelDTO;
65
import hexlet.code.dto.label.LabelUpdateDTO;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.mapstruct.TargetType;
88
import org.springframework.beans.factory.annotation.Autowired;
99

10-
1110
@Mapper(
1211
componentModel = MappingConstants.ComponentModel.SPRING
1312
)

0 commit comments

Comments
 (0)