diff --git a/photo-service/src/main/java/kr/mafoo/photo/exception/ErrorCode.java b/photo-service/src/main/java/kr/mafoo/photo/exception/ErrorCode.java index 1a64111..4dc16e8 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/exception/ErrorCode.java +++ b/photo-service/src/main/java/kr/mafoo/photo/exception/ErrorCode.java @@ -19,7 +19,9 @@ public enum ErrorCode { PHOTO_DISPLAY_INDEX_NOT_VALID("PE0005", "옮기려는 대상 사진 인덱스가 유효하지 않습니다"), PRE_SIGNED_URL_EXCEED_MAXIMUM("OE0001", "한 번에 생성할 수 있는 Pre-signed url 최대치를 초과했습니다"), - PRE_SIGNED_URL_BANNED_FILE_TYPE("OE0002", "Pre-signed url 발급이 허용되지 않는 파일 형식입니다") + PRE_SIGNED_URL_BANNED_FILE_TYPE("OE0002", "Pre-signed url 발급이 허용되지 않는 파일 형식입니다"), + + MAFOO_USER_API_FAILED("MUE0001", "마푸의 user-service API 호출이 실패했습니다") ; private final String code; diff --git a/photo-service/src/main/java/kr/mafoo/photo/exception/MafooUserApiFailed.java b/photo-service/src/main/java/kr/mafoo/photo/exception/MafooUserApiFailed.java new file mode 100644 index 0000000..62027f0 --- /dev/null +++ b/photo-service/src/main/java/kr/mafoo/photo/exception/MafooUserApiFailed.java @@ -0,0 +1,7 @@ +package kr.mafoo.photo.exception; + +public class MafooUserApiFailed extends DomainException { + public MafooUserApiFailed() { + super(ErrorCode.MAFOO_USER_API_FAILED); + } +} diff --git a/photo-service/src/main/java/kr/mafoo/photo/service/MemberService.java b/photo-service/src/main/java/kr/mafoo/photo/service/MemberService.java index 260710a..4fc6bfc 100644 --- a/photo-service/src/main/java/kr/mafoo/photo/service/MemberService.java +++ b/photo-service/src/main/java/kr/mafoo/photo/service/MemberService.java @@ -1,7 +1,9 @@ package kr.mafoo.photo.service; +import kr.mafoo.photo.exception.MafooUserApiFailed; import kr.mafoo.photo.service.dto.MemberDto; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import reactor.core.publisher.Mono; import org.springframework.web.reactive.function.client.WebClient; @@ -11,16 +13,18 @@ @Service public class MemberService { + @Value("${app.gateway.endpoint}") + private String endpoint; + private final WebClient client; public Mono getMemberInfo(String authorizationToken) { return client .get() - .uri("https://gateway.mafoo.kr/user/v1/me") + .uri(endpoint + "/user/v1/me") .header("Authorization", "Bearer " + authorizationToken) .retrieve() - .onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), - ClientResponse::createException) + .onStatus(status -> !status.is2xxSuccessful(), (res) -> Mono.error(new MafooUserApiFailed())) .bodyToMono(MemberDto.class); } }