-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskHistoryResponseMapper.java
More file actions
71 lines (64 loc) · 3.83 KB
/
TaskHistoryResponseMapper.java
File metadata and controls
71 lines (64 loc) · 3.83 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
package clap.server.application.mapper.response;
import clap.server.adapter.inbound.web.dto.history.response.FindTaskHistoryResponse;
import clap.server.domain.model.task.Attachment;
import clap.server.domain.model.task.TaskHistory;
import java.util.List;
public class TaskHistoryResponseMapper {
private TaskHistoryResponseMapper() {
throw new IllegalArgumentException("Utility class");
}
public static FindTaskHistoryResponse toFindTaskHistoryResponse(List<TaskHistory> taskHistories) {
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.getModifiedMember().getNickname()
),
null,
null
);
case STATUS_SWITCHED, TASK_TERMINATED -> new FindTaskHistoryResponse.Details(
new FindTaskHistoryResponse.TaskDetails(
taskHistory.getTaskModificationInfo().getModifiedStatus()
),
null,
null
);
case COMMENT -> new FindTaskHistoryResponse.Details(
null,
new FindTaskHistoryResponse.CommentDetails(
taskHistory.getComment().getCommentId(),
taskHistory.getModifiedMember().getNickname(),
taskHistory.getModifiedMember().getImageUrl(),
taskHistory.getComment().isModified(),
taskHistory.getComment().getContent()
),
null
);
case COMMENT_FILE -> new FindTaskHistoryResponse.Details(
null,
null,
new FindTaskHistoryResponse.CommentFileDetails(
taskHistory.getComment().getCommentId(),
taskHistory.getModifiedMember().getNickname(),
taskHistory.getModifiedMember().getImageUrl(),
taskHistory.getComment().getOriginalName(),
taskHistory.getComment().getFileUrl(),
taskHistory.getComment().getFileSize()
)
);
};
return new FindTaskHistoryResponse.TaskHistoryResponse(
taskHistory.getTaskHistoryId(),
taskHistory.getCreatedAt().toLocalDate(),
taskHistory.getCreatedAt().toLocalTime(),
taskHistory.getType(),
details
);
})
.toList();
return new FindTaskHistoryResponse(historyResponses);
}
}