From c7a438df03dc126cd1fa4496d4bd84c373e49bc7 Mon Sep 17 00:00:00 2001 From: fengshuonan Date: Tue, 27 Jun 2023 21:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=907.6.0=E3=80=91=E3=80=90config=E3=80=91?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=88=A0=E9=99=A4=E9=85=8D=E7=BD=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=EF=BC=8C=E8=B0=83=E6=95=B4config=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kernel/config/api/exception/ConfigException.java | 9 +++------ .../modular/service/impl/SysConfigServiceImpl.java | 12 ++++-------- .../roses/kernel/config/ConfigContainer.java | 8 ++------ .../kernel/config/redis/RedisConfigContainer.java | 8 ++------ 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/ConfigException.java b/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/ConfigException.java index ebac3a166..c2ebf5d48 100644 --- a/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/ConfigException.java +++ b/kernel-d-config/config-api/src/main/java/cn/stylefeng/roses/kernel/config/api/exception/ConfigException.java @@ -24,6 +24,7 @@ */ package cn.stylefeng.roses.kernel.config.api.exception; +import cn.hutool.core.util.StrUtil; import cn.stylefeng.roses.kernel.config.api.constants.ConfigConstants; import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum; import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; @@ -36,16 +37,12 @@ import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException; */ public class ConfigException extends ServiceException { - public ConfigException(String errorCode, String userTip) { - super(ConfigConstants.CONFIG_MODULE_NAME, errorCode, userTip); + public ConfigException(AbstractExceptionEnum exception, Object... params) { + super(ConfigConstants.CONFIG_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params)); } public ConfigException(AbstractExceptionEnum exception) { super(ConfigConstants.CONFIG_MODULE_NAME, exception); } - public ConfigException(AbstractExceptionEnum exception, String userTip) { - super(ConfigConstants.CONFIG_MODULE_NAME, exception.getErrorCode(), userTip); - } - } diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java index 8b981085b..0a0a2769c 100644 --- a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/SysConfigServiceImpl.java @@ -93,8 +93,7 @@ public class SysConfigServiceImpl extends ServiceImpl T getConfigValue(String configCode, Class clazz) throws ConfigException { String configValue = CONFIG_CONTAINER.getStr(configCode); if (ObjectUtil.isEmpty(configValue)) { - String format = StrUtil.format(ConfigExceptionEnum.CONFIG_NOT_EXIST.getUserTip(), configCode); - log.warn(format); - throw new ConfigException(ConfigExceptionEnum.CONFIG_NOT_EXIST.getErrorCode(), format); + throw new ConfigException(ConfigExceptionEnum.CONFIG_NOT_EXIST, configCode); } else { try { return Convert.convert(clazz, configValue); } catch (Exception e) { - String format = StrUtil.format(ConfigExceptionEnum.CONVERT_ERROR.getUserTip(), configCode, configValue, clazz.toString()); - log.warn(format); - throw new ConfigException(ConfigExceptionEnum.CONVERT_ERROR.getErrorCode(), format); + throw new ConfigException(ConfigExceptionEnum.CONVERT_ERROR, configCode, configValue, clazz.toString()); } } } diff --git a/kernel-d-config/config-sdk-redis/src/main/java/cn/stylefeng/roses/kernel/config/redis/RedisConfigContainer.java b/kernel-d-config/config-sdk-redis/src/main/java/cn/stylefeng/roses/kernel/config/redis/RedisConfigContainer.java index aba1ad5b6..32b2e2a37 100644 --- a/kernel-d-config/config-sdk-redis/src/main/java/cn/stylefeng/roses/kernel/config/redis/RedisConfigContainer.java +++ b/kernel-d-config/config-sdk-redis/src/main/java/cn/stylefeng/roses/kernel/config/redis/RedisConfigContainer.java @@ -156,16 +156,12 @@ public class RedisConfigContainer implements ConfigApi { try (Jedis jedis = pool.getResource()) { String configValue = jedis.get(CONFIG_PREFIX + configCode); if (ObjectUtil.isEmpty(configValue)) { - String format = StrUtil.format(ConfigExceptionEnum.CONFIG_NOT_EXIST.getUserTip(), configCode); - log.warn(format); - throw new ConfigException(ConfigExceptionEnum.CONFIG_NOT_EXIST.getErrorCode(), format); + throw new ConfigException(ConfigExceptionEnum.CONFIG_NOT_EXIST, configCode); } else { try { return Convert.convert(clazz, configValue); } catch (Exception e) { - String format = StrUtil.format(ConfigExceptionEnum.CONVERT_ERROR.getUserTip(), configCode, configValue, clazz.toString()); - log.warn(format); - throw new ConfigException(ConfigExceptionEnum.CONVERT_ERROR.getErrorCode(), format); + throw new ConfigException(ConfigExceptionEnum.CONVERT_ERROR, configCode, configValue, clazz.toString()); } } }