Skip to content

Commit

Permalink
Merge pull request #163 from dnd-side-project/fix/#157-meeting
Browse files Browse the repository at this point in the history
[Fix] 모임 조회 - 익명 응답
  • Loading branch information
f1v3-dev authored Dec 11, 2024
2 parents 87c7d41 + bf93fc7 commit 88c669c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,15 @@ public MeetingTime(LocalDateTime startTime, LocalDateTime endTime, Double rank)
public void addMemberNames(List<String> memberNames) {
this.memberNames.addAll(memberNames);
}

public void setAnonymous() {

List<String> anonymous = new ArrayList<>();
for (int i = 1; i <= memberNames.size(); i++) {
anonymous.add("익명" + i);
}

this.memberNames.clear();
this.memberNames.addAll(anonymous);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,19 @@ public PagedResponse<MeetingTimeResponseDto> getMeetingTimes(String uuid, Pageab
.select(dateOfSchedule.dateOfScheduleRank.count())
.fetchCount();

// 3. 익명 모임이 아닌 경우, 일정을 할당한 사용자의 닉네임 조회 후 추가
Boolean isAnonymous = from(meeting)
.where(meeting.meetingUuid.eq(uuid))
.select(meeting.isAnonymous)
.fetchOne();
// 3. 일정을 할당한 사용자의 닉네임 조회 후 추가
for (MeetingTime meetingTime : meetingTimeList) {
List<String> nicknames = from(dateOfSchedule)
.join(dateOfSchedule.schedule, schedule)
.join(schedule.meeting, meeting)
.where(meeting.meetingUuid.eq(uuid)
.and(dateOfSchedule.dateOfScheduleStart.eq(meetingTime.getStartTime()))
.and(dateOfSchedule.dateOfScheduleEnd.eq(meetingTime.getEndTime()))
.and(schedule.assignedAt.loe(requestTime)))
.select(schedule.scheduleNickname)
.fetch();

if (Boolean.FALSE.equals(isAnonymous)) {
for (MeetingTime meetingTime : meetingTimeList) {
List<String> nicknames = from(dateOfSchedule)
.join(dateOfSchedule.schedule, schedule)
.join(schedule.meeting, meeting)
.where(meeting.meetingUuid.eq(uuid)
.and(dateOfSchedule.dateOfScheduleStart.eq(meetingTime.getStartTime()))
.and(dateOfSchedule.dateOfScheduleEnd.eq(meetingTime.getEndTime()))
.and(schedule.assignedAt.loe(requestTime)))
.select(schedule.scheduleNickname)
.fetch();

meetingTime.addMemberNames(nicknames);
}
meetingTime.addMemberNames(nicknames);
}

// 4. PageInfo 생성
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import com.dnd.jjakkak.domain.category.exception.CategoryNotFoundException;
import com.dnd.jjakkak.domain.category.repository.CategoryRepository;
import com.dnd.jjakkak.domain.meeting.dto.request.MeetingCreateRequestDto;
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingCreateResponseDto;
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingInfoResponseDto;
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingParticipantResponseDto;
import com.dnd.jjakkak.domain.meeting.dto.response.MeetingTimeResponseDto;
import com.dnd.jjakkak.domain.meeting.dto.response.*;
import com.dnd.jjakkak.domain.meeting.entity.Meeting;
import com.dnd.jjakkak.domain.meeting.exception.MeetingNotFoundException;
import com.dnd.jjakkak.domain.meeting.exception.MeetingUnauthorizedException;
Expand Down Expand Up @@ -173,7 +170,16 @@ public PagedResponse<MeetingTimeResponseDto> getMeetingTimes(String uuid, Pageab
throw new MeetingNotFoundException();
}

return meetingRepository.getMeetingTimes(uuid, pageable, requestTime);
PagedResponse<MeetingTimeResponseDto> meetingTimes = meetingRepository.getMeetingTimes(uuid, pageable, requestTime);

if (Boolean.TRUE.equals(meetingTimes.getData().getIsAnonymous())) {
List<MeetingTime> meetingTimeList = meetingTimes.getData().getMeetingTimeList();
for (MeetingTime meetingTime : meetingTimeList) {
meetingTime.setAnonymous();
}
}

return meetingTimes;
}

/**
Expand Down

0 comments on commit 88c669c

Please sign in to comment.