| | |
| | | import org.dromara.common.core.utils.MapstructUtils; |
| | | import org.dromara.common.core.utils.StreamUtils; |
| | | import org.dromara.common.core.utils.StringUtils; |
| | | import org.dromara.common.json.utils.JsonUtils; |
| | | import org.dromara.common.mybatis.core.page.PageQuery; |
| | | import org.dromara.common.mybatis.core.page.TableDataInfo; |
| | | import org.dromara.common.oss.constant.OssConstant; |
| | |
| | | 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(); |
| | | if ("0".equals(config.getStatus())) { |
| | | RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, configKey); |
| | | } |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), config); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | } |
| | | } |
| | | } finally { |
| | | TenantHelper.clearDynamic(); |
| | | }); |
| | | } |
| | | } |
| | | |
| | |
| | | lqw.eq(StringUtils.isNotBlank(bo.getConfigKey()), SysOssConfig::getConfigKey, bo.getConfigKey()); |
| | | lqw.like(StringUtils.isNotBlank(bo.getBucketName()), SysOssConfig::getBucketName, bo.getBucketName()); |
| | | lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysOssConfig::getStatus, bo.getStatus()); |
| | | lqw.orderByAsc(SysOssConfig::getOssConfigId); |
| | | return lqw; |
| | | } |
| | | |
| | |
| | | validEntityBeforeSave(config); |
| | | boolean flag = baseMapper.insert(config) > 0; |
| | | if (flag) { |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), config); |
| | | // 从数据库查询完整的数据做缓存 |
| | | config = baseMapper.selectById(config.getOssConfigId()); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | } |
| | | return flag; |
| | | } |
| | |
| | | luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId()); |
| | | boolean flag = baseMapper.update(config, luw) > 0; |
| | | if (flag) { |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), config); |
| | | // 从数据库查询完整的数据做缓存 |
| | | config = baseMapper.selectById(config.getOssConfigId()); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | } |
| | | return flag; |
| | | } |