-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskMapper.java
More file actions
90 lines (78 loc) · 3.52 KB
/
TaskMapper.java
File metadata and controls
90 lines (78 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package clap.server.application.mapper;
import clap.server.adapter.inbound.web.dto.task.*;
import clap.server.domain.model.task.Attachment;
import clap.server.domain.model.task.Task;
import java.util.List;
import java.util.stream.Collectors;
public class TaskMapper {
private TaskMapper() {
throw new IllegalArgumentException();
}
public static CreateTaskResponse toCreateTaskResponse(Task task) {
return new CreateTaskResponse(task.getTaskId(), task.getCategory().getCategoryId(), task.getTitle());
}
public static UpdateTaskResponse toUpdateTaskResponse(Task task) {
return new UpdateTaskResponse(task.getTaskId(), task.getCategory().getCategoryId(), task.getTitle());
}
public static FilterTaskListResponse toFilterTaskListResponse(Task task) {
return new FilterTaskListResponse(
task.getTaskId(),
task.getTaskCode(),
task.getUpdatedAt(),
task.getCategory().getMainCategory().getName(),
task.getCategory().getName(),
task.getTitle(),
task.getProcessor() != null ? task.getProcessor().getMemberInfo().getNickname() : "",
task.getTaskStatus(),
task.getCompletedAt() != null ? task.getCompletedAt() : null
);
}
public static FilterPendingApprovalResponse toFilterPendingApprovalTasksResponse(Task task) {
return new FilterPendingApprovalResponse(
task.getTaskId(),
task.getTaskCode(),
task.getUpdatedAt(),
task.getCategory().getMainCategory().getName(),
task.getCategory().getName(),
task.getTitle(),
task.getRequester().getMemberInfo().getNickname()
);
}
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());
return new FindTaskDetailsResponse(
task.getTaskId(),
task.getTaskCode(),
task.getCreatedAt(),
task.getCompletedAt(),
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(),
attachmentResponses
);
}
public static ApprovalTaskResponse toApprovalTaskResponse(Task approvedTask) {
return new ApprovalTaskResponse(
approvedTask.getTaskId(),
approvedTask.getProcessor().getNickname(),
approvedTask.getReviewer().getNickname(),
approvedTask.getDueDate(),
approvedTask.getLabel().getLabelName(),
approvedTask.getTaskStatus()
);
}
}