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

#62 [FEAT] 개인 및 팀 대시보드 퍼즐판 빈 퍼즐까지 내려주는 로직 구현 #63

Merged
merged 1 commit into from
Jul 19, 2023
Merged
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 @@ -93,16 +93,21 @@ public ProjectOwnPuzzleResponseDto getMyPuzzles(Long memberId, Long projectId, S
Boolean hasTodayReview = reviewRepository.existsReviewByReviewDate(today);

List<PuzzleObjectDto> result = new ArrayList<>();
for (int idx = 1; idx <= reviews.size(); idx++) {
Review review = reviews.get(idx - 1);
result.add(PuzzleObjectDto.of(review.getReviewDate(), review.getId(), ("puzzlea" + idx)));
}

if (isReviewDay) {
if (!hasTodayReview) {
result.add(PuzzleObjectDto.of(today, null, "puzzled" + (result.size() + 1)));
for (int idx = 1; idx <= pageSize; idx++) {
if (idx <= reviews.size()) {
Review review = reviews.get(idx - 1);
result.add(PuzzleObjectDto.of(review.getReviewDate(), review.getId(), ("puzzlea" + idx)));
} else {
if (idx == reviews.size() + 1) {
if (isReviewDay && !hasTodayReview) {
result.add(PuzzleObjectDto.of(today, null, "puzzled" + (result.size() + 1)));
}
} else {
result.add(PuzzleObjectDto.of(null, null, ("puzzlee" + idx)));
}
}
}

return ProjectOwnPuzzleResponseDto.of(mapperMyPuzzleObject(memberId, projectId), result,
pageReviews.getTotalPages() - 1, isReviewDay, hasTodayReview);
}
Expand Down Expand Up @@ -156,13 +161,19 @@ public ProjectTeamPuzzleResponseDto getTeamPuzzles(Principal principal, Long pro
int endIndex = teamPuzzleBoard.size();

lastPageValues.addAll(teamPuzzleBoard.subList(startIndex, endIndex));
} else {
lastPageValues.addAll(teamPuzzleBoard);
}

if (isReviewDay) {
if (!hasTodayReview) {
lastPageValues.add(TeamPuzzleObjectDto.of(null, null, "puzzled" + (lastPageValues.size() + 1)));
}
}

for (int i = lastPageValues.size() + 1; i <= pageSize ; i++) {
lastPageValues.add(TeamPuzzleObjectDto.of(null, null, ("puzzlee" + i)));
}
return ProjectTeamPuzzleResponseDto.of(mapperMyPuzzleObject(memberId, projectId), lastPageValues,
lastPageNumber, isReviewDay, hasTodayReview);
}
Expand Down Expand Up @@ -216,9 +227,9 @@ public ProjectJoinResponseDto joinProject(Long memberId, ProjectJoinRequestDto p
if (userProjectRepository.existsByProjectIdAndNickname(projectJoinRequestDto.getProjectId(),projectJoinRequestDto.getMemberProjectNickname())){
throw new BadRequestException(("이미 프로젝트에 있는 닉네임입니다."));
}
if (userProjectRepository.existsByMemberIdAndProjectId(memberId, projectJoinRequestDto.getProjectId())){
throw new BadRequestException(("이미 프로젝트에 참여한 팀원입니다."));
}
// if (userProjectRepository.existsByMemberIdAndProjectId(memberId, projectJoinRequestDto.getProjectId())){
// throw new BadRequestException(("이미 프로젝트에 참여한 팀원입니다."));
// }
Member member = findMemberById(memberId);
Project project = findProjectById(projectJoinRequestDto.getProjectId());

Expand Down
Loading