Search in sources :

Example 21 with SysConfig

use of com.ruoyi.system.domain.SysConfig in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysConfigServiceImpl method selectConfigByKey.

/**
 * 根据键名查询参数配置信息
 *
 * @param configKey 参数key
 * @return 参数键值
 */
@Override
public String selectConfigByKey(String configKey) {
    String configValue = Convert.toStr(RedisUtils.getCacheObject(getCacheKey(configKey)));
    if (StringUtils.isNotEmpty(configValue)) {
        return configValue;
    }
    SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, configKey));
    if (ObjectUtil.isNotNull(retConfig)) {
        RedisUtils.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
        return retConfig.getConfigValue();
    }
    return StringUtils.EMPTY;
}
Also used : SysConfig(com.ruoyi.system.domain.SysConfig) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 22 with SysConfig

use of com.ruoyi.system.domain.SysConfig in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysConfigServiceImpl method deleteConfigByIds.

/**
 * 批量删除参数信息
 *
 * @param configIds 需要删除的参数ID
 */
@Override
public void deleteConfigByIds(Long[] configIds) {
    for (Long configId : configIds) {
        SysConfig config = selectConfigById(configId);
        if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
            throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
        }
        RedisUtils.deleteObject(getCacheKey(config.getConfigKey()));
    }
    baseMapper.deleteBatchIds(Arrays.asList(configIds));
}
Also used : SysConfig(com.ruoyi.system.domain.SysConfig) ServiceException(com.ruoyi.common.core.exception.ServiceException)

Example 23 with SysConfig

use of com.ruoyi.system.domain.SysConfig in project RuoYi-Cloud-Plus by JavaLionLi.

the class SysConfigServiceImpl method checkConfigKeyUnique.

/**
 * 校验参数键名是否唯一
 *
 * @param config 参数配置信息
 * @return 结果
 */
@Override
public String checkConfigKeyUnique(SysConfig config) {
    Long configId = ObjectUtil.isNull(config.getConfigId()) ? -1L : config.getConfigId();
    SysConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getConfigKey, config.getConfigKey()));
    if (ObjectUtil.isNotNull(info) && info.getConfigId().longValue() != configId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : SysConfig(com.ruoyi.system.domain.SysConfig) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 24 with SysConfig

use of com.ruoyi.system.domain.SysConfig in project RuoYi-Vue by yangzongzhuan.

the class SysConfigServiceImpl method selectConfigByKey.

/**
 * 根据键名查询参数配置信息
 *
 * @param configKey 参数key
 * @return 参数键值
 */
@Override
public String selectConfigByKey(String configKey) {
    String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
    if (StringUtils.isNotEmpty(configValue)) {
        return configValue;
    }
    SysConfig config = new SysConfig();
    config.setConfigKey(configKey);
    SysConfig retConfig = configMapper.selectConfig(config);
    if (StringUtils.isNotNull(retConfig)) {
        redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
        return retConfig.getConfigValue();
    }
    return StringUtils.EMPTY;
}
Also used : SysConfig(com.ruoyi.system.domain.SysConfig)

Example 25 with SysConfig

use of com.ruoyi.system.domain.SysConfig in project RuoYi-Vue by yangzongzhuan.

the class SysConfigServiceImpl method deleteConfigByIds.

/**
 * 批量删除参数信息
 *
 * @param configIds 需要删除的参数ID
 */
@Override
public void deleteConfigByIds(Long[] configIds) {
    for (Long configId : configIds) {
        SysConfig config = selectConfigById(configId);
        if (StringUtils.equals(UserConstants.YES, config.getConfigType())) {
            throw new ServiceException(String.format("内置参数【%1$s】不能删除 ", config.getConfigKey()));
        }
        configMapper.deleteConfigById(configId);
        redisCache.deleteObject(getCacheKey(config.getConfigKey()));
    }
}
Also used : SysConfig(com.ruoyi.system.domain.SysConfig) ServiceException(com.ruoyi.common.exception.ServiceException)

Aggregations

SysConfig (com.ruoyi.system.domain.SysConfig)29 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)6 ServiceException (com.ruoyi.common.exception.ServiceException)4 DataSource (com.ruoyi.common.annotation.DataSource)3 ServiceException (com.ruoyi.common.core.exception.ServiceException)3 CustomException (com.ruoyi.common.exception.CustomException)1