Skip to content
Merged
Show file tree
Hide file tree
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 @@ -165,7 +165,7 @@ public ResponseEntity<BasicResponse<MyProfileResponse>> getMyProfile(
@Operation(summary = "상대방 프로필 조회 API", description = "타인의 프로필을 조회합니다.")
@ApiResponses(value = {
@ApiResponse(description = "200", responseCode = "요청 성공", content = @Content(schema = @Schema(implementation = OtherProfileResponse.class))),
@ApiResponse(responseCode = "400", description = "MEMBER4041: 해당 사용자를 찾을 수 없습니다.")
@ApiResponse(responseCode = "400", description = "MEMBER4041: 해당 사용자를 찾을 수 없습니다., MEMBER4031: 차단된 or 차단한 사용자의 프로필은 조회할 수 없습니다.")
})
@GetMapping("/{targetId}")
public ResponseEntity<BasicResponse<OtherProfileResponse>> getOtherProfile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public enum MemberErrorStatus implements BaseCode {
// 회원 관련
MEMBER_NOT_FOUND(HttpStatus.NOT_FOUND, "MEMBER4041", "해당 사용자를 찾을 수 없습니다."),
INVALID_S3_KEY(HttpStatus.NOT_FOUND, "MEMBER4042", "저장된 프로필 사진을 찾을 수 없습니다."),
ALREADY_BLOCKED(HttpStatus.BAD_REQUEST, "MEMBER_4001", "이미 차단된 사용자입니다.")
ALREADY_BLOCKED(HttpStatus.BAD_REQUEST, "MEMBER_4001", "이미 차단된 사용자입니다."),
BLOCKED_MEMBER(HttpStatus.FORBIDDEN, "MEMBER4031", "차단당한 or 차단한 사용자의 프로필은 조회 불가능 합니다.")
;

private final HttpStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ProfileService {
private final PreferenceRepository preferenceRepository;
private final MemberLocationRepository memberLocationRepository;
private final EvaluationRepository evaluationRepository;
private final MemberBlockRepository memberBlockRepository;
private final BadgeService badgeService;
private final GeocodingService geocodingService;
private final S3Service s3Service;
Expand Down Expand Up @@ -174,6 +175,16 @@ public OtherProfileResponse getOtherProfile(Long memberId, Long targetMemberId)
Member me = getMember(memberId);
Member target = getMember(targetMemberId);

// 내가 차단한 상태인지 확인
boolean iBlockedTarget = memberBlockRepository.existsByMemberBlockIdFromIdAndMemberBlockIdToId(memberId, targetMemberId);

// 상대가 나를 차단했는지 확인
boolean targetBlockedMe = memberBlockRepository.existsByMemberBlockIdFromIdAndMemberBlockIdToId(targetMemberId, memberId);

if (iBlockedTarget || targetBlockedMe) {
throw new MemberException(MemberErrorStatus.BLOCKED_MEMBER);
}

MemberLocation myLocation = memberLocationRepository.findByMember(me).orElse(null);
MemberLocation targetLocation = memberLocationRepository.findByMember(target).orElse(null);
// 나와의 거리 계산
Expand Down