use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Vue-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method deleteWithValidByIds.
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
if (CollUtil.containsAny(ids, OssConstant.SYSTEM_DATA_IDS)) {
throw new ServiceException("系统内置, 不可删除!");
}
}
List<SysOssConfig> list = Lists.newArrayList();
for (Long configId : ids) {
SysOssConfig config = baseMapper.selectById(configId);
list.add(config);
}
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
if (flag) {
list.stream().forEach(sysOssConfig -> {
RedisUtils.deleteObject(getCacheKey(sysOssConfig.getConfigKey()));
});
}
return flag;
}
use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Vue-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method updateByBo.
@Override
public Boolean updateByBo(SysOssConfigBo bo) {
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
validEntityBeforeSave(config);
LambdaUpdateWrapper<SysOssConfig> luw = new LambdaUpdateWrapper<>();
luw.set(StringUtils.isBlank(config.getPrefix()), SysOssConfig::getPrefix, "");
luw.set(StringUtils.isBlank(config.getRegion()), SysOssConfig::getRegion, "");
luw.set(StringUtils.isBlank(config.getExt1()), SysOssConfig::getExt1, "");
luw.eq(SysOssConfig::getOssConfigId, config.getOssConfigId());
return setConfigCache(baseMapper.update(config, luw) > 0, config);
}
use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Vue-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method insertByBo.
@Override
public Boolean insertByBo(SysOssConfigBo bo) {
SysOssConfig config = BeanUtil.toBean(bo, SysOssConfig.class);
validEntityBeforeSave(config);
return setConfigCache(baseMapper.insert(config) > 0, config);
}
use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Vue-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method updateOssConfigStatus.
/**
* 启用禁用状态
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int updateOssConfigStatus(SysOssConfigBo bo) {
SysOssConfig sysOssConfig = BeanUtil.toBean(bo, SysOssConfig.class);
int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>().set(SysOssConfig::getStatus, "1"));
row += baseMapper.updateById(sysOssConfig);
if (row > 0) {
RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, sysOssConfig.getConfigKey());
}
return row;
}
use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Vue-Plus by JavaLionLi.
the class SysOssConfigServiceImpl method init.
/**
* 项目启动时,初始化参数到缓存,加载配置类
*/
@Override
public void init() {
List<SysOssConfig> list = baseMapper.selectList();
// 加载OSS初始化配置
for (SysOssConfig config : list) {
String configKey = config.getConfigKey();
if ("0".equals(config.getStatus())) {
RedisUtils.setCacheObject(OssConstant.CACHE_CONFIG_KEY, configKey);
}
setConfigCache(true, config);
}
// 初始化OSS工厂
OssFactory.init();
}
Aggregations