-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTaskHistoryMapper.java
More file actions
74 lines (67 loc) · 4.15 KB
/
TaskHistoryMapper.java
File metadata and controls
74 lines (67 loc) · 4.15 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
package clap.server.application.mapper;
import clap.server.adapter.inbound.web.dto.task.response.FindTaskHistoryResponse;
import clap.server.domain.model.task.Attachment;
import clap.server.domain.model.task.TaskHistory;
import java.util.List;
public class TaskHistoryMapper {
private TaskHistoryMapper() {
throw new IllegalArgumentException();
}
public static FindTaskHistoryResponse toFindTaskHistoryResponse(List<TaskHistory> taskHistories, List<Attachment> attachments) {
List<FindTaskHistoryResponse.TaskHistoryResponse> historyResponses = taskHistories.stream()
.map(taskHistory -> {
FindTaskHistoryResponse.Details details =
switch (taskHistory.getType()) {
case PROCESSOR_CHANGED, PROCESSOR_ASSIGNED -> new FindTaskHistoryResponse.Details(
new FindTaskHistoryResponse.TaskDetails(
taskHistory.getTaskModificationInfo().getModifiedMember().getNickname()
),
null,
null
);
case STATUS_SWITCHED -> new FindTaskHistoryResponse.Details(
new FindTaskHistoryResponse.TaskDetails(
taskHistory.getTaskModificationInfo().getTask().getTaskStatus().getDescription()
),
null,
null
);
case COMMENT -> new FindTaskHistoryResponse.Details(
null,
new FindTaskHistoryResponse.CommentDetails(
taskHistory.getComment().getMember().getNickname(),
taskHistory.getComment().getMember().getImageUrl(),
taskHistory.getComment().isModified(),
taskHistory.getComment().getContent()
),
null
);
case COMMENT_FILE -> new FindTaskHistoryResponse.Details(
null,
null,
attachments.stream()
.filter(attachment -> attachment.getComment().getCommentId().equals(taskHistory.getComment().getCommentId()))
.findFirst()
.map(attachment -> new FindTaskHistoryResponse.CommentFileDetails(
taskHistory.getComment().getMember().getNickname(),
taskHistory.getComment().getMember().getImageUrl(),
taskHistory.getComment().isModified(),
attachment.getOriginalName(),
attachment.getFileUrl(),
attachment.getFileSize()
))
.orElse(null)
);
};
return new FindTaskHistoryResponse.TaskHistoryResponse(
taskHistory.getTaskHistoryId(),
taskHistory.getUpdatedAt().toLocalDate(),
taskHistory.getUpdatedAt().toLocalTime(),
taskHistory.getType(),
details
);
})
.toList();
return new FindTaskHistoryResponse(historyResponses);
}
}