diff --git a/src/main/java/dynamicquad/agilehub/issue/controller/response/IssueResponse.java b/src/main/java/dynamicquad/agilehub/issue/controller/response/IssueResponse.java index 7e29f84..d386efa 100644 --- a/src/main/java/dynamicquad/agilehub/issue/controller/response/IssueResponse.java +++ b/src/main/java/dynamicquad/agilehub/issue/controller/response/IssueResponse.java @@ -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(); } } diff --git a/src/main/java/dynamicquad/agilehub/issue/domain/story/Story.java b/src/main/java/dynamicquad/agilehub/issue/domain/story/Story.java index 3f8571b..2b77729 100644 --- a/src/main/java/dynamicquad/agilehub/issue/domain/story/Story.java +++ b/src/main/java/dynamicquad/agilehub/issue/domain/story/Story.java @@ -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); + } } } diff --git a/src/main/java/dynamicquad/agilehub/issue/domain/task/Task.java b/src/main/java/dynamicquad/agilehub/issue/domain/task/Task.java index fa623c4..86d4f2d 100644 --- a/src/main/java/dynamicquad/agilehub/issue/domain/task/Task.java +++ b/src/main/java/dynamicquad/agilehub/issue/domain/task/Task.java @@ -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); + } } } diff --git a/src/main/java/dynamicquad/agilehub/issue/service/IssueQueryService.java b/src/main/java/dynamicquad/agilehub/issue/service/IssueQueryService.java index 0cc8a42..d75f1c0 100644 --- a/src/main/java/dynamicquad/agilehub/issue/service/IssueQueryService.java +++ b/src/main/java/dynamicquad/agilehub/issue/service/IssueQueryService.java @@ -66,10 +66,10 @@ public IssueReadResponseDto getIssue(String key, Long issueId, AuthMember authMe List childIssueDtos = issueFactory.createChildIssueDtos(issue); return IssueReadResponseDto.builder() - .issue(issueDto) - .parentIssue(parentIssueDto) - .childIssues(childIssueDtos) - .build(); + .issue(issueDto) + .parentIssue(parentIssueDto) + .childIssues(childIssueDtos) + .build(); } @@ -90,8 +90,8 @@ public List getStoriesByEpic(String key, Long epicId, AuthMember List 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 getTasksByStory(String key, Long storyId, AuthMember authMember) { @@ -100,8 +100,8 @@ public List getTasksByStory(String key, Long storyId, AuthMember a List 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 getEpics(String key, AuthMember authMember) { @@ -110,11 +110,11 @@ public List getEpics(String key, AuthMember authMember) { List 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(); } @@ -124,11 +124,11 @@ public List getStories(String key, AuthMember authMember) { List 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 getTasks(String key, AuthMember authMember) { @@ -137,11 +137,11 @@ public List getTasks(String key, AuthMember authMember) { List 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) { @@ -149,37 +149,38 @@ 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 getEpicWithStatisticResponses(List epicResponses, List 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 getEpicResponses(List 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(); } diff --git a/src/main/java/dynamicquad/agilehub/sprint/service/SprintQueryService.java b/src/main/java/dynamicquad/agilehub/sprint/service/SprintQueryService.java index d329c29..efde50a 100644 --- a/src/main/java/dynamicquad/agilehub/sprint/service/SprintQueryService.java +++ b/src/main/java/dynamicquad/agilehub/sprint/service/SprintQueryService.java @@ -29,28 +29,28 @@ public List getSprints(String key) { List sprints = sprintRepository.findAllByProjectId(projectId); return sprints.stream() - .map(sprint -> { - List 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 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); }