completed zesa journey
This commit is contained in:
@@ -3,6 +3,8 @@ package zw.qantra.tm.domain.services;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.WordUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -64,7 +66,7 @@ public class ProviderService {
|
||||
headers.setBearerAuth(token);
|
||||
|
||||
List<Provider> existingProviders;
|
||||
if (category != null) {
|
||||
if (category != null && !category.isEmpty()) {
|
||||
existingProviders = getProviderRepository().findByCategory(category);
|
||||
} else {
|
||||
existingProviders = getProviderRepository().findAll();
|
||||
@@ -84,6 +86,24 @@ public class ProviderService {
|
||||
LinkedHashMap body = (LinkedHashMap) response.get("body");
|
||||
List<LinkedHashMap> content = (List<LinkedHashMap>) body.get("content");
|
||||
|
||||
for (LinkedHashMap provider : content) {
|
||||
String clientId = (String) provider.get("clientId");
|
||||
if (existingProviderIds.contains(clientId)) {
|
||||
// Update existing provider
|
||||
Provider existingProvider = existingProviders.stream()
|
||||
.filter(p -> p.getClientId().equals(clientId))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (existingProvider != null) {
|
||||
provider.put("name", WordUtils.capitalizeFully((String)provider.get("name")));
|
||||
provider.put("description", existingProvider.getDescription());
|
||||
provider.put("image", existingProvider.getImage());
|
||||
provider.put("label", existingProvider.getLabel());
|
||||
provider.put("category", existingProvider.getCategory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user