Search in sources :

Example 1 with SysOssConfig

use of com.ruoyi.resource.domain.SysOssConfig in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysOssConfigServiceImpl method checkConfigKeyUnique.

/**
 * 判断configKey是否唯一
 */
private String checkConfigKeyUnique(SysOssConfig sysOssConfig) {
    long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
    SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>().select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey).eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
    if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysOssConfig(com.ruoyi.resource.domain.SysOssConfig)

Example 2 with SysOssConfig

use of com.ruoyi.resource.domain.SysOssConfig in project RuoYi-Cloud-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);
}
Also used : SysOssConfig(com.ruoyi.resource.domain.SysOssConfig)

Example 3 with SysOssConfig

use of com.ruoyi.resource.domain.SysOssConfig in project RuoYi-Cloud-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();
}
Also used : SysOssConfig(com.ruoyi.resource.domain.SysOssConfig)

Example 4 with SysOssConfig

use of com.ruoyi.resource.domain.SysOssConfig in project RuoYi-Cloud-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(ObjectUtil.isNull(config.getPrefix()), SysOssConfig::getPrefix, "");
    luw.set(ObjectUtil.isNull(config.getRegion()), SysOssConfig::getRegion, "");
    luw.set(ObjectUtil.isNull(config.getExt1()), SysOssConfig::getExt1, "");
    luw.set(ObjectUtil.isNull(config.getRemark()), SysOssConfig::getRemark, "");
    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.resource.domain.SysOssConfig)

Example 5 with SysOssConfig

use of com.ruoyi.resource.domain.SysOssConfig in project RuoYi-Cloud-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;
}
Also used : LambdaUpdateWrapper(com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper) SysOssConfig(com.ruoyi.resource.domain.SysOssConfig) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SysOssConfig (com.ruoyi.resource.domain.SysOssConfig)6 LambdaUpdateWrapper (com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper)2 ServiceException (com.ruoyi.common.core.exception.ServiceException)1 Transactional (org.springframework.transaction.annotation.Transactional)1