Skip to content

Commit

Permalink
♻️ [Refactor] 차단한 회원 목록 조회 페이징 단위 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunjin3395 committed Aug 13, 2024
1 parent 26c1661 commit 7a780ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/com/gamegoo/service/member/BlockService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class BlockService {
private final ChatCommandService chatCommandService;
private final FriendService friendService;

Integer pageSize = 9;
private final static Integer PAGE_SIZE = 10;

/**
* memberId에 해당하는 회원이 targetMemberId에 해당하는 회원을 차단
Expand All @@ -53,15 +53,15 @@ public Member blockMember(Long memberId, Long targetMemberId) {

// 이미 차단한 회원인지 검증
boolean isblocked = blockRepository.existsByBlockerMemberAndBlockedMember(member,
targetMember);
targetMember);
if (isblocked) {
throw new BlockHandler(ErrorStatus.ALREADY_BLOCKED);
}

// block 엔티티 생성 및 연관관계 매핑
Block block = Block.builder()
.blockedMember(targetMember)
.build();
.blockedMember(targetMember)
.build();
block.setBlockerMember(member);

blockRepository.save(block);
Expand Down Expand Up @@ -98,10 +98,10 @@ public Page<Member> getBlockList(Long memberId, Integer pageIdx) {
// member 엔티티 조회
Member member = profileService.findMember(memberId);

PageRequest pageRequest = PageRequest.of(pageIdx, pageSize);
PageRequest pageRequest = PageRequest.of(pageIdx, PAGE_SIZE);

return memberRepository.findBlockedMembersByBlockerIdAndNotBlind(member.getId(),
pageRequest);
pageRequest);
}

/**
Expand All @@ -117,7 +117,7 @@ public void unBlockMember(Long memberId, Long targetMemberId) {

// targetMember가 차단 실제로 차단 목록에 존재하는지 검증
Block block = blockRepository.findByBlockerMemberAndBlockedMember(member, targetMember)
.orElseThrow(() -> new BlockHandler(ErrorStatus.TARGET_MEMBER_NOT_BLOCKED));
.orElseThrow(() -> new BlockHandler(ErrorStatus.TARGET_MEMBER_NOT_BLOCKED));

block.removeBlockerMember(member); // 양방향 연관관계 제거
blockRepository.delete(block);
Expand Down

0 comments on commit 7a780ef

Please sign in to comment.