| | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.constant.CacheNames; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.PageQuery; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.JsonUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.cache.CacheUtils; |
| | | import com.ruoyi.common.utils.redis.RedisUtils; |
| | | import com.ruoyi.oss.constant.OssConstant; |
| | | import com.ruoyi.oss.factory.OssFactory; |
| | |
| | | for (SysOssConfig config : list) { |
| | | String configKey = config.getConfigKey(); |
| | | if ("0".equals(config.getStatus())) { |
| | | RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, configKey); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, OssConstant.OSS_CONFIG_KEY, configKey); |
| | | } |
| | | setConfigCache(true, config); |
| | | } |
| | |
| | | } |
| | | boolean flag = baseMapper.deleteBatchIds(ids) > 0; |
| | | if (flag) { |
| | | list.forEach(sysOssConfig -> { |
| | | RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey())); |
| | | }); |
| | | list.forEach(sysOssConfig -> |
| | | CacheUtils.evict(CacheNames.SYS_OSS_CONFIG, sysOssConfig.getConfigKey())); |
| | | } |
| | | return flag; |
| | | } |
| | |
| | | .set(SysOssConfig::getStatus, "1")); |
| | | row += baseMapper.updateById(sysOssConfig); |
| | | if (row > 0) { |
| | | RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, OssConstant.OSS_CONFIG_KEY, sysOssConfig.getConfigKey()); |
| | | } |
| | | return row; |
| | | } |
| | | |
| | | /** |
| | | * 设置cache key |
| | | * |
| | | * @param configKey 参数键 |
| | | * @return 缓存键key |
| | | */ |
| | | private String getCacheKey(String configKey) { |
| | | return OssConstant.SYS_OSS_KEY + configKey; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | private boolean setConfigCache(boolean flag, SysOssConfig config) { |
| | | if (flag) { |
| | | RedisUtils.setCacheObject( |
| | | getCacheKey(config.getConfigKey()), |
| | | JsonUtils.toJsonString(config)); |
| | | CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config)); |
| | | RedisUtils.publish(OssConstant.CACHE_CONFIG_KEY, config.getConfigKey(), msg -> { |
| | | log.info("发布刷新OSS配置 => " + msg); |
| | | }); |