Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#83] 이슈 수정 버그 해결 assignee dto image URL 추가 #84

Merged
merged 6 commits into from
May 3, 2024
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
Expand Up @@ -44,16 +44,19 @@ public ContentDto() {
public static class AssigneeDto {
private Long id;
private String name;
private String profileImageURL;

public AssigneeDto() {
this.id = null;
this.name = "";
this.profileImageURL = "";
}

public static AssigneeDto from(Long id, String name) {
public static AssigneeDto from(Long id, String name, String profileImageURL) {
return AssigneeDto.builder()
.id(id)
.name(name)
.profileImageURL(profileImageURL)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public void updateStory(IssueEditRequest request, Member assignee, Epic upEpic)
if (this.epic != null) {
this.epic.getStories().remove(this);
}

this.epic = upEpic;
upEpic.getStories().add(this);
if (upEpic != null) {
upEpic.getStories().add(this);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public void updateTask(IssueEditRequest request, Member assignee, Story upStory)
this.story.getTasks().remove(this);
}
this.story = upStory;
upStory.getTasks().add(this);
if (upStory != null) {
upStory.getTasks().add(this);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ public IssueReadResponseDto getIssue(String key, Long issueId, AuthMember authMe
List<SubIssueDto> childIssueDtos = issueFactory.createChildIssueDtos(issue);

return IssueReadResponseDto.builder()
.issue(issueDto)
.parentIssue(parentIssueDto)
.childIssues(childIssueDtos)
.build();
.issue(issueDto)
.parentIssue(parentIssueDto)
.childIssues(childIssueDtos)
.build();
}


Expand All @@ -90,8 +90,8 @@ public List<StoryResponse> getStoriesByEpic(String key, Long epicId, AuthMember
List<Story> storiesByEpic = storyRepository.findStoriesByEpicId(epicId);

return storiesByEpic.stream()
.map(story -> StoryResponse.fromEntity(story, project.getKey(), epicId))
.toList();
.map(story -> StoryResponse.fromEntity(story, project.getKey(), epicId))
.toList();
}

public List<TaskResponse> getTasksByStory(String key, Long storyId, AuthMember authMember) {
Expand All @@ -100,8 +100,8 @@ public List<TaskResponse> getTasksByStory(String key, Long storyId, AuthMember a
List<Task> tasksByStory = taskRepository.findByStoryId(storyId);

return tasksByStory.stream()
.map(task -> TaskResponse.fromEntity(task, project.getKey(), storyId))
.toList();
.map(task -> TaskResponse.fromEntity(task, project.getKey(), storyId))
.toList();
}

public List<SimpleIssueResponse> getEpics(String key, AuthMember authMember) {
Expand All @@ -110,11 +110,11 @@ public List<SimpleIssueResponse> getEpics(String key, AuthMember authMember) {
List<Epic> epicsByProject = epicRepository.findByProject(project);

return epicsByProject.stream()
.map(epic -> {
AssigneeDto assigneeDto = createAssigneeDto(epic);
return SimpleIssueResponse.fromEntity(epic, project.getKey(), IssueType.EPIC, assigneeDto);
})
.toList();
.map(epic -> {
AssigneeDto assigneeDto = createAssigneeDto(epic);
return SimpleIssueResponse.fromEntity(epic, project.getKey(), IssueType.EPIC, assigneeDto);
})
.toList();
}


Expand All @@ -124,11 +124,11 @@ public List<SimpleIssueResponse> getStories(String key, AuthMember authMember) {
List<Story> storiesByProject = storyRepository.findByProject(project);

return storiesByProject.stream()
.map(story -> {
AssigneeDto assigneeDto = createAssigneeDto(story);
return SimpleIssueResponse.fromEntity(story, project.getKey(), IssueType.STORY, assigneeDto);
})
.toList();
.map(story -> {
AssigneeDto assigneeDto = createAssigneeDto(story);
return SimpleIssueResponse.fromEntity(story, project.getKey(), IssueType.STORY, assigneeDto);
})
.toList();
}

public List<SimpleIssueResponse> getTasks(String key, AuthMember authMember) {
Expand All @@ -137,49 +137,50 @@ public List<SimpleIssueResponse> getTasks(String key, AuthMember authMember) {
List<Task> tasksByProject = taskRepository.findByProject(project);

return tasksByProject.stream()
.map(task -> {
AssigneeDto assigneeDto = createAssigneeDto(task);
return SimpleIssueResponse.fromEntity(task, project.getKey(), IssueType.TASK, assigneeDto);
})
.toList();
.map(task -> {
AssigneeDto assigneeDto = createAssigneeDto(task);
return SimpleIssueResponse.fromEntity(task, project.getKey(), IssueType.TASK, assigneeDto);
})
.toList();
}

private AssigneeDto createAssigneeDto(Issue issue) {

if (issue.getAssignee() == null) {
return new AssigneeDto();
}
return AssigneeDto.from(issue.getAssignee().getId(), issue.getAssignee().getName());
return AssigneeDto.from(issue.getAssignee().getId(), issue.getAssignee().getName(),
issue.getAssignee().getProfileImageUrl());
}

private List<EpicWithStatisticResponse> getEpicWithStatisticResponses(List<EpicResponse> epicResponses,
List<EpicStatisticDto> epicStatics) {
return epicResponses.stream()
.map(epic -> {
EpicStatisticDto epicStatisticDto = epicStatics.stream()
.filter(epicStatistic -> epicStatistic.getEpicId().equals(epic.getId()))
.findFirst()
.orElseThrow(() -> new GeneralException(ErrorStatus.EPIC_STATISTIC_NOT_FOUND));
return new EpicWithStatisticResponse(epic, epicStatisticDto);
})
.toList();
.map(epic -> {
EpicStatisticDto epicStatisticDto = epicStatics.stream()
.filter(epicStatistic -> epicStatistic.getEpicId().equals(epic.getId()))
.findFirst()
.orElseThrow(() -> new GeneralException(ErrorStatus.EPIC_STATISTIC_NOT_FOUND));
return new EpicWithStatisticResponse(epic, epicStatisticDto);
})
.toList();
}

private List<EpicResponse> getEpicResponses(List<Epic> epicsByProject, Project project) {
return epicsByProject.stream()
.map(epic -> {
Member assignee = epic.getAssignee();
if (assignee == null) {
return EpicResponse.fromEntity(epic, project.getKey(), new AssigneeDto());
}
AssigneeDto assigneeDto = AssigneeDto.builder()
.id(assignee.getId())
.name(assignee.getName())
.build();
return EpicResponse.fromEntity(epic, project.getKey(), assigneeDto);

})
.toList();
.map(epic -> {
Member assignee = epic.getAssignee();
if (assignee == null) {
return EpicResponse.fromEntity(epic, project.getKey(), new AssigneeDto());
}
AssigneeDto assigneeDto = AssigneeDto.builder()
.id(assignee.getId())
.name(assignee.getName())
.build();
return EpicResponse.fromEntity(epic, project.getKey(), assigneeDto);

})
.toList();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@ public List<SprintReadResponse> getSprints(String key) {
List<Sprint> sprints = sprintRepository.findAllByProjectId(projectId);

return sprints.stream()
.map(sprint -> {
List<IssueInSprintDto> issueInSprintDtos = issueRepository.findBySprint(sprint).stream()
.map(issue -> convertToIssueInSprintDto(issue, key))
.toList();
return SprintReadResponse.builder()
.sprintId(sprint.getId())
.title(sprint.getTitle())
.description(sprint.getTargetDescription())
.startDate(sprint.getStartDate() == null ? "" : sprint.getStartDate().toString())
.endDate(sprint.getEndDate() == null ? "" : sprint.getEndDate().toString())
.issueCount((long) issueInSprintDtos.size())
.issues(issueInSprintDtos)
.build();
}
)
.toList();
.map(sprint -> {
List<IssueInSprintDto> issueInSprintDtos = issueRepository.findBySprint(sprint).stream()
.map(issue -> convertToIssueInSprintDto(issue, key))
.toList();
return SprintReadResponse.builder()
.sprintId(sprint.getId())
.title(sprint.getTitle())
.description(sprint.getTargetDescription())
.startDate(sprint.getStartDate() == null ? "" : sprint.getStartDate().toString())
.endDate(sprint.getEndDate() == null ? "" : sprint.getEndDate().toString())
.issueCount((long) issueInSprintDtos.size())
.issues(issueInSprintDtos)
.build();
}
)
.toList();
}

private IssueInSprintDto convertToIssueInSprintDto(Issue issue, String key) {
AssigneeDto assigneeDto = Optional.ofNullable(issue.getAssignee())
.map(assignee -> new AssigneeDto(assignee.getId(), assignee.getName()))
.orElse(new AssigneeDto());
.map(assignee -> new AssigneeDto(assignee.getId(), assignee.getName(), assignee.getProfileImageUrl()))
.orElse(new AssigneeDto());
return IssueInSprintDto.fromEntity(issue, key, assigneeDto);
}

Expand Down
Loading