1 | package org.cardanofoundation.explorer.api.service.impl; | |
2 | ||
3 | import java.nio.charset.StandardCharsets; | |
4 | ||
5 | import lombok.RequiredArgsConstructor; | |
6 | ||
7 | import org.springframework.beans.factory.annotation.Value; | |
8 | import org.springframework.stereotype.Service; | |
9 | import org.springframework.web.reactive.function.client.WebClient; | |
10 | ||
11 | import reactor.core.publisher.Mono; | |
12 | ||
13 | import org.cardanofoundation.explorer.api.common.enumeration.TypeTokenGson; | |
14 | import org.cardanofoundation.explorer.api.config.aop.singletoncache.SingletonCall; | |
15 | import org.cardanofoundation.explorer.api.exception.BusinessCode; | |
16 | import org.cardanofoundation.explorer.api.service.NewsService; | |
17 | import org.cardanofoundation.explorer.common.exception.BusinessException; | |
18 | ||
19 | @Service | |
20 | @RequiredArgsConstructor | |
21 | public class NewsServiceImpl implements NewsService { | |
22 | ||
23 | @Value("${application.api.news.base-url}") | |
24 | private String apiNewsDataUrl; | |
25 | ||
26 | private final WebClient webClient; | |
27 | ||
28 | @SingletonCall(typeToken = TypeTokenGson.NEWS, expireAfterSeconds = 200) | |
29 | public Object getNews(Integer limit, Integer offset) { | |
30 |
1
1. getNews : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/NewsServiceImpl::getNews → KILLED |
return webClient |
31 | .get() | |
32 | .uri(String.format(apiNewsDataUrl, limit, offset)) | |
33 | .acceptCharset(StandardCharsets.UTF_8) | |
34 | .retrieve() | |
35 | .onStatus( | |
36 |
3
1. lambda$getNews$0 : negated conditional → KILLED 2. lambda$getNews$0 : replaced boolean return with true for org/cardanofoundation/explorer/api/service/impl/NewsServiceImpl::lambda$getNews$0 → KILLED 3. lambda$getNews$0 : negated conditional → KILLED |
status -> status.is4xxClientError() || status.is5xxServerError(), |
37 | clientResponse -> | |
38 |
1
1. lambda$getNews$1 : replaced return value with null for org/cardanofoundation/explorer/api/service/impl/NewsServiceImpl::lambda$getNews$1 → KILLED |
Mono.error(new BusinessException(BusinessCode.EXTERNAL_API_IS_NOT_AVAILABLE))) |
39 | .bodyToMono(Object.class) | |
40 | .block(); | |
41 | } | |
42 | } | |
Mutations | ||
30 |
1.1 |
|
36 |
1.1 2.2 3.3 |
|
38 |
1.1 |