This commit is contained in:
@@ -91,8 +91,10 @@ public class ImageFoundRequestHandler implements RequestHandler {
|
|||||||
|
|
||||||
int page = imageSearchRequest.getPage() != null ? imageSearchRequest.getPage() : 1;
|
int page = imageSearchRequest.getPage() != null ? imageSearchRequest.getPage() : 1;
|
||||||
|
|
||||||
YandexSearchResponse yandexSearchResponse = mapper.mapToYandexResponse(searchResponseYandex, page, 5);
|
YandexSearchResponse yandexSearchResponse = mapper.mapToYandexResponse(searchResponseYandex, page, 5,
|
||||||
YandexSearchResponse googleSearchResponse = mapper.mapToYandexResponse(searchResponseGoogle, page, 5);
|
"visual_matches");
|
||||||
|
YandexSearchResponse googleSearchResponse = mapper.mapToYandexResponse(searchResponseGoogle, page, 5,
|
||||||
|
"exact_matches");
|
||||||
|
|
||||||
List<YandexSearchResponse.ImageResult> results = new ArrayList<>();
|
List<YandexSearchResponse.ImageResult> results = new ArrayList<>();
|
||||||
results.addAll(googleSearchResponse.getImages());
|
results.addAll(googleSearchResponse.getImages());
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import java.util.List;
|
|||||||
public class SearchApiToYandexResponseMapper {
|
public class SearchApiToYandexResponseMapper {
|
||||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
public YandexSearchResponse mapToYandexResponse(String searchApiJson, int page, int pageSize) throws IOException {
|
public YandexSearchResponse mapToYandexResponse(String searchApiJson, int page, int pageSize, String findType) throws IOException {
|
||||||
|
|
||||||
JsonNode root = objectMapper.readTree(searchApiJson);
|
JsonNode root = objectMapper.readTree(searchApiJson);
|
||||||
JsonNode visualMatches = root.path("visual_matches");
|
JsonNode visualMatches = root.path(findType);
|
||||||
|
|
||||||
YandexSearchResponse response = new YandexSearchResponse();
|
YandexSearchResponse response = new YandexSearchResponse();
|
||||||
List<YandexSearchResponse.ImageResult> images = new ArrayList<>();
|
List<YandexSearchResponse.ImageResult> images = new ArrayList<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user