implement zesa currency swap feature

This commit is contained in:
2026-06-01 20:34:48 +02:00
parent 92276c07d8
commit 461dc7e7e4
17 changed files with 257 additions and 48 deletions

View File

@@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
@@ -81,7 +82,8 @@ public class ProviderService {
return products;
}
@Cacheable(value = "providerProducts", key = "#providerUid")
// todo: figure out caching for different providers
// @Cacheable(value = "providerProducts", key = "#providerUid")
public List<SBZProductDto> getProviderProducts(String providerUid) {
try {
Provider provider = providerRepository.findById(UUID.fromString(providerUid)).orElse(null);
@@ -126,6 +128,7 @@ public class ProviderService {
return products;
} catch (IllegalArgumentException e) {
log.error("Error fetching products: " + providerUid, e);
return Collections.emptyList();
}
}
@@ -159,11 +162,7 @@ public class ProviderService {
}
public Object getProviderByClientId(String clientId) {
Provider provider = providerRepository.findByClientId(clientId);
if (provider != null) {
return ((List)getProviders(Collections.singletonList(provider))).stream().findFirst().orElse(null);
}
return null;
return providerRepository.findByClientId(clientId);
}
public Object findAll(Specification<Provider> specification, Pageable pageable) {
@@ -237,4 +236,17 @@ public class ProviderService {
}
return false;
}
// Evict ALL providerProducts cache entries
@CacheEvict(value = "providerProducts", allEntries = true)
public void evictProviderProductsCache() {
// empty - annotation handles the eviction
}
// Or evict a SINGLE entry by key
@CacheEvict(value = "providerProducts", key = "#providerUid")
public void evictProviderProductCache(String providerUid) {
// only evicts cache for this specific providerUid
}
}