Skip to content

Commit 2722f7f

Browse files
committed
CLAP-121 Refactor: 사용자 작업상세정보, 관리자 작업상세정보 분리
1 parent 5554aab commit 2722f7f

File tree

9 files changed

+112
-16
lines changed

9 files changed

+112
-16
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package clap.server.adapter.inbound.web.dto.task;
2+
3+
import clap.server.adapter.outbound.persistense.entity.task.constant.TaskStatus;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.List;
7+
8+
public record FindTaskDetailsForManagerResponse(
9+
Long taskId,
10+
String taskCode,
11+
LocalDateTime requestedAt,
12+
LocalDateTime finishedAt,
13+
TaskStatus taskStatus,
14+
String requesterNickName,
15+
String requesterImageUrl,
16+
String processorNickName,
17+
String processorImageUrl,
18+
String mainCategoryName,
19+
String categoryName,
20+
String title,
21+
String description,
22+
LocalDateTime dueDate,
23+
String labelName,
24+
List<AttachmentResponse> attachmentResponses
25+
) implements TaskDetailsResponse {}

src/main/java/clap/server/adapter/inbound/web/dto/task/FindTaskDetailsResponse.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ public record FindTaskDetailsResponse(
2121
String description,
2222
List<AttachmentResponse> attachmentResponses
2323

24-
//TODO: taskhistory 및 comment 정보 추가
25-
) {}
24+
) implements TaskDetailsResponse {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package clap.server.adapter.inbound.web.dto.task;
2+
3+
import clap.server.adapter.outbound.persistense.entity.task.constant.TaskStatus;
4+
5+
import java.time.LocalDateTime;
6+
import java.util.List;
7+
8+
public interface TaskDetailsResponse {
9+
Long taskId();
10+
String taskCode();
11+
LocalDateTime requestedAt();
12+
LocalDateTime finishedAt();
13+
TaskStatus taskStatus();
14+
String requesterNickName();
15+
String requesterImageUrl();
16+
String processorNickName();
17+
String processorImageUrl();
18+
String mainCategoryName();
19+
String categoryName();
20+
String title();
21+
String description();
22+
List<AttachmentResponse> attachmentResponses();
23+
}

src/main/java/clap/server/adapter/inbound/web/task/FindTaskController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public ResponseEntity<Page<FilterRequestedTasksResponse>> findTasksRequestedByUs
3737
Pageable pageable = PageRequest.of(page, pageSize);
3838
return ResponseEntity.ok(taskListUsecase.findTasksRequestedByUser(userInfo.getUserId(), pageable, filterTaskListRequest));
3939
}
40-
4140
@Operation(summary = "요청한 작업 상세 조회")
4241
@Secured({"ROLE_USER", "ROLE_MANAGER"})
4342
@GetMapping("/requests/details/{taskId}")
@@ -70,4 +69,13 @@ public ResponseEntity<Page<FilterAllTasksResponse>> findAllTasks(
7069
Pageable pageable = PageRequest.of(page, pageSize);
7170
return ResponseEntity.ok(taskListUsecase.findAllTasks(userInfo.getUserId(), pageable, filterTaskListRequest));
7271
}
72+
73+
@Operation(summary = "전체요청, 내 작업에 대한 상세 조회")
74+
@Secured("ROLE_MANAGER")
75+
@GetMapping("/details/{taskId}")
76+
public ResponseEntity<FindTaskDetailsForManagerResponse> findRequestedTaskDetailsForManager(
77+
@PathVariable Long taskId,
78+
@AuthenticationPrincipal SecurityUserDetails userInfo) {
79+
return ResponseEntity.ok(taskDetailsUsecase.findTaskDetailsForManager(userInfo.getUserId(), taskId));
80+
}
7381
}

src/main/java/clap/server/application/Task/FindTaskDetailsService.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package clap.server.application.Task;
22

3+
import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsForManagerResponse;
34
import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsResponse;
45
import clap.server.adapter.outbound.persistense.entity.task.TaskEntity;
56
import clap.server.application.mapper.TaskMapper;
@@ -35,4 +36,13 @@ public FindTaskDetailsResponse findRequestedTaskDetails(final Long requesterId,
3536
List<Attachment> attachments = loadAttachmentPort.findAllByTaskIdAndCommentIsNull(taskId);
3637
return TaskMapper.toFindTaskDetailResponse(task, attachments);
3738
}
39+
40+
@Override
41+
public FindTaskDetailsForManagerResponse findTaskDetailsForManager(final Long requesterId, final Long taskId) {
42+
memberService.findActiveMember(requesterId);
43+
Task task = loadTaskPort.findById(taskId)
44+
.orElseThrow(() -> new ApplicationException(TaskErrorCode.TASK_NOT_FOUND));
45+
List<Attachment> attachments = loadAttachmentPort.findAllByTaskIdAndCommentIsNull(taskId);
46+
return TaskMapper.toFindTaskDetailForManagerResponse(task, attachments);
47+
}
3848
}

src/main/java/clap/server/application/mapper/AttachmentMapper.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package clap.server.application.mapper;
22

3+
import clap.server.adapter.inbound.web.dto.task.AttachmentResponse;
34
import clap.server.domain.model.task.Attachment;
45
import clap.server.domain.model.task.Task;
56
import org.springframework.web.multipart.MultipartFile;
@@ -25,5 +26,17 @@ public static List<Attachment> toTaskAttachments(Task task, List<MultipartFile>
2526
.toList();
2627
}
2728

29+
public static List<AttachmentResponse> toAttachmentResponseList(List<Attachment> attachments) {
30+
return attachments.stream()
31+
.map(attachment -> new AttachmentResponse(
32+
attachment.getAttachmentId(),
33+
attachment.getOriginalName(),
34+
attachment.getFileSize(),
35+
attachment.getFileUrl(),
36+
attachment.getCreatedAt()
37+
))
38+
.toList();
39+
}
40+
2841
}
2942

src/main/java/clap/server/application/mapper/TaskMapper.java

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.util.Map;
1515
import java.util.stream.Collectors;
1616

17+
import static clap.server.application.mapper.AttachmentMapper.toAttachmentResponseList;
18+
1719
public class TaskMapper {
1820
private TaskMapper() {
1921
throw new IllegalArgumentException();
@@ -54,17 +56,7 @@ public static FilterPendingApprovalResponse toFilterPendingApprovalTasksResponse
5456
}
5557

5658
public static FindTaskDetailsResponse toFindTaskDetailResponse(Task task, List<Attachment> attachments){
57-
58-
List<AttachmentResponse> attachmentResponses = attachments.stream()
59-
.map(attachment -> new AttachmentResponse(
60-
attachment.getAttachmentId(),
61-
attachment.getOriginalName(),
62-
attachment.getFileSize(),
63-
attachment.getFileUrl(),
64-
attachment.getCreatedAt()
65-
))
66-
.collect(Collectors.toList());
67-
59+
List<AttachmentResponse> attachmentResponses = toAttachmentResponseList(attachments);
6860
return new FindTaskDetailsResponse(
6961
task.getTaskId(),
7062
task.getTaskCode(),
@@ -138,4 +130,26 @@ private static TaskItemResponse toTaskItemResponse(Task task) {
138130
task.getCreatedAt()
139131
);
140132
}
133+
134+
public static FindTaskDetailsForManagerResponse toFindTaskDetailForManagerResponse(Task task, List<Attachment> attachments) {
135+
List<AttachmentResponse> attachmentResponses = toAttachmentResponseList(attachments);
136+
return new FindTaskDetailsForManagerResponse(
137+
task.getTaskId(),
138+
task.getTaskCode(),
139+
task.getCreatedAt(),
140+
task.getFinishedAt(),
141+
task.getTaskStatus(),
142+
task.getRequester().getMemberInfo().getNickname(),
143+
task.getRequester().getImageUrl(),
144+
task.getProcessor() != null ? task.getProcessor().getMemberInfo().getNickname() : "",
145+
task.getProcessor() != null ? task.getProcessor().getImageUrl() : "",
146+
task.getCategory().getMainCategory().getName(),
147+
task.getCategory().getName(),
148+
task.getTitle(),
149+
task.getDescription(),
150+
task.getDueDate(),
151+
task.getLabel() != null ? task.getLabel().getLabelName() : "",
152+
attachmentResponses
153+
);
154+
}
141155
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package clap.server.application.port.inbound.task;
22

33
import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsResponse;
4-
5-
import java.util.List;
4+
import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsForManagerResponse;
65

76
public interface FindTaskDetailsUsecase {
87
FindTaskDetailsResponse findRequestedTaskDetails(Long memberId, Long taskId);
8+
9+
FindTaskDetailsForManagerResponse findTaskDetailsForManager(Long memberId, Long taskId);
910
}

src/main/java/clap/server/application/port/outbound/task/LoadTaskPort.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package clap.server.application.port.outbound.task;
22

3+
import clap.server.adapter.inbound.web.dto.task.FilterAllTasksResponse;
4+
import clap.server.adapter.inbound.web.dto.task.FilterTaskListRequest;
5+
import clap.server.adapter.inbound.web.dto.task.FilterRequestedTasksResponse;
36
import clap.server.adapter.inbound.web.dto.task.FilterPendingApprovalResponse;
47
import clap.server.adapter.inbound.web.dto.task.FilterAllTasksResponse;
58
import clap.server.adapter.inbound.web.dto.task.FilterTaskListRequest;

0 commit comments

Comments
 (0)