Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package clap.server.adapter.inbound.web.dto.task;

import clap.server.adapter.outbound.persistense.entity.task.constant.TaskStatus;

import java.time.LocalDateTime;
import java.util.List;

public record FindTaskDetailsForManagerResponse(
Long taskId,
String taskCode,
LocalDateTime requestedAt,
LocalDateTime finishedAt,
TaskStatus taskStatus,
String requesterNickName,
String requesterImageUrl,
String processorNickName,
String processorImageUrl,
String mainCategoryName,
String categoryName,
String title,
String description,
LocalDateTime dueDate,
String labelName,
List<AttachmentResponse> attachmentResponses
) implements TaskDetailsResponse {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ public record FindTaskDetailsResponse(
String description,
List<AttachmentResponse> attachmentResponses

//TODO: taskhistory 및 comment 정보 추가
) {}
) implements TaskDetailsResponse {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package clap.server.adapter.inbound.web.dto.task;

import clap.server.adapter.outbound.persistense.entity.task.constant.TaskStatus;

import java.time.LocalDateTime;
import java.util.List;

public interface TaskDetailsResponse {
Long taskId();
String taskCode();
LocalDateTime requestedAt();
LocalDateTime finishedAt();
TaskStatus taskStatus();
String requesterNickName();
String requesterImageUrl();
String processorNickName();
String processorImageUrl();
String mainCategoryName();
String categoryName();
String title();
String description();
List<AttachmentResponse> attachmentResponses();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public ResponseEntity<Page<FilterRequestedTasksResponse>> findTasksRequestedByUs
Pageable pageable = PageRequest.of(page, pageSize);
return ResponseEntity.ok(taskListUsecase.findTasksRequestedByUser(userInfo.getUserId(), pageable, filterTaskListRequest));
}

@Operation(summary = "요청한 작업 상세 조회")
@Secured({"ROLE_USER", "ROLE_MANAGER"})
@GetMapping("/requests/details/{taskId}")
Expand Down Expand Up @@ -70,4 +69,13 @@ public ResponseEntity<Page<FilterAllTasksResponse>> findAllTasks(
Pageable pageable = PageRequest.of(page, pageSize);
return ResponseEntity.ok(taskListUsecase.findAllTasks(userInfo.getUserId(), pageable, filterTaskListRequest));
}

@Operation(summary = "전체요청, 내 작업에 대한 상세 조회")
@Secured("ROLE_MANAGER")
@GetMapping("/details/{taskId}")
public ResponseEntity<FindTaskDetailsForManagerResponse> findRequestedTaskDetailsForManager(
@PathVariable Long taskId,
@AuthenticationPrincipal SecurityUserDetails userInfo) {
return ResponseEntity.ok(taskDetailsUsecase.findTaskDetailsForManager(userInfo.getUserId(), taskId));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package clap.server.application.Task;

import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsForManagerResponse;
import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsResponse;
import clap.server.adapter.outbound.persistense.entity.task.TaskEntity;
import clap.server.application.mapper.TaskMapper;
Expand Down Expand Up @@ -35,4 +36,13 @@ public FindTaskDetailsResponse findRequestedTaskDetails(final Long requesterId,
List<Attachment> attachments = loadAttachmentPort.findAllByTaskIdAndCommentIsNull(taskId);
return TaskMapper.toFindTaskDetailResponse(task, attachments);
}

@Override
public FindTaskDetailsForManagerResponse findTaskDetailsForManager(final Long requesterId, final Long taskId) {
memberService.findActiveMember(requesterId);
Task task = loadTaskPort.findById(taskId)
.orElseThrow(() -> new ApplicationException(TaskErrorCode.TASK_NOT_FOUND));
List<Attachment> attachments = loadAttachmentPort.findAllByTaskIdAndCommentIsNull(taskId);
return TaskMapper.toFindTaskDetailForManagerResponse(task, attachments);
}
}
13 changes: 13 additions & 0 deletions src/main/java/clap/server/application/mapper/AttachmentMapper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package clap.server.application.mapper;

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

public static List<AttachmentResponse> toAttachmentResponseList(List<Attachment> attachments) {
return attachments.stream()
.map(attachment -> new AttachmentResponse(
attachment.getAttachmentId(),
attachment.getOriginalName(),
attachment.getFileSize(),
attachment.getFileUrl(),
attachment.getCreatedAt()
))
.toList();
}

}

36 changes: 25 additions & 11 deletions src/main/java/clap/server/application/mapper/TaskMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Map;
import java.util.stream.Collectors;

import static clap.server.application.mapper.AttachmentMapper.toAttachmentResponseList;

public class TaskMapper {
private TaskMapper() {
throw new IllegalArgumentException();
Expand Down Expand Up @@ -54,17 +56,7 @@ public static FilterPendingApprovalResponse toFilterPendingApprovalTasksResponse
}

public static FindTaskDetailsResponse toFindTaskDetailResponse(Task task, List<Attachment> attachments){

List<AttachmentResponse> attachmentResponses = attachments.stream()
.map(attachment -> new AttachmentResponse(
attachment.getAttachmentId(),
attachment.getOriginalName(),
attachment.getFileSize(),
attachment.getFileUrl(),
attachment.getCreatedAt()
))
.collect(Collectors.toList());

List<AttachmentResponse> attachmentResponses = toAttachmentResponseList(attachments);
return new FindTaskDetailsResponse(
task.getTaskId(),
task.getTaskCode(),
Expand Down Expand Up @@ -138,4 +130,26 @@ private static TaskItemResponse toTaskItemResponse(Task task) {
task.getCreatedAt()
);
}

public static FindTaskDetailsForManagerResponse toFindTaskDetailForManagerResponse(Task task, List<Attachment> attachments) {
List<AttachmentResponse> attachmentResponses = toAttachmentResponseList(attachments);
return new FindTaskDetailsForManagerResponse(
task.getTaskId(),
task.getTaskCode(),
task.getCreatedAt(),
task.getFinishedAt(),
task.getTaskStatus(),
task.getRequester().getMemberInfo().getNickname(),
task.getRequester().getImageUrl(),
task.getProcessor() != null ? task.getProcessor().getMemberInfo().getNickname() : "",
task.getProcessor() != null ? task.getProcessor().getImageUrl() : "",
task.getCategory().getMainCategory().getName(),
task.getCategory().getName(),
task.getTitle(),
task.getDescription(),
task.getDueDate(),
task.getLabel() != null ? task.getLabel().getLabelName() : "",
attachmentResponses
);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package clap.server.application.port.inbound.task;

import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsResponse;

import java.util.List;
import clap.server.adapter.inbound.web.dto.task.FindTaskDetailsForManagerResponse;

public interface FindTaskDetailsUsecase {
FindTaskDetailsResponse findRequestedTaskDetails(Long memberId, Long taskId);

FindTaskDetailsForManagerResponse findTaskDetailsForManager(Long memberId, Long taskId);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package clap.server.application.port.outbound.task;

import clap.server.adapter.inbound.web.dto.task.FilterAllTasksResponse;
import clap.server.adapter.inbound.web.dto.task.FilterTaskListRequest;
import clap.server.adapter.inbound.web.dto.task.FilterRequestedTasksResponse;
import clap.server.adapter.inbound.web.dto.task.FilterPendingApprovalResponse;
import clap.server.adapter.inbound.web.dto.task.FilterAllTasksResponse;
import clap.server.adapter.inbound.web.dto.task.FilterTaskListRequest;
Expand Down
Loading