From: Tang Cheng Date: Mon, 15 Jul 2019 08:07:51 +0000 (+0800) Subject: 修改缓存的bug X-Git-Tag: 1.0.0^2~46 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=31cd3f584fe3230b208113ce406a5f74638f3b1e;p=epayment%2Ffood_payapi.git 修改缓存的bug --- diff --git a/payapi/src/main/java/com/supwisdom/dlpay/framework/tenant/TenantHolder.java b/payapi/src/main/java/com/supwisdom/dlpay/framework/tenant/TenantHolder.java index b71b2cbf..585767fd 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/framework/tenant/TenantHolder.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/framework/tenant/TenantHolder.java @@ -17,8 +17,8 @@ public class TenantHolder { public String genKey(String prefix, String... args) { StringBuilder builder = new StringBuilder(); - builder.append(prefix).append(delimiter) - .append(getId()); + builder.append(getId()).append(delimiter) + .append(prefix); for (String item : args) { builder.append(delimiter).append(item); } diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java index 0f93d767..7496452b 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/DictionaryDataServiceImpl.java @@ -24,7 +24,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService { } @Override - @Cacheable(cacheNames = "dictionary_cache", key = "#p0") + @Cacheable(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey(#dicttype)") public List getDictionaryByDictType(String dicttype) { List list = dictionaryDao.findAllByDicttype(dicttype); if (!list.isEmpty()) { @@ -35,7 +35,7 @@ public class DictionaryDataServiceImpl implements DictionaryDataService { @Override - @CacheEvict(cacheNames = "dictionary_cache", key = "#p0") + @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey(#dicttype)") public void updateDictionaryByDictType(String dicttype, List list) { for (TDictionary item : list) { if (!dicttype.equals(item.getDicttype())) { @@ -49,18 +49,18 @@ public class DictionaryDataServiceImpl implements DictionaryDataService { } @Override - @CacheEvict(cacheNames = "dictionary_cache", key = "#p0") + @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey(#dicttype)") public void refreshCache(String dicttype) { } @Override - @CacheEvict(cacheNames = "dictionary_cache", key = "'.*'", allEntries = true) + @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.getId() + '.*'", allEntries = true) public void refreshCache() { } @Override - @Cacheable(cacheNames = "trans_code_cache") + @Cacheable(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey('transcode')") public List getTransCode() { List list = transcodeDao.findAll(); if (!list.isEmpty()) { diff --git a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java index 9319434a..3d239c65 100644 --- a/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java +++ b/payapi/src/main/java/com/supwisdom/dlpay/system/service/impl/ParamServiceImpl.java @@ -164,7 +164,7 @@ public class ParamServiceImpl implements ParamService { } @Override - @Cacheable(cacheNames = "dictionary_cache", key = "#{@tenantHolder.genKey('sourcetype', sourceType)}") + @Cacheable(cacheNames = "dictionary_cache", key = "#{@tenantHolder.genKey('sourcetype', #sourceType)}") public TSourceType getSourceType(String sourceType) { if (!StringUtil.isEmpty(sourceType)) { return sourceTypeDao.getBySourceType(sourceType.trim()); @@ -179,7 +179,7 @@ public class ParamServiceImpl implements ParamService { } @Override - @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey('sourcetype', sourceType.sourceType)") + @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey('sourcetype', #sourceType.sourceType)") public boolean saveOrUpdateSourceType(TSourceType sourceType) { if (null != sourceType) { sourceType.setTenantid(TenantContext.getTenantSchema()); @@ -190,7 +190,7 @@ public class ParamServiceImpl implements ParamService { } @Override - @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey('sourcetype', sourceType.sourceType)") + @CacheEvict(cacheNames = "dictionary_cache", key = "@tenantHolder.genKey('sourcetype', #sourceType.sourceType)") public boolean deleteSourceType(TSourceType sourceType) { if (null != sourceType) { sourceTypeDao.delete(sourceType); @@ -200,7 +200,7 @@ public class ParamServiceImpl implements ParamService { } @Override - @Cacheable(cacheNames = "source_type_config_cache", key = "@tenantHolder.genKey('sourcetype_config', sourceType)") + @Cacheable(cacheNames = "source_type_config_cache", key = "@tenantHolder.genKey('sourcetype_config', #sourceType)") public List getSourceTypeConfigList(String sourceType) { if (!StringUtil.isEmpty(sourceType)) { List list = paytypeConfigDao.getBySourceTypeOrderByConfigid(sourceType.trim()); @@ -211,7 +211,7 @@ public class ParamServiceImpl implements ParamService { } @Override - @CacheEvict(cacheNames = "source_type_config_cache", key = "@tenantHolder.genKey('sourcetype_config', sourceType)") + @CacheEvict(cacheNames = "source_type_config_cache", key = "@tenantHolder.genKey('sourcetype_config', #sourceType)") public boolean saveSourceTypeConfig(String sourceType, Map param) throws WebCheckException { TSourceType tPaytype = getSourceType(sourceType); if (null == tPaytype) throw new WebCheckException("支付能力[" + sourceType + "]不存在");