update 优化 使用动态租户重构业务对租户的逻辑

This commit is contained in:
疯狂的狮子Li
2023-11-21 14:57:35 +08:00
parent 5f660b27d3
commit ef4cb01d9b
5 changed files with 69 additions and 124 deletions

View File

@@ -57,9 +57,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
new LambdaQueryWrapper<SysOssConfig>().orderByAsc(TenantEntity::getTenantId))
);
Map<String, List<SysOssConfig>> map = StreamUtils.groupByKey(list, SysOssConfig::getTenantId);
try {
for (String tenantId : map.keySet()) {
TenantHelper.setDynamic(tenantId);
for (String tenantId : map.keySet()) {
TenantHelper.dynamic(tenantId, () -> {
// 加载OSS初始化配置
for (SysOssConfig config : map.get(tenantId)) {
String configKey = config.getConfigKey();
@@ -68,9 +67,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
}
CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
}
}
} finally {
TenantHelper.clearDynamic();
});
}
}