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

[Feat/49] 차단한 회원 목록 조회 API 구현 #53

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT_VALID, INVALID 둘 중에 어떤거 사용할지도 Code Convention 정하면 좋을 것 같아요!
전 INVALID로 개발했긴한데 둘 다 상관없습니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 그럼 저도 INVALID로 수정하겠습니다

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public enum ErrorStatus implements BaseErrorCode {
// 테스트
TEMP_EXCEPTION(HttpStatus.BAD_REQUEST, "TEMP4001", "테스트"),

// 페이징 관련 에러
PAGE_NOT_VALID(HttpStatus.BAD_REQUEST, "PAGE401", "페이지 값은 1 이상이어야 합니다."),

// Member 관련 에러
PASSWORD_INVALID(HttpStatus.BAD_REQUEST, "MEMBER400", "비밀번호가 불일치합니다."),
MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER404", "해당 사용자를 찾을 수 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.gamegoo.apiPayload.exception.handler;

import com.gamegoo.apiPayload.code.BaseErrorCode;
import com.gamegoo.apiPayload.exception.GeneralException;

public class PageHandler extends GeneralException {
public PageHandler(BaseErrorCode code) {
super(code);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public ApiResponse<String> blockMember(@PathVariable(name = "memberId") Long tar
return ApiResponse.onSuccess("회원 차단 성공");
}

@Operation(summary = "차단한 회원 목록 조회 API", description = "내가 차단한 회원의 목록을 조회하는 API 입니다.")
@Parameter(name = "page", description = "페이지 번호, 1 이상의 숫자를 입력해 주세요.")
@GetMapping("/block")
public ApiResponse<Object> getBlockList(@RequestParam(name = "page") Integer page) {
Long memberId = JWTUtil.getCurrentUserId();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/gamegoo/converter/MemberConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static MemberResponse.blockListDto toBlockListDto(Page<Member> blockList)
public static MemberResponse.blockedMemberDto toBlockedMemberDto(Member membr) {
return MemberResponse.blockedMemberDto.builder()
.memberId(membr.getId())
.profileImg(membr.getProfileImage())
.email(membr.getEmail())
.name(membr.getGameuserName())
.build();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/gamegoo/dto/member/MemberResponse.java
Copy link
Contributor

@rimi3226 rimi3226 Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로필 이미지 변수명을 profile_image, profileImg 둘 중 하나로 통일하는 것이 좋을 것 같습니다!
전 profile_image 으로 개발했습니다.
Code Convention에 변수명 관련된 규칙을 새로 정하면 좋을 것 같아요.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 저는 엔티티에서도 camel case로 속성들 선언했어서 이번에도 camel case로 한거긴 한데,, 어떤걸로 통일하는게 좋을까요?

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static class blockListDto {
@AllArgsConstructor
public static class blockedMemberDto {
Long memberId;
String profileImg;
String email;
String name;
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/gamegoo/service/member/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gamegoo.apiPayload.code.status.ErrorStatus;
import com.gamegoo.apiPayload.exception.handler.BlockHandler;
import com.gamegoo.apiPayload.exception.handler.MemberHandler;
import com.gamegoo.apiPayload.exception.handler.PageHandler;
import com.gamegoo.domain.Block;
import com.gamegoo.domain.Member;
import com.gamegoo.repository.member.BlockRepository;
Expand Down Expand Up @@ -55,7 +56,19 @@ public Member blockMember(Long memberId, Long targetMemberId) {
return member;
}

/**
* memberId에 해당하는 회원이 차단한 회원 목록 조회
*
* @param memberId
* @param pageIdx 0 이상의 값이어야 함
* @return
*/
public Page<Member> getBlockList(Long memberId, Integer pageIdx) {
// 페이지 값 검증
if (pageIdx < 0) {
throw new PageHandler(ErrorStatus.PAGE_NOT_VALID);
}

// member 엔티티 조회
Member member = memberRepository.findById(memberId).orElseThrow(() -> new MemberHandler(ErrorStatus.MEMBER_NOT_FOUND));
PageRequest pageRequest = PageRequest.of(pageIdx, pageSize);
Expand Down
Loading