Search in sources :

Example 1 with SysOssConfig

use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Flowable-Plus by KonBAI-Q.

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);
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) SysOssConfig(com.ruoyi.system.domain.SysOssConfig)

Example 2 with SysOssConfig

use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Flowable-Plus by KonBAI-Q.

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;
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) SysOssConfig(com.ruoyi.system.domain.SysOssConfig) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SysOssConfig

use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Flowable-Plus by KonBAI-Q.

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();
}
Also used : SysOssConfig(com.ruoyi.system.domain.SysOssConfig)

Example 4 with SysOssConfig

use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Flowable-Plus by KonBAI-Q.

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;
}
Also used : SysOssConfig(com.ruoyi.system.domain.SysOssConfig) ServiceException(com.ruoyi.common.exception.ServiceException)

Example 5 with SysOssConfig

use of com.ruoyi.system.domain.SysOssConfig in project RuoYi-Flowable-Plus by KonBAI-Q.

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);
}
Also used : SysOssConfig(com.ruoyi.system.domain.SysOssConfig)

Aggregations

SysOssConfig (com.ruoyi.system.domain.SysOssConfig)12 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)4 ServiceException (com.ruoyi.common.exception.ServiceException)2 Transactional (org.springframework.transaction.annotation.Transactional)2