Skip to content

Commit

Permalink
chore: getBlockedUsers 기존 메서드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekks committed Nov 17, 2024
1 parent 8dd90d7 commit 609225d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ public CommentV2GetCommentsResponseDto getComments(Integer postId, Integer page,
User user = userRepository.findByIdOrThrow(userId);
Long orgId = user.getOrgId().longValue();

Map<Long, Boolean> blockedUsers = memberBlockService.getBlockedUsers(orgId);
List<Long> userOrgIds = comments.stream()
.map(comment -> comment.getUser().getOrgId().longValue())
.toList();

Map<Long, Boolean> blockedUsers = memberBlockService.getBlockedUsers(orgId, userOrgIds);

MyLikes myLikes = new MyLikes(likeRepository.findAllByUserIdAndCommentIdNotNull(userId));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@

public interface MemberBlockService {
Map<Long, Boolean> getBlockedUsers(Long blockerOrgId, List<Long> userOrgIds);

Map<Long, Boolean> getBlockedUsers(Long blockerOrgId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ public Map<Long, Boolean> getBlockedUsers(Long blockerOrgId, List<Long> userOrgI
.filter(memberBlock -> userOrgIds.contains(memberBlock.getBlockedMember()))
.collect(Collectors.toMap(MemberBlock::getBlockedMember, memberBlock -> true));
}

@Override
public Map<Long, Boolean> getBlockedUsers(Long blockerOrgId) {
List<MemberBlock> memberBlocks = memberBlockRepository.findAllByBlockerAndIsBlockedTrue(blockerOrgId);

return memberBlocks.stream()
.collect(Collectors.toMap(MemberBlock::getBlockedMember, memberBlock -> true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.sopt.makers.crew.main.entity.meeting.Meeting;
import org.sopt.makers.crew.main.entity.meeting.MeetingRepository;
Expand Down Expand Up @@ -44,7 +45,13 @@ public InternalMeetingGetAllMeetingDto getMeetings(

Page<Meeting> meetings = meetingRepository.findAllByQuery(queryCommand,
new CustomPageable(queryCommand.getPage() - 1, queryCommand.getTake(), sort), time);
Map<Long, Boolean> blockedUsers = memberBlockService.getBlockedUsers(orgId.longValue());

List<Long> userOrgIds = meetings.getContent()
.stream()
.map(meeting -> meeting.getUser().getOrgId().longValue())
.toList();

Map<Long, Boolean> blockedUsers = memberBlockService.getBlockedUsers(orgId.longValue(), userOrgIds);

List<InternalMeetingResponseDto> meetingResponseDtos = meetings.getContent().stream()
.map(meeting -> InternalMeetingResponseDto.of(meeting, time.now(),
Expand Down

0 comments on commit 609225d

Please sign in to comment.