Skip to content

Commit

Permalink
[BE/#17] Refactor : issueService 리팩토링
Browse files Browse the repository at this point in the history
- Issue 도메인을 IssueDeatils로 만드는 로직을 mapToIssueDeatils 메서드 분리
  • Loading branch information
MuseopKim committed Jun 12, 2020
1 parent c6e3ed3 commit 0aa888d
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,9 @@ public IssueService(IssueDao issueDao, UserService userService, MilestoneService

public ListOfIssuesDto findAllIssues() {
List<Issue> allOfOpenedIssues = issueDao.findAllOpendIssues();
List<IssueDetails> issues = allOfOpenedIssues.stream().map(issue -> {
Milestone milestone = milestoneService.findMilestoneById(issue.getMilestoneId());
List<LabelSummary> attachedLabels = labelService.findAttachedLabelsByIssueId(issue.getId());
List<UserSummary> allocatedAssignees = userService.findAllocatedAssigneesByIds(issue.getId());
User user = userService.findUserById(issue.getUserId());
return new IssueDetails.Builder()
.issueId(issue.getId())
.issueTitle(issue.getTitle())
.milestone(MilestoneSummary.create(milestone.getId(), milestone.getTitle()))
.attachedLabels(attachedLabels)
.author(UserSummary.create(user.getId(), user.getName(), user.getAvatarUrl()))
.allocatedAssignees(allocatedAssignees)
.createdAt(issue.getCreatedDateTime())
.opened(issue.isOpened())
.build();
}).collect(Collectors.toList());
List<IssueDetails> issues = allOfOpenedIssues.stream()
.map(this::mapToIssueDetails)
.collect(Collectors.toList());
LabelInformation labelInformation = labelService.findAllLabels();
MilestoneInformation milestoneInformation = milestoneService.findAllMilestones();
List<UserSummary> assigneeInformation = userService.findAllAssignees();
Expand All @@ -62,4 +49,21 @@ public ListOfIssuesDto findAllIssues() {
.assigneeInfo(assigneeInformation)
.build();
}

private IssueDetails mapToIssueDetails(Issue issue) {
Milestone milestone = milestoneService.findMilestoneById(issue.getMilestoneId());
List<LabelSummary> attachedLabels = labelService.findAttachedLabelsByIssueId(issue.getId());
List<UserSummary> allocatedAssignees = userService.findAllocatedAssigneesByIds(issue.getId());
User user = userService.findUserById(issue.getUserId());
return new IssueDetails.Builder()
.issueId(issue.getId())
.issueTitle(issue.getTitle())
.milestone(MilestoneSummary.create(milestone.getId(), milestone.getTitle()))
.attachedLabels(attachedLabels)
.author(UserSummary.create(user.getId(), user.getName(), user.getAvatarUrl()))
.allocatedAssignees(allocatedAssignees)
.createdAt(issue.getCreatedDateTime())
.opened(issue.isOpened())
.build();
}
}

0 comments on commit 0aa888d

Please sign in to comment.