Merge branch 'feature/provider-pagination-total-count' into 'release'
This change handles the new DTO received from Marketplace Service over the... See merge request theappsmith/internal-tools-server!255
This commit is contained in:
commit
1896e9ec0c
|
|
@ -11,6 +11,7 @@ import com.appsmith.external.models.Statistics;
|
|||
import com.appsmith.server.constants.Url;
|
||||
import com.appsmith.server.domains.Action;
|
||||
import com.appsmith.server.domains.Datasource;
|
||||
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
||||
import com.appsmith.server.dtos.ResponseDTO;
|
||||
import com.appsmith.server.dtos.SearchResponseDTO;
|
||||
import com.appsmith.server.services.MarketplaceService;
|
||||
|
|
@ -127,7 +128,7 @@ public class MarketplaceController {
|
|||
}
|
||||
|
||||
@GetMapping("/providers")
|
||||
public Mono<ResponseDTO<List<Provider>>> getAllProvidersFromMarketplace(@RequestParam MultiValueMap<String, String> params) {
|
||||
public Mono<ResponseDTO<ProviderPaginatedDTO>> getAllProvidersFromMarketplace(@RequestParam MultiValueMap<String, String> params) {
|
||||
log.debug("Going to get all providers from Marketplace");
|
||||
return marketplaceService.getProviders(params)
|
||||
.map(resources -> new ResponseDTO<>(HttpStatus.OK.value(), resources, null));
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.appsmith.server.dtos;
|
||||
|
||||
import com.appsmith.external.models.Provider;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ProviderPaginatedDTO {
|
||||
List<Provider> providers;
|
||||
Long total;
|
||||
}
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
package com.appsmith.server.services;
|
||||
|
||||
import com.appsmith.external.models.ApiTemplate;
|
||||
import com.appsmith.external.models.Provider;
|
||||
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MarketplaceService {
|
||||
Mono<List<Provider>> getProviders(MultiValueMap<String, String> params);
|
||||
Mono<ProviderPaginatedDTO> getProviders(MultiValueMap<String, String> params);
|
||||
Mono<List<ApiTemplate>> getTemplates(MultiValueMap<String, String> params);
|
||||
Mono<List<String>> getCategories();
|
||||
Mono<Boolean> subscribeAndUpdateStatisticsOfProvider(String providerId);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.appsmith.server.services;
|
||||
|
||||
import com.appsmith.external.models.ApiTemplate;
|
||||
import com.appsmith.external.models.Provider;
|
||||
import com.appsmith.server.configurations.MarketplaceConfig;
|
||||
import com.appsmith.server.dtos.ProviderPaginatedDTO;
|
||||
import com.appsmith.server.exceptions.AppsmithError;
|
||||
import com.appsmith.server.exceptions.AppsmithException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
|
@ -58,7 +58,7 @@ public class MarketplaceServiceImpl implements MarketplaceService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mono<List<Provider>> getProviders(MultiValueMap<String, String> params) {
|
||||
public Mono<ProviderPaginatedDTO> getProviders(MultiValueMap<String, String> params) {
|
||||
URI uri = buildFullURI(params, PROVIDER_PATH);
|
||||
|
||||
return webClient
|
||||
|
|
@ -67,13 +67,13 @@ public class MarketplaceServiceImpl implements MarketplaceService {
|
|||
.retrieve()
|
||||
.bodyToMono(String.class)
|
||||
.flatMap(stringBody -> {
|
||||
List<Provider> providerList = null;
|
||||
ProviderPaginatedDTO providersPaginated = null;
|
||||
try {
|
||||
providerList = objectMapper.readValue(stringBody, ArrayList.class);
|
||||
providersPaginated = objectMapper.readValue(stringBody, ProviderPaginatedDTO.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
return Mono.error(new AppsmithException(AppsmithError.JSON_PROCESSING_ERROR, e));
|
||||
}
|
||||
return Mono.just(providerList);
|
||||
return Mono.just(providersPaginated);
|
||||
})
|
||||
.timeout(Duration.ofMillis(timeoutInMillis))
|
||||
.doOnError(error -> Mono.error(new AppsmithException(AppsmithError.MARKETPLACE_TIMEOUT)));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user