From 3580b416bca557bc15caec9d0723ec979410ad99 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 21 Apr 2021 00:02:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=20error=20code=20=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA=E5=92=8C=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ation.java => ErrorCodeConfiguration.java} | 4 +- .../errorcode/config/ErrorCodeProperties.java | 7 +- .../generator/ErrorCodeAutoGeneratorImpl.java | 65 +++++++++---------- .../core/loader/ErrorCodeLoaderImpl.java | 2 +- .../errorcode/SysErrorCodeConvert.java | 18 ++--- .../dataobject/errorcode/InfErrorCodeDO.java} | 15 +++-- .../mysql/errorcode/InfErrorCodeMapper.java | 38 +++++++++++ .../dal/mysql/errorcode/ErrorCodeMapper.java | 38 ----------- .../errorcode/impl/ErrorCodeServiceImpl.java | 30 ++++----- src/main/resources/application.yaml | 9 ++- 10 files changed, 116 insertions(+), 110 deletions(-) rename src/main/java/cn/iocoder/dashboard/framework/errorcode/config/{ErrorCodeAutoConfiguration.java => ErrorCodeConfiguration.java} (95%) rename src/main/java/cn/iocoder/dashboard/modules/{system => infra}/convert/errorcode/SysErrorCodeConvert.java (62%) rename src/main/java/cn/iocoder/dashboard/modules/{system/dal/dataobject/errorcode/ErrorCodeDO.java => infra/dal/dataobject/errorcode/InfErrorCodeDO.java} (76%) create mode 100644 src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java delete mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/ErrorCodeMapper.java diff --git a/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeAutoConfiguration.java b/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeConfiguration.java similarity index 95% rename from src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeAutoConfiguration.java rename to src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeConfiguration.java index 0a885aad4..21e967e18 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeAutoConfiguration.java +++ b/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeConfiguration.java @@ -17,13 +17,13 @@ import org.springframework.scheduling.annotation.EnableScheduling; @Configuration @EnableConfigurationProperties(ErrorCodeProperties.class) @EnableScheduling // 开启调度任务的功能,因为 ErrorCodeRemoteLoader 通过定时刷新错误码 -public class ErrorCodeAutoConfiguration { +public class ErrorCodeConfiguration { @Bean public ErrorCodeAutoGenerator errorCodeAutoGenerator(@Value("${spring.application.name}") String applicationName, ErrorCodeProperties errorCodeProperties, ErrorCodeFrameworkService errorCodeFrameworkService) { - return new ErrorCodeAutoGeneratorImpl(applicationName, errorCodeProperties.getConstantsClass(), + return new ErrorCodeAutoGeneratorImpl(applicationName, errorCodeProperties.getConstantsClassList(), errorCodeFrameworkService); } diff --git a/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeProperties.java b/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeProperties.java index 4fc2b5c45..2f629a297 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeProperties.java +++ b/src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeProperties.java @@ -4,7 +4,8 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.util.List; /** * 错误码的配置属性类 @@ -19,7 +20,7 @@ public class ErrorCodeProperties { /** * 错误码枚举类 */ - @NotEmpty(message = "错误码枚举类不能为空") - private String constantsClass; + @NotNull(message = "错误码枚举类不能为空") + private List constantsClassList; } diff --git a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java index 0207d0e59..049c87a23 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java +++ b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java @@ -1,5 +1,8 @@ package cn.iocoder.dashboard.framework.errorcode.core.generator; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ClassUtil; +import cn.hutool.core.util.ReflectUtil; import cn.iocoder.dashboard.common.exception.ErrorCode; import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; import cn.iocoder.dashboard.framework.errorcode.core.service.ErrorCodeFrameworkService; @@ -8,7 +11,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; -import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.Arrays; @@ -16,7 +18,7 @@ import java.util.List; /** * ErrorCodeAutoGenerator 的实现类 - * 目的是,扫描指定的 {@link #errorCodeConstantsClass} 类,写入到 system 的数据库中 + * 目的是,扫描指定的 {@link #constantsClassList} 类,写入到 infra 服务中 * * @author dylan */ @@ -31,7 +33,7 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator { /** * 错误码枚举类 */ - private final String errorCodeConstantsClass; + private final List constantsClassList; /** * 错误码 Service */ @@ -41,38 +43,36 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator { @EventListener(ApplicationReadyEvent.class) @Async // 异步,保证项目的启动过程,毕竟非关键流程 public void execute() { - // 第一步,获得错误码类 - Class errorCodeConstantsClazz = parseErrorCodeConstantsClass(); - if (errorCodeConstantsClazz == null) { - return; - } - - // 第二步,获得错误码数组 - List autoGenerateDTOs = parseErrorCode(errorCodeConstantsClazz); + // 第一步,解析错误码 + List autoGenerateDTOs = parseErrorCode(); log.info("[execute][解析到错误码数量为 ({}) 个]", autoGenerateDTOs.size()); - // 第三步,写入到 system 的数据库 + // 第二步,写入到 infra 服务 errorCodeService.autoGenerateErrorCodes(autoGenerateDTOs); - log.info("[execute][写入到 system 组件完成]"); + log.info("[execute][写入到 infra 组件完成]"); } /** - * 解析 errorCodeConstantsClass 变量,获得错误码类 + * 解析 constantsClassList 变量,转换成错误码数组 * - * @return 错误码类 + * @return 错误码数组 */ - private Class parseErrorCodeConstantsClass() { + private List parseErrorCode() { // 校验 errorCodeConstantsClass 参数 - if (!StringUtils.hasText(errorCodeConstantsClass)) { - log.info("[execute][未配置 yudao.error-code.constants-class 配置项,不进行自动写入到当前服务中]"); - return null; - } - try { - return Class.forName(errorCodeConstantsClass); - } catch (ClassNotFoundException e) { - log.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); - return null; + if (CollUtil.isEmpty(constantsClassList)) { + log.info("[execute][未配置 yudao.error-code.constants-class-list 配置项,不进行自动写入到 infra 服务中]"); + return new ArrayList<>(); } + + // 解析错误码 + List autoGenerateDTOs = new ArrayList<>(); + constantsClassList.forEach(constantsClass -> { + // 解析错误码枚举类 + Class errorCodeConstantsClazz = ClassUtil.loadClass(constantsClass); + // 解析错误码 + autoGenerateDTOs.addAll(parseErrorCode(errorCodeConstantsClazz)); + }); + return autoGenerateDTOs; } /** @@ -80,19 +80,16 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator { * * @return 错误码数组 */ - private List parseErrorCode(Class errorCodeConstantsClazz) { + private List parseErrorCode(Class constantsClass) { List autoGenerateDTOs = new ArrayList<>(); - Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> { + Arrays.stream(constantsClass.getFields()).forEach(field -> { if (field.getType() != ErrorCode.class) { return; } - try { - ErrorCode errorCode = (ErrorCode) field.get(errorCodeConstantsClazz); - autoGenerateDTOs.add(new ErrorCodeAutoGenerateReqDTO().setApplicationName(applicationName) - .setCode(errorCode.getCode()).setMessage(errorCode.getMsg())); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + // 转换成 ErrorCodeAutoGenerateReqDTO 对象 + ErrorCode errorCode = (ErrorCode) ReflectUtil.getFieldValue(constantsClass, field); + autoGenerateDTOs.add(new ErrorCodeAutoGenerateReqDTO().setApplicationName(applicationName) + .setCode(errorCode.getCode()).setMessage(errorCode.getMsg())); }); return autoGenerateDTOs; } diff --git a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java index 9dd9e5450..2f1c9b9d8 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java +++ b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/loader/ErrorCodeLoaderImpl.java @@ -14,7 +14,7 @@ import java.util.Date; import java.util.List; /** - * ErrorCodeLoader 的实现类,从 system 的数据库中,加载错误码。 + * ErrorCodeLoader 的实现类,从 infra 的数据库中,加载错误码。 * * 考虑到错误码会刷新,所以按照 {@link #REFRESH_ERROR_CODE_PERIOD} 频率,增量加载错误码。 * diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/SysErrorCodeConvert.java similarity index 62% rename from src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java rename to src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/SysErrorCodeConvert.java index 7d46b9538..aeb359f75 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/SysErrorCodeConvert.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.convert.errorcode; +package cn.iocoder.dashboard.modules.infra.convert.errorcode; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; @@ -6,7 +6,7 @@ import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeRespDTO; import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; -import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; +import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; import com.baomidou.mybatisplus.core.metadata.IPage; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -20,19 +20,19 @@ public interface SysErrorCodeConvert { SysErrorCodeConvert INSTANCE = Mappers.getMapper(SysErrorCodeConvert.class); - ErrorCodeVO convert (ErrorCodeDO bean); + ErrorCodeVO convert (InfErrorCodeDO bean); - List convertList(List list); + List convertList(List list); @Mapping(source = "records", target = "list") - PageResult convertPage(IPage page); + PageResult convertPage(IPage page); - ErrorCodeDO convert (ErrorCodeCreateDTO bean); + InfErrorCodeDO convert (ErrorCodeCreateDTO bean); - ErrorCodeDO convert (ErrorCodeUpdateDTO bean); + InfErrorCodeDO convert (ErrorCodeUpdateDTO bean); - ErrorCodeDO convert(ErrorCodeAutoGenerateReqDTO bean); + InfErrorCodeDO convert(ErrorCodeAutoGenerateReqDTO bean); - List convertList02(List list); + List convertList02(List list); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/ErrorCodeDO.java b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/errorcode/InfErrorCodeDO.java similarity index 76% rename from src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/ErrorCodeDO.java rename to src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/errorcode/InfErrorCodeDO.java index 21e1537ea..279018b7f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/ErrorCodeDO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/errorcode/InfErrorCodeDO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode; +package cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode; import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.dashboard.modules.system.enums.errorcode.SysErrorCodeTypeEnum; @@ -8,17 +8,22 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@TableName(value = "sys_error_code") +/** + * 错误码表 + * + * @author 芋道源码 + */ +@TableName(value = "inf_error_code") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ErrorCodeDO extends BaseDO { +public class InfErrorCodeDO extends BaseDO { /** - * 错误码编号 + * 错误码编号,自增 */ @TableId - private Integer id; + private Long id; /** * 错误码类型 * diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java new file mode 100644 index 000000000..92cc5b571 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java @@ -0,0 +1,38 @@ +package cn.iocoder.dashboard.modules.infra.dal.mysql.errorcode; + +import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; +import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Mapper; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +@Mapper +public interface InfErrorCodeMapper extends BaseMapper { + + default IPage selectPage(ErrorCodePageDTO pageDTO) { + return selectPage(new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize()), + new QueryWrapperX().likeIfPresent("`group`", pageDTO.getGroup()) + .eqIfPresent("code", pageDTO.getCode()).likeIfPresent("message", pageDTO.getMessage())); + } + + default List selectListByCodes(Collection codes) { + return selectList(new QueryWrapper().in("code", codes)); + } + + default InfErrorCodeDO selectByCode(Integer code) { + return selectOne(new QueryWrapper().eq("code", code)); + } + + default List selectListByApplicationNameAndUpdateTimeGt(String applicationName, Date minUpdateTime) { + return selectList(new QueryWrapperX().eq("application_name", applicationName) + .gtIfPresent("update_time", minUpdateTime)); + } + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/ErrorCodeMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/ErrorCodeMapper.java deleted file mode 100644 index 60b8d8fc5..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/ErrorCodeMapper.java +++ /dev/null @@ -1,38 +0,0 @@ -package cn.iocoder.dashboard.modules.system.dal.mysql.errorcode; - -import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; -import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; - -import java.util.Collection; -import java.util.Date; -import java.util.List; - -@Mapper -public interface ErrorCodeMapper extends BaseMapper { - - default IPage selectPage(ErrorCodePageDTO pageDTO) { - return selectPage(new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize()), - new QueryWrapperX().likeIfPresent("`group`", pageDTO.getGroup()) - .eqIfPresent("code", pageDTO.getCode()).likeIfPresent("message", pageDTO.getMessage())); - } - - default List selectListByCodes(Collection codes) { - return selectList(new QueryWrapper().in("code", codes)); - } - - default ErrorCodeDO selectByCode(Integer code) { - return selectOne(new QueryWrapper().eq("code", code)); - } - - default List selectListByApplicationNameAndUpdateTimeGt(String applicationName, Date minUpdateTime) { - return selectList(new QueryWrapperX().eq("application_name", applicationName) - .gtIfPresent("update_time", minUpdateTime)); - } - -} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/ErrorCodeServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/ErrorCodeServiceImpl.java index 3aff41357..0970be816 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/ErrorCodeServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/ErrorCodeServiceImpl.java @@ -9,9 +9,9 @@ import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCre import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; -import cn.iocoder.dashboard.modules.system.convert.errorcode.SysErrorCodeConvert; -import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper; +import cn.iocoder.dashboard.modules.infra.convert.errorcode.SysErrorCodeConvert; +import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; +import cn.iocoder.dashboard.modules.infra.dal.mysql.errorcode.InfErrorCodeMapper; import cn.iocoder.dashboard.modules.system.enums.errorcode.SysErrorCodeTypeEnum; import cn.iocoder.dashboard.modules.system.service.errorcode.SysErrorCodeService; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -39,7 +39,7 @@ import static cn.iocoder.dashboard.util.collection.CollectionUtils.convertSet; public class ErrorCodeServiceImpl implements SysErrorCodeService { @Resource - private ErrorCodeMapper errorCodeMapper; + private InfErrorCodeMapper errorCodeMapper; /** * 创建错误码 @@ -50,7 +50,7 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { public ErrorCodeVO createErrorCode(ErrorCodeCreateDTO createDTO) { checkDuplicateErrorCode(createDTO.getCode(), null); // 插入到数据库 - ErrorCodeDO errorCodeDO = SysErrorCodeConvert.INSTANCE.convert(createDTO); + InfErrorCodeDO errorCodeDO = SysErrorCodeConvert.INSTANCE.convert(createDTO); errorCodeMapper.insert(errorCodeDO); // 返回 return SysErrorCodeConvert.INSTANCE.convert(errorCodeDO); @@ -68,7 +68,7 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS); } // 更新到数据库 - ErrorCodeDO updateObject = SysErrorCodeConvert.INSTANCE.convert(updateDTO); + InfErrorCodeDO updateObject = SysErrorCodeConvert.INSTANCE.convert(updateDTO); errorCodeMapper.updateById(updateObject); } @@ -93,7 +93,7 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { * @return 错误码 */ public ErrorCodeVO getErrorCode(Integer errorCodeId) { - ErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId); + InfErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId); return SysErrorCodeConvert.INSTANCE.convert(errorCodeDO); } @@ -104,7 +104,7 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { * @return 错误码列表 */ public List listErrorCodes(List errorCodeIds) { - List errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds); + List errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds); return SysErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); } @@ -115,7 +115,7 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { * @return 错误码分页结果 */ public PageResult pageErrorCode(ErrorCodePageDTO pageDTO) { - IPage errorCodeDOPage = errorCodeMapper.selectPage(pageDTO); + IPage errorCodeDOPage = errorCodeMapper.selectPage(pageDTO); return SysErrorCodeConvert.INSTANCE.convertPage(errorCodeDOPage); } @@ -128,7 +128,7 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { * @param id 错误码编号 */ private void checkDuplicateErrorCode(Integer code, Integer id) { - ErrorCodeDO errorCodeDO = errorCodeMapper.selectByCode(code); + InfErrorCodeDO errorCodeDO = errorCodeMapper.selectByCode(code); if (errorCodeDO == null) { return; } @@ -148,13 +148,13 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { return; } // 获得错误码 - List errorCodeDOs = errorCodeMapper.selectListByCodes( + List errorCodeDOs = errorCodeMapper.selectListByCodes( convertSet(autoGenerateDTOs, ErrorCodeAutoGenerateReqDTO::getCode)); - Map errorCodeDOMap = convertMap(errorCodeDOs, ErrorCodeDO::getCode); + Map errorCodeDOMap = convertMap(errorCodeDOs, InfErrorCodeDO::getCode); // 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了 autoGenerateDTOs.forEach(autoGenerateDTO -> { - ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateDTO.getCode()); + InfErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateDTO.getCode()); // 不存在,则进行新增 if (errorCodeDO == null) { errorCodeDO = SysErrorCodeConvert.INSTANCE.convert(autoGenerateDTO) @@ -179,13 +179,13 @@ public class ErrorCodeServiceImpl implements SysErrorCodeService { return; } // 最终匹配,进行更新 - errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateDTO.getMessage())); + errorCodeMapper.updateById(new InfErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateDTO.getMessage())); }); } @Override public List getErrorCodeList(String applicationName, Date minUpdateTime) { - List errorCodeDOs = errorCodeMapper.selectListByApplicationNameAndUpdateTimeGt( + List errorCodeDOs = errorCodeMapper.selectListByApplicationNameAndUpdateTimeGt( applicationName, minUpdateTime); return SysErrorCodeConvert.INSTANCE.convertList02(errorCodeDOs); } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index f704932ed..9e9f9400b 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -33,7 +33,10 @@ mybatis-plus: mapper-locations: classpath*:mapper/*.xml type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject +--- #################### 芋道相关配置 #################### + yudao: - error-code: - group: test1 - constantsClass: cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants + error-code: # 错误码相关配置项 + constants-class-list: + - cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants + - cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants