Skip to content

Commit b6e5746

Browse files
committed
Feat: token validate api 호출 코드 수정
1 parent 5dede69 commit b6e5746

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

src/main/java/flipnote/apigateway/client/TokenValidationClient.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package flipnote.apigateway.client;
22

3+
import com.fasterxml.jackson.annotation.JsonProperty;
34
import org.springframework.beans.factory.annotation.Value;
5+
import org.springframework.core.ParameterizedTypeReference;
6+
import org.springframework.http.MediaType;
47
import org.springframework.stereotype.Component;
58
import org.springframework.web.reactive.function.client.WebClient;
69
import reactor.core.publisher.Mono;
@@ -19,12 +22,24 @@ public TokenValidationClient(@Value("${app.user-service.url}") String userServic
1922
public Mono<TokenValidationResponse> validateToken(String token) {
2023
return webClient.post()
2124
.uri("/v1/auth/token/validate")
25+
.contentType(MediaType.APPLICATION_JSON)
2226
.bodyValue(new TokenValidationRequest(token))
2327
.retrieve()
24-
.bodyToMono(TokenValidationResponse.class);
28+
.bodyToMono(new ParameterizedTypeReference<ApiResponse<TokenValidationResponse>>() {})
29+
.map(ApiResponse::data);
2530
}
2631

27-
public record TokenValidationRequest(String token) {}
32+
public record TokenValidationRequest(
33+
@JsonProperty("token") String token) {}
2834

29-
public record TokenValidationResponse(Long userId, String email, String role) {}
35+
public record TokenValidationResponse(
36+
@JsonProperty("userId") Long userId,
37+
@JsonProperty("email") String email,
38+
@JsonProperty("role") String role) {}
39+
40+
public record ApiResponse<T>(
41+
@JsonProperty("status") int status,
42+
@JsonProperty("code") String code,
43+
@JsonProperty("message") String message,
44+
@JsonProperty("data") T data) {}
3045
}

0 commit comments

Comments
 (0)