Commit e973a4368f4807f582134db5ac5de7c0c6de343b
1 parent
c6ef8b3a
refactor(error-code): 移除错误码BO
Showing
13 changed files
with
75 additions
and
296 deletions
src/main/java/cn/iocoder/dashboard/framework/errorcode/config/ErrorCodeProperties.java
| 1 | package cn.iocoder.dashboard.framework.errorcode.config; | 1 | package cn.iocoder.dashboard.framework.errorcode.config; |
| 2 | 2 | ||
| 3 | +import lombok.Getter; | ||
| 4 | +import lombok.Setter; | ||
| 3 | import org.springframework.boot.context.properties.ConfigurationProperties; | 5 | import org.springframework.boot.context.properties.ConfigurationProperties; |
| 4 | import org.springframework.validation.annotation.Validated; | 6 | import org.springframework.validation.annotation.Validated; |
| 5 | 7 | ||
| 6 | import javax.validation.constraints.NotNull; | 8 | import javax.validation.constraints.NotNull; |
| 7 | 9 | ||
| 8 | -@ConfigurationProperties("ruoyi.error-code") | 10 | +@ConfigurationProperties("yudao.error-code") |
| 9 | @Validated | 11 | @Validated |
| 12 | +@Getter | ||
| 13 | +@Setter | ||
| 10 | public class ErrorCodeProperties { | 14 | public class ErrorCodeProperties { |
| 11 | 15 | ||
| 12 | /** | 16 | /** |
| 13 | * 应用分组 | 17 | * 应用分组 |
| 14 | */ | 18 | */ |
| 15 | - @NotNull(message = "应用分组不能为空,请设置 ruoyi.error-code.group 配置项,推荐直接使用 spring. application.name 配置项") | 19 | + @NotNull(message = "应用分组不能为空,请设置 yudao.error-code.group 配置项,推荐直接使用 spring.application.name 配置项") |
| 16 | private String group; | 20 | private String group; |
| 17 | /** | 21 | /** |
| 18 | * 错误码枚举类 | 22 | * 错误码枚举类 |
| 19 | */ | 23 | */ |
| 20 | private String constantsClass; | 24 | private String constantsClass; |
| 21 | - | ||
| 22 | - public String getGroup() { | ||
| 23 | - return group; | ||
| 24 | - } | ||
| 25 | - | ||
| 26 | - public ErrorCodeProperties setGroup(String group) { | ||
| 27 | - this.group = group; | ||
| 28 | - return this; | ||
| 29 | - } | ||
| 30 | - | ||
| 31 | - public String getConstantsClass() { | ||
| 32 | - return constantsClass; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - public ErrorCodeProperties setConstantsClass(String constantsClass) { | ||
| 36 | - this.constantsClass = constantsClass; | ||
| 37 | - return this; | ||
| 38 | - } | ||
| 39 | } | 25 | } |
| 40 | \ No newline at end of file | 26 | \ No newline at end of file |
src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeAutoGenerator.java
| @@ -3,10 +3,8 @@ package cn.iocoder.dashboard.framework.errorcode.core; | @@ -3,10 +3,8 @@ package cn.iocoder.dashboard.framework.errorcode.core; | ||
| 3 | import cn.iocoder.dashboard.common.exception.ErrorCode; | 3 | import cn.iocoder.dashboard.common.exception.ErrorCode; |
| 4 | import cn.iocoder.dashboard.common.pojo.CommonResult; | 4 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 5 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; | 5 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; |
| 6 | -import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; | ||
| 7 | import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; | 6 | import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; |
| 8 | -import org.slf4j.Logger; | ||
| 9 | -import org.slf4j.LoggerFactory; | 7 | +import lombok.extern.slf4j.Slf4j; |
| 10 | import org.springframework.boot.context.event.ApplicationReadyEvent; | 8 | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| 11 | import org.springframework.context.event.EventListener; | 9 | import org.springframework.context.event.EventListener; |
| 12 | import org.springframework.scheduling.annotation.Async; | 10 | import org.springframework.scheduling.annotation.Async; |
| @@ -17,10 +15,9 @@ import java.util.ArrayList; | @@ -17,10 +15,9 @@ import java.util.ArrayList; | ||
| 17 | import java.util.Arrays; | 15 | import java.util.Arrays; |
| 18 | import java.util.List; | 16 | import java.util.List; |
| 19 | 17 | ||
| 18 | +@Slf4j | ||
| 20 | public class ErrorCodeAutoGenerator { | 19 | public class ErrorCodeAutoGenerator { |
| 21 | 20 | ||
| 22 | - private Logger logger = LoggerFactory.getLogger(ErrorCodeAutoGenerator.class); | ||
| 23 | - | ||
| 24 | /** | 21 | /** |
| 25 | * 应用分组 | 22 | * 应用分组 |
| 26 | */ | 23 | */ |
| @@ -47,18 +44,18 @@ public class ErrorCodeAutoGenerator { | @@ -47,18 +44,18 @@ public class ErrorCodeAutoGenerator { | ||
| 47 | public void execute() { | 44 | public void execute() { |
| 48 | // 校验 errorCodeConstantsClass 参数 | 45 | // 校验 errorCodeConstantsClass 参数 |
| 49 | if (!StringUtils.hasText(errorCodeConstantsClass)) { | 46 | if (!StringUtils.hasText(errorCodeConstantsClass)) { |
| 50 | - logger.info("[execute][未配置 ruoyi.error-code.constants-class 配置项,不进行自动写入到 system-service 服务]"); | 47 | + log.info("[execute][未配置 yudao.error-code.constants-class 配置项,不进行自动写入到当前服务中]"); |
| 51 | return; | 48 | return; |
| 52 | } | 49 | } |
| 53 | Class errorCodeConstantsClazz; | 50 | Class errorCodeConstantsClazz; |
| 54 | try { | 51 | try { |
| 55 | errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass); | 52 | errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass); |
| 56 | } catch (ClassNotFoundException e) { | 53 | } catch (ClassNotFoundException e) { |
| 57 | - logger.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); | 54 | + log.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); |
| 58 | return; | 55 | return; |
| 59 | } | 56 | } |
| 60 | // 写入 system-service 服务 | 57 | // 写入 system-service 服务 |
| 61 | - logger.info("[execute][自动将 ({}) 类的错误码,准备写入到 system-service 服务]", errorCodeConstantsClass); | 58 | + log.info("[execute][自动将 ({}) 类的错误码,准备写入到当前服务]", errorCodeConstantsClass); |
| 62 | List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs = new ArrayList<>(); | 59 | List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs = new ArrayList<>(); |
| 63 | Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> { | 60 | Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> { |
| 64 | if (field.getType() != ErrorCode.class) { | 61 | if (field.getType() != ErrorCode.class) { |
| @@ -73,11 +70,11 @@ public class ErrorCodeAutoGenerator { | @@ -73,11 +70,11 @@ public class ErrorCodeAutoGenerator { | ||
| 73 | throw new RuntimeException(e); | 70 | throw new RuntimeException(e); |
| 74 | } | 71 | } |
| 75 | }); | 72 | }); |
| 76 | - CommonResult<Boolean> autoGenerateErrorCodesResult = errorCodeService.autoGenerateErrorCodes1(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); | 73 | + CommonResult<Boolean> autoGenerateErrorCodesResult = errorCodeService.autoGenerateErrorCodes1(autoGenerateDTOs); |
| 77 | if (autoGenerateErrorCodesResult.isSuccess()) { | 74 | if (autoGenerateErrorCodesResult.isSuccess()) { |
| 78 | - logger.info("[execute][自动将 ({}) 类的错误码,成功写入到 system-service 服务]", errorCodeConstantsClass); | 75 | + log.info("[execute][自动将 ({}) 类的错误码,成功写入到当前服务]", errorCodeConstantsClass); |
| 79 | } else { | 76 | } else { |
| 80 | - logger.error("[execute][自动将 ({}) 类的错误码,失败写入到 system-service 服务,原因为 ({}/{})]", errorCodeConstantsClass, | 77 | + log.error("[execute][自动将 ({}) 类的错误码,失败写入到当前服务,原因为 ({}/{})]", errorCodeConstantsClass, |
| 81 | autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMsg()); | 78 | autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMsg()); |
| 82 | } | 79 | } |
| 83 | } | 80 | } |
src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeRemoteLoader.java
| @@ -5,10 +5,8 @@ import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | @@ -5,10 +5,8 @@ import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | ||
| 5 | import cn.iocoder.dashboard.common.pojo.CommonResult; | 5 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 6 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; | 6 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; |
| 7 | import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; | 7 | import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; |
| 8 | -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; | ||
| 9 | import cn.iocoder.dashboard.util.date.DateUtils; | 8 | import cn.iocoder.dashboard.util.date.DateUtils; |
| 10 | -import org.slf4j.Logger; | ||
| 11 | -import org.slf4j.LoggerFactory; | 9 | +import lombok.extern.slf4j.Slf4j; |
| 12 | import org.springframework.boot.context.event.ApplicationReadyEvent; | 10 | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| 13 | import org.springframework.context.event.EventListener; | 11 | import org.springframework.context.event.EventListener; |
| 14 | import org.springframework.scheduling.annotation.Scheduled; | 12 | import org.springframework.scheduling.annotation.Scheduled; |
| @@ -17,12 +15,11 @@ import javax.annotation.Resource; | @@ -17,12 +15,11 @@ import javax.annotation.Resource; | ||
| 17 | import java.util.Date; | 15 | import java.util.Date; |
| 18 | import java.util.List; | 16 | import java.util.List; |
| 19 | 17 | ||
| 18 | +@Slf4j | ||
| 20 | public class ErrorCodeRemoteLoader { | 19 | public class ErrorCodeRemoteLoader { |
| 21 | 20 | ||
| 22 | private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000; | 21 | private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000; |
| 23 | 22 | ||
| 24 | - private Logger logger = LoggerFactory.getLogger(ErrorCodeRemoteLoader.class); | ||
| 25 | - | ||
| 26 | /** | 23 | /** |
| 27 | * 应用分组 | 24 | * 应用分组 |
| 28 | */ | 25 | */ |
| @@ -42,7 +39,7 @@ public class ErrorCodeRemoteLoader { | @@ -42,7 +39,7 @@ public class ErrorCodeRemoteLoader { | ||
| 42 | // 从 ErrorCodeRpc 全量加载 ErrorCode 错误码 | 39 | // 从 ErrorCodeRpc 全量加载 ErrorCode 错误码 |
| 43 | CommonResult<List<ErrorCodeVO>> listErrorCodesResult = errorCodeService.listErrorCodes1(group, null); | 40 | CommonResult<List<ErrorCodeVO>> listErrorCodesResult = errorCodeService.listErrorCodes1(group, null); |
| 44 | listErrorCodesResult.checkError(); | 41 | listErrorCodesResult.checkError(); |
| 45 | - logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); | 42 | + log.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); |
| 46 | // 写入到 ServiceExceptionUtil 到 | 43 | // 写入到 ServiceExceptionUtil 到 |
| 47 | listErrorCodesResult.getData().forEach(errorCodeVO -> { | 44 | listErrorCodesResult.getData().forEach(errorCodeVO -> { |
| 48 | ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); | 45 | ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); |
| @@ -60,7 +57,7 @@ public class ErrorCodeRemoteLoader { | @@ -60,7 +57,7 @@ public class ErrorCodeRemoteLoader { | ||
| 60 | if (CollUtil.isEmpty(listErrorCodesResult.getData())) { | 57 | if (CollUtil.isEmpty(listErrorCodesResult.getData())) { |
| 61 | return; | 58 | return; |
| 62 | } | 59 | } |
| 63 | - logger.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); | 60 | + log.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); |
| 64 | // 写入到 ServiceExceptionUtil 到 | 61 | // 写入到 ServiceExceptionUtil 到 |
| 65 | listErrorCodesResult.getData().forEach(errorCodeVO -> { | 62 | listErrorCodesResult.getData().forEach(errorCodeVO -> { |
| 66 | ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); | 63 | ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); |
src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/ErrorCodeController.java
| @@ -7,9 +7,7 @@ import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCre | @@ -7,9 +7,7 @@ import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCre | ||
| 7 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | 7 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; |
| 8 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; | 8 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; |
| 9 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; | 9 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; |
| 10 | -import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; | ||
| 11 | import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; | 10 | import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; |
| 12 | -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; | ||
| 13 | import io.swagger.annotations.Api; | 11 | import io.swagger.annotations.Api; |
| 14 | import io.swagger.annotations.ApiOperation; | 12 | import io.swagger.annotations.ApiOperation; |
| 15 | import org.springframework.beans.propertyeditors.CustomDateEditor; | 13 | import org.springframework.beans.propertyeditors.CustomDateEditor; |
| @@ -44,7 +42,7 @@ public class ErrorCodeController { | @@ -44,7 +42,7 @@ public class ErrorCodeController { | ||
| 44 | @ApiOperation("获取指定分组下的状态码") | 42 | @ApiOperation("获取指定分组下的状态码") |
| 45 | @GetMapping("/list-group") | 43 | @GetMapping("/list-group") |
| 46 | public CommonResult<List<ErrorCodeVO>> listErrorCodes(@NotNull(message = "错误码分组不能为空") String group, Date minUpdateTime) { | 44 | public CommonResult<List<ErrorCodeVO>> listErrorCodes(@NotNull(message = "错误码分组不能为空") String group, Date minUpdateTime) { |
| 47 | - return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(group, minUpdateTime))); | 45 | + return success(errorCodeService.listErrorCodes(group, minUpdateTime)); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | /** | 48 | /** |
| @@ -55,7 +53,7 @@ public class ErrorCodeController { | @@ -55,7 +53,7 @@ public class ErrorCodeController { | ||
| 55 | @ApiOperation("自动生成错误码") | 53 | @ApiOperation("自动生成错误码") |
| 56 | @PostMapping("/generate") | 54 | @PostMapping("/generate") |
| 57 | public CommonResult<Boolean> autoGenerateErrorCodes(@RequestBody List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { | 55 | public CommonResult<Boolean> autoGenerateErrorCodes(@RequestBody List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { |
| 58 | - errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); | 56 | + errorCodeService.autoGenerateErrorCodes(autoGenerateDTOs); |
| 59 | return success(Boolean.TRUE); | 57 | return success(Boolean.TRUE); |
| 60 | } | 58 | } |
| 61 | 59 | ||
| @@ -69,7 +67,7 @@ public class ErrorCodeController { | @@ -69,7 +67,7 @@ public class ErrorCodeController { | ||
| 69 | @ApiOperation("创建错误码") | 67 | @ApiOperation("创建错误码") |
| 70 | @PostMapping("/create") | 68 | @PostMapping("/create") |
| 71 | public CommonResult<Integer> createErrorCode(@RequestBody ErrorCodeCreateDTO createDTO) { | 69 | public CommonResult<Integer> createErrorCode(@RequestBody ErrorCodeCreateDTO createDTO) { |
| 72 | - return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId()); | 70 | + return success(errorCodeService.createErrorCode(createDTO).getId()); |
| 73 | } | 71 | } |
| 74 | 72 | ||
| 75 | /** | 73 | /** |
| @@ -80,7 +78,7 @@ public class ErrorCodeController { | @@ -80,7 +78,7 @@ public class ErrorCodeController { | ||
| 80 | @ApiOperation("更新错误码") | 78 | @ApiOperation("更新错误码") |
| 81 | @PatchMapping("/update") | 79 | @PatchMapping("/update") |
| 82 | public CommonResult<Boolean> updateErrorCode(@RequestBody ErrorCodeUpdateDTO updateDTO) { | 80 | public CommonResult<Boolean> updateErrorCode(@RequestBody ErrorCodeUpdateDTO updateDTO) { |
| 83 | - errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)); | 81 | + errorCodeService.updateErrorCode(updateDTO); |
| 84 | return success(Boolean.TRUE); | 82 | return success(Boolean.TRUE); |
| 85 | } | 83 | } |
| 86 | 84 | ||
| @@ -105,7 +103,7 @@ public class ErrorCodeController { | @@ -105,7 +103,7 @@ public class ErrorCodeController { | ||
| 105 | @ApiOperation("获取错误码") | 103 | @ApiOperation("获取错误码") |
| 106 | @GetMapping("/query") | 104 | @GetMapping("/query") |
| 107 | public CommonResult<ErrorCodeVO> getErrorCode(Integer errorCodeId) { | 105 | public CommonResult<ErrorCodeVO> getErrorCode(Integer errorCodeId) { |
| 108 | - return success(ErrorCodeConvert.INSTANCE.convert(errorCodeService.getErrorCode(errorCodeId))); | 106 | + return success(errorCodeService.getErrorCode(errorCodeId)); |
| 109 | } | 107 | } |
| 110 | 108 | ||
| 111 | /** | 109 | /** |
| @@ -117,7 +115,7 @@ public class ErrorCodeController { | @@ -117,7 +115,7 @@ public class ErrorCodeController { | ||
| 117 | @ApiOperation("获取错误码列表") | 115 | @ApiOperation("获取错误码列表") |
| 118 | @GetMapping("/query-ids") | 116 | @GetMapping("/query-ids") |
| 119 | public CommonResult<List<ErrorCodeVO>> listErrorCodes(@RequestBody List<Integer> errorCodeIds) { | 117 | public CommonResult<List<ErrorCodeVO>> listErrorCodes(@RequestBody List<Integer> errorCodeIds) { |
| 120 | - return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds))); | 118 | + return success(errorCodeService.listErrorCodes(errorCodeIds)); |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | /** | 121 | /** |
| @@ -129,8 +127,7 @@ public class ErrorCodeController { | @@ -129,8 +127,7 @@ public class ErrorCodeController { | ||
| 129 | @ApiOperation("获取错误码分页列表") | 127 | @ApiOperation("获取错误码分页列表") |
| 130 | @GetMapping("/page") | 128 | @GetMapping("/page") |
| 131 | public CommonResult<PageResult<ErrorCodeVO>> pageErrorCode(ErrorCodePageDTO pageDTO) { | 129 | public CommonResult<PageResult<ErrorCodeVO>> pageErrorCode(ErrorCodePageDTO pageDTO) { |
| 132 | - final PageResult<ErrorCodeBO> pageResult = errorCodeService.pageErrorCode(ErrorCodeConvert.INSTANCE.convert(pageDTO)); | ||
| 133 | - return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult)); | 130 | + return success(errorCodeService.pageErrorCode(pageDTO)); |
| 134 | } | 131 | } |
| 135 | 132 | ||
| 136 | @InitBinder | 133 | @InitBinder |
src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/ErrorCodeConvert.java
| @@ -3,47 +3,37 @@ package cn.iocoder.dashboard.modules.system.convert.errorcode; | @@ -3,47 +3,37 @@ package cn.iocoder.dashboard.modules.system.convert.errorcode; | ||
| 3 | import cn.iocoder.dashboard.common.pojo.PageResult; | 3 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 4 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; | 4 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; |
| 5 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; | 5 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; |
| 6 | -import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | ||
| 7 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; | 6 | import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; |
| 8 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; | 7 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; |
| 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; | 8 | import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; |
| 10 | -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.*; | ||
| 11 | import com.baomidou.mybatisplus.core.metadata.IPage; | 9 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 12 | import org.mapstruct.Mapper; | 10 | import org.mapstruct.Mapper; |
| 13 | import org.mapstruct.Mapping; | 11 | import org.mapstruct.Mapping; |
| 12 | +import org.mapstruct.ReportingPolicy; | ||
| 14 | import org.mapstruct.factory.Mappers; | 13 | import org.mapstruct.factory.Mappers; |
| 15 | 14 | ||
| 16 | import java.util.List; | 15 | import java.util.List; |
| 17 | 16 | ||
| 18 | -@Mapper | 17 | +/** |
| 18 | + * @author dylan | ||
| 19 | + */ | ||
| 20 | +@Mapper(unmappedSourcePolicy = ReportingPolicy.IGNORE) | ||
| 19 | public interface ErrorCodeConvert { | 21 | public interface ErrorCodeConvert { |
| 20 | 22 | ||
| 21 | ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class); | 23 | ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class); |
| 22 | 24 | ||
| 23 | - ErrorCodeDO convert(ErrorCodeCreateBO bean); | 25 | + ErrorCodeVO convert (ErrorCodeDO bean); |
| 24 | 26 | ||
| 25 | - ErrorCodeBO convert(ErrorCodeDO bean); | ||
| 26 | - | ||
| 27 | - List<ErrorCodeBO> convertList(List<ErrorCodeDO> list); | 27 | + List<ErrorCodeVO> convertList(List<ErrorCodeDO> list); |
| 28 | 28 | ||
| 29 | @Mapping(source = "records", target = "list") | 29 | @Mapping(source = "records", target = "list") |
| 30 | - PageResult<ErrorCodeBO> convertPage(IPage<ErrorCodeDO> page); | ||
| 31 | - | ||
| 32 | - ErrorCodeDO convert(ErrorCodeUpdateBO bean); | ||
| 33 | - | ||
| 34 | - ErrorCodeCreateBO convert(ErrorCodeCreateDTO bean); | ||
| 35 | - | ||
| 36 | - ErrorCodeUpdateBO convert(ErrorCodeUpdateDTO bean); | ||
| 37 | - | ||
| 38 | - ErrorCodeVO convert(ErrorCodeBO bean); | 30 | + PageResult<ErrorCodeVO> convertPage(IPage<ErrorCodeDO> page); |
| 39 | 31 | ||
| 40 | - List<ErrorCodeVO> convertList02(List<ErrorCodeBO> list); | 32 | + ErrorCodeDO convert (ErrorCodeCreateDTO bean); |
| 41 | 33 | ||
| 42 | - PageResult<ErrorCodeVO> convertPage(PageResult<ErrorCodeBO> page); | 34 | + ErrorCodeDO convert (ErrorCodeUpdateDTO bean); |
| 43 | 35 | ||
| 44 | - ErrorCodePageBO convert(ErrorCodePageDTO bean); | 36 | + ErrorCodeDO convert(ErrorCodeAutoGenerateDTO bean); |
| 45 | 37 | ||
| 46 | - ErrorCodeDO convert(ErrorCodeAutoGenerateBO bean); | ||
| 47 | 38 | ||
| 48 | - List<ErrorCodeAutoGenerateBO> convertList03(List<ErrorCodeAutoGenerateDTO> list); | ||
| 49 | } | 39 | } |
src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/ErrorCodeMapper.java
| 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.errorcode; | 1 | package cn.iocoder.dashboard.modules.system.dal.mysql.errorcode; |
| 2 | 2 | ||
| 3 | import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; | 3 | import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; |
| 4 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | ||
| 4 | import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; | 5 | import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; |
| 5 | -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodePageBO; | ||
| 6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 6 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 7 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 7 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 8 | import com.baomidou.mybatisplus.core.metadata.IPage; | 8 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| @@ -15,10 +15,10 @@ import java.util.List; | @@ -15,10 +15,10 @@ import java.util.List; | ||
| 15 | 15 | ||
| 16 | @Mapper | 16 | @Mapper |
| 17 | public interface ErrorCodeMapper extends BaseMapper<ErrorCodeDO> { | 17 | public interface ErrorCodeMapper extends BaseMapper<ErrorCodeDO> { |
| 18 | - default IPage<ErrorCodeDO> selectPage(ErrorCodePageBO pageBO) { | ||
| 19 | - return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), | ||
| 20 | - new QueryWrapperX<ErrorCodeDO>().likeIfPresent("`group`", pageBO.getGroup()) | ||
| 21 | - .eqIfPresent("code", pageBO.getCode()).likeIfPresent("message", pageBO.getMessage())); | 18 | + default IPage<ErrorCodeDO> selectPage(ErrorCodePageDTO pageDTO) { |
| 19 | + return selectPage(new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize()), | ||
| 20 | + new QueryWrapperX<ErrorCodeDO>().likeIfPresent("`group`", pageDTO.getGroup()) | ||
| 21 | + .eqIfPresent("code", pageDTO.getCode()).likeIfPresent("message", pageDTO.getMessage())); | ||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | default List<ErrorCodeDO> selectListByCodes(Collection<Integer> codes) { | 24 | default List<ErrorCodeDO> selectListByCodes(Collection<Integer> codes) { |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java
| @@ -4,12 +4,15 @@ import cn.hutool.core.collection.CollUtil; | @@ -4,12 +4,15 @@ import cn.hutool.core.collection.CollUtil; | ||
| 4 | import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; | 4 | import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; |
| 5 | import cn.iocoder.dashboard.common.pojo.CommonResult; | 5 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 6 | import cn.iocoder.dashboard.common.pojo.PageResult; | 6 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 7 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; | ||
| 8 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; | ||
| 9 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodePageDTO; | ||
| 10 | +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeUpdateDTO; | ||
| 7 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; | 11 | import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; |
| 8 | import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; | 12 | import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; |
| 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; | 13 | import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.ErrorCodeDO; |
| 10 | import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper; | 14 | import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.ErrorCodeMapper; |
| 11 | import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; | 15 | import cn.iocoder.dashboard.modules.system.enums.errorcode.ErrorCodeTypeEnum; |
| 12 | -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.*; | ||
| 13 | import cn.iocoder.dashboard.util.collection.CollectionUtils; | 16 | import cn.iocoder.dashboard.util.collection.CollectionUtils; |
| 14 | import com.baomidou.mybatisplus.core.metadata.IPage; | 17 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 15 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
| @@ -41,13 +44,13 @@ public class ErrorCodeService { | @@ -41,13 +44,13 @@ public class ErrorCodeService { | ||
| 41 | /** | 44 | /** |
| 42 | * 创建错误码 | 45 | * 创建错误码 |
| 43 | * | 46 | * |
| 44 | - * @param createBO 创建错误码 BO | 47 | + * @param createDTO 创建错误码 DTO |
| 45 | * @return 错误码 | 48 | * @return 错误码 |
| 46 | */ | 49 | */ |
| 47 | - public ErrorCodeBO createErrorCode(@Valid ErrorCodeCreateBO createBO) { | ||
| 48 | - checkDuplicateErrorCode(createBO.getCode(), null); | 50 | + public ErrorCodeVO createErrorCode(@Valid ErrorCodeCreateDTO createDTO) { |
| 51 | + checkDuplicateErrorCode(createDTO.getCode(), null); | ||
| 49 | // 插入到数据库 | 52 | // 插入到数据库 |
| 50 | - ErrorCodeDO errorCodeDO = ErrorCodeConvert.INSTANCE.convert(createBO); | 53 | + ErrorCodeDO errorCodeDO = ErrorCodeConvert.INSTANCE.convert(createDTO); |
| 51 | errorCodeMapper.insert(errorCodeDO); | 54 | errorCodeMapper.insert(errorCodeDO); |
| 52 | // 返回 | 55 | // 返回 |
| 53 | return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); | 56 | return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); |
| @@ -56,33 +59,33 @@ public class ErrorCodeService { | @@ -56,33 +59,33 @@ public class ErrorCodeService { | ||
| 56 | /** | 59 | /** |
| 57 | * 更新错误码 | 60 | * 更新错误码 |
| 58 | * | 61 | * |
| 59 | - * @param updateBO 更新错误码 BO | 62 | + * @param updateDTO 更新错误码 DTO |
| 60 | */ | 63 | */ |
| 61 | - public void updateErrorCode(@Valid ErrorCodeUpdateBO updateBO) { | ||
| 62 | - checkDuplicateErrorCode(updateBO.getCode(), updateBO.getId()); | 64 | + public void updateErrorCode(@Valid ErrorCodeUpdateDTO updateDTO) { |
| 65 | + checkDuplicateErrorCode(updateDTO.getCode(), updateDTO.getId()); | ||
| 63 | // 校验更新的错误码是否存在 | 66 | // 校验更新的错误码是否存在 |
| 64 | - if (errorCodeMapper.selectById(updateBO.getId()) == null) { | 67 | + if (errorCodeMapper.selectById(updateDTO.getId()) == null) { |
| 65 | throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS); | 68 | throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS); |
| 66 | } | 69 | } |
| 67 | // 更新到数据库 | 70 | // 更新到数据库 |
| 68 | - ErrorCodeDO updateObject = ErrorCodeConvert.INSTANCE.convert(updateBO); | 71 | + ErrorCodeDO updateObject = ErrorCodeConvert.INSTANCE.convert(updateDTO); |
| 69 | errorCodeMapper.updateById(updateObject); | 72 | errorCodeMapper.updateById(updateObject); |
| 70 | } | 73 | } |
| 71 | 74 | ||
| 72 | @Transactional | 75 | @Transactional |
| 73 | - public void autoGenerateErrorCodes(@Valid List<ErrorCodeAutoGenerateBO> autoGenerateBOs) { | ||
| 74 | - if (CollUtil.isEmpty(autoGenerateBOs)) { | 76 | + public void autoGenerateErrorCodes(@Valid List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { |
| 77 | + if (CollUtil.isEmpty(autoGenerateDTOs)) { | ||
| 75 | return; | 78 | return; |
| 76 | } | 79 | } |
| 77 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByCodes( | 80 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByCodes( |
| 78 | - CollectionUtils.convertSet(autoGenerateBOs, ErrorCodeAutoGenerateBO::getCode)); | 81 | + CollectionUtils.convertSet(autoGenerateDTOs, ErrorCodeAutoGenerateDTO::getCode)); |
| 79 | Map<Integer, ErrorCodeDO> errorCodeDOMap = CollectionUtils.convertMap(errorCodeDOs, ErrorCodeDO::getCode); | 82 | Map<Integer, ErrorCodeDO> errorCodeDOMap = CollectionUtils.convertMap(errorCodeDOs, ErrorCodeDO::getCode); |
| 80 | // 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了 | 83 | // 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了 |
| 81 | - autoGenerateBOs.forEach(autoGenerateBO -> { | ||
| 82 | - ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateBO.getCode()); | 84 | + autoGenerateDTOs.forEach(autoGenerateDTO -> { |
| 85 | + ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateDTO.getCode()); | ||
| 83 | // 不存在,则进行新增 | 86 | // 不存在,则进行新增 |
| 84 | if (errorCodeDO == null) { | 87 | if (errorCodeDO == null) { |
| 85 | - errorCodeDO = ErrorCodeConvert.INSTANCE.convert(autoGenerateBO) | 88 | + errorCodeDO = ErrorCodeConvert.INSTANCE.convert(autoGenerateDTO) |
| 86 | .setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType()); | 89 | .setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType()); |
| 87 | errorCodeMapper.insert(errorCodeDO); | 90 | errorCodeMapper.insert(errorCodeDO); |
| 88 | return; | 91 | return; |
| @@ -93,23 +96,23 @@ public class ErrorCodeService { | @@ -93,23 +96,23 @@ public class ErrorCodeService { | ||
| 93 | return; | 96 | return; |
| 94 | } | 97 | } |
| 95 | // 条件 2. 分组 group 必须匹配,避免存在错误码冲突的情况 | 98 | // 条件 2. 分组 group 必须匹配,避免存在错误码冲突的情况 |
| 96 | - if (!autoGenerateBO.getGroup().equals(errorCodeDO.getGroup())) { | 99 | + if (!autoGenerateDTO.getGroup().equals(errorCodeDO.getGroup())) { |
| 97 | log.error("[autoGenerateErrorCodes][自动创建({}/{}) 错误码失败,数据库中已经存在({}/{})]", | 100 | log.error("[autoGenerateErrorCodes][自动创建({}/{}) 错误码失败,数据库中已经存在({}/{})]", |
| 98 | - autoGenerateBO.getCode(), autoGenerateBO.getGroup(), | 101 | + autoGenerateDTO.getCode(), autoGenerateDTO.getGroup(), |
| 99 | errorCodeDO.getCode(), errorCodeDO.getGroup()); | 102 | errorCodeDO.getCode(), errorCodeDO.getGroup()); |
| 100 | return; | 103 | return; |
| 101 | } | 104 | } |
| 102 | // 条件 3. 错误提示语存在差异 | 105 | // 条件 3. 错误提示语存在差异 |
| 103 | - if (autoGenerateBO.getMessage().equals(errorCodeDO.getMessage())) { | 106 | + if (autoGenerateDTO.getMessage().equals(errorCodeDO.getMessage())) { |
| 104 | return; | 107 | return; |
| 105 | } | 108 | } |
| 106 | // 最终匹配,进行更新 | 109 | // 最终匹配,进行更新 |
| 107 | - errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateBO.getMessage())); | 110 | + errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateDTO.getMessage())); |
| 108 | }); | 111 | }); |
| 109 | } | 112 | } |
| 110 | 113 | ||
| 111 | - public CommonResult<Boolean> autoGenerateErrorCodes1(@Valid List<ErrorCodeAutoGenerateBO> autoGenerateBOs) { | ||
| 112 | - autoGenerateErrorCodes(autoGenerateBOs); | 114 | + public CommonResult<Boolean> autoGenerateErrorCodes1(@Valid List<ErrorCodeAutoGenerateDTO> autoGenerateDTOs) { |
| 115 | + autoGenerateErrorCodes(autoGenerateDTOs); | ||
| 113 | return success(Boolean.TRUE); | 116 | return success(Boolean.TRUE); |
| 114 | } | 117 | } |
| 115 | 118 | ||
| @@ -134,7 +137,7 @@ public class ErrorCodeService { | @@ -134,7 +137,7 @@ public class ErrorCodeService { | ||
| 134 | * @param errorCodeId 错误码编号 | 137 | * @param errorCodeId 错误码编号 |
| 135 | * @return 错误码 | 138 | * @return 错误码 |
| 136 | */ | 139 | */ |
| 137 | - public ErrorCodeBO getErrorCode(Integer errorCodeId) { | 140 | + public ErrorCodeVO getErrorCode(Integer errorCodeId) { |
| 138 | ErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId); | 141 | ErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId); |
| 139 | return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); | 142 | return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); |
| 140 | } | 143 | } |
| @@ -145,7 +148,7 @@ public class ErrorCodeService { | @@ -145,7 +148,7 @@ public class ErrorCodeService { | ||
| 145 | * @param errorCodeIds 错误码编号列表 | 148 | * @param errorCodeIds 错误码编号列表 |
| 146 | * @return 错误码列表 | 149 | * @return 错误码列表 |
| 147 | */ | 150 | */ |
| 148 | - public List<ErrorCodeBO> listErrorCodes(List<Integer> errorCodeIds) { | 151 | + public List<ErrorCodeVO> listErrorCodes(List<Integer> errorCodeIds) { |
| 149 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds); | 152 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds); |
| 150 | return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); | 153 | return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); |
| 151 | } | 154 | } |
| @@ -153,11 +156,11 @@ public class ErrorCodeService { | @@ -153,11 +156,11 @@ public class ErrorCodeService { | ||
| 153 | /** | 156 | /** |
| 154 | * 获得错误码分页 | 157 | * 获得错误码分页 |
| 155 | * | 158 | * |
| 156 | - * @param pageBO 错误码分页查询 | 159 | + * @param pageDTO 错误码分页查询 |
| 157 | * @return 错误码分页结果 | 160 | * @return 错误码分页结果 |
| 158 | */ | 161 | */ |
| 159 | - public PageResult<ErrorCodeBO> pageErrorCode(ErrorCodePageBO pageBO) { | ||
| 160 | - IPage<ErrorCodeDO> errorCodeDOPage = errorCodeMapper.selectPage(pageBO); | 162 | + public PageResult<ErrorCodeVO> pageErrorCode(ErrorCodePageDTO pageDTO) { |
| 163 | + IPage<ErrorCodeDO> errorCodeDOPage = errorCodeMapper.selectPage(pageDTO); | ||
| 161 | return ErrorCodeConvert.INSTANCE.convertPage(errorCodeDOPage); | 164 | return ErrorCodeConvert.INSTANCE.convertPage(errorCodeDOPage); |
| 162 | } | 165 | } |
| 163 | 166 | ||
| @@ -183,15 +186,14 @@ public class ErrorCodeService { | @@ -183,15 +186,14 @@ public class ErrorCodeService { | ||
| 183 | } | 186 | } |
| 184 | } | 187 | } |
| 185 | 188 | ||
| 186 | - public List<ErrorCodeBO> listErrorCodes(String group, Date minUpdateTime) { | 189 | + public List<ErrorCodeVO> listErrorCodes(String group, Date minUpdateTime) { |
| 187 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); | 190 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); |
| 188 | return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); | 191 | return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); |
| 189 | } | 192 | } |
| 190 | 193 | ||
| 191 | public CommonResult<List<ErrorCodeVO>> listErrorCodes1(String group, Date minUpdateTime) { | 194 | public CommonResult<List<ErrorCodeVO>> listErrorCodes1(String group, Date minUpdateTime) { |
| 192 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); | 195 | List<ErrorCodeDO> errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); |
| 193 | - final List<ErrorCodeBO> errorCodeBOS = ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); | ||
| 194 | - return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeBOS)); | 196 | + return success(ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs)); |
| 195 | } | 197 | } |
| 196 | 198 | ||
| 197 | } | 199 | } |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeAutoGenerateBO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | ||
| 2 | - | ||
| 3 | -import lombok.Data; | ||
| 4 | -import lombok.experimental.Accessors; | ||
| 5 | - | ||
| 6 | -import javax.validation.constraints.NotEmpty; | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | -import java.io.Serializable; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * 错误码自动生成 BO | ||
| 12 | - */ | ||
| 13 | -@Data | ||
| 14 | -@Accessors(chain = true) | ||
| 15 | -public class ErrorCodeAutoGenerateBO implements Serializable { | ||
| 16 | - | ||
| 17 | - /** | ||
| 18 | - * 错误码编码 | ||
| 19 | - */ | ||
| 20 | - @NotNull(message = "错误码编码不能为空") | ||
| 21 | - private Integer code; | ||
| 22 | - /** | ||
| 23 | - * 错误码错误提示 | ||
| 24 | - */ | ||
| 25 | - @NotEmpty(message = "错误码错误提示不能为空") | ||
| 26 | - private String message; | ||
| 27 | - /** | ||
| 28 | - * 错误码分组 | ||
| 29 | - */ | ||
| 30 | - @NotNull(message = "错误码分组不能为空") | ||
| 31 | - private String group; | ||
| 32 | - | ||
| 33 | -} | ||
| 34 | \ No newline at end of file | 0 | \ No newline at end of file |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeBO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | ||
| 2 | - | ||
| 3 | -import lombok.Data; | ||
| 4 | -import lombok.experimental.Accessors; | ||
| 5 | - | ||
| 6 | -import java.util.Date; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 错误码 BO | ||
| 10 | - */ | ||
| 11 | -@Data | ||
| 12 | -@Accessors(chain = true) | ||
| 13 | -public class ErrorCodeBO { | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * 错误码编号 | ||
| 17 | - */ | ||
| 18 | - private Integer id; | ||
| 19 | - /** | ||
| 20 | - * 错误码编码 | ||
| 21 | - */ | ||
| 22 | - private Integer code; | ||
| 23 | - /** | ||
| 24 | - * 错误码错误提示 | ||
| 25 | - */ | ||
| 26 | - private String message; | ||
| 27 | - /** | ||
| 28 | - * 错误码类型 | ||
| 29 | - */ | ||
| 30 | - private Integer type; | ||
| 31 | - /** | ||
| 32 | - * 错误码分组 | ||
| 33 | - */ | ||
| 34 | - private String group; | ||
| 35 | - /** | ||
| 36 | - * 错误码备注 | ||
| 37 | - */ | ||
| 38 | - private String memo; | ||
| 39 | - /** | ||
| 40 | - * 创建时间 | ||
| 41 | - */ | ||
| 42 | - private Date createTime; | ||
| 43 | - /** | ||
| 44 | - * 最后更新时间 | ||
| 45 | - */ | ||
| 46 | - private Date updateTime; | ||
| 47 | - | ||
| 48 | -} | ||
| 49 | \ No newline at end of file | 0 | \ No newline at end of file |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeCreateBO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | ||
| 2 | - | ||
| 3 | -import lombok.Data; | ||
| 4 | -import lombok.experimental.Accessors; | ||
| 5 | - | ||
| 6 | -import javax.validation.constraints.NotEmpty; | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | - | ||
| 9 | -@Data | ||
| 10 | -@Accessors(chain = true) | ||
| 11 | -public class ErrorCodeCreateBO { | ||
| 12 | - | ||
| 13 | - /** | ||
| 14 | - * 错误码编码 | ||
| 15 | - */ | ||
| 16 | - @NotNull(message = "错误码编码不能为空") | ||
| 17 | - private Integer code; | ||
| 18 | - /** | ||
| 19 | - * 错误码错误提示 | ||
| 20 | - */ | ||
| 21 | - @NotEmpty(message = "错误码错误提示不能为空") | ||
| 22 | - private String message; | ||
| 23 | - /** | ||
| 24 | - * 错误码类型 | ||
| 25 | - */ | ||
| 26 | - @NotNull(message = "错误码类型不能为空") | ||
| 27 | - private Integer type; | ||
| 28 | - /** | ||
| 29 | - * 错误码分组 | ||
| 30 | - */ | ||
| 31 | - private String group; | ||
| 32 | - /** | ||
| 33 | - * 错误码备注 | ||
| 34 | - */ | ||
| 35 | - private String memo; | ||
| 36 | -} |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodePageBO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.dashboard.common.pojo.PageParam; | ||
| 4 | -import lombok.Data; | ||
| 5 | -import lombok.EqualsAndHashCode; | ||
| 6 | -import lombok.experimental.Accessors; | ||
| 7 | - | ||
| 8 | -/** | ||
| 9 | - * 错误码分页 BO | ||
| 10 | - */ | ||
| 11 | -@Data | ||
| 12 | -@EqualsAndHashCode(callSuper = true) | ||
| 13 | -@Accessors(chain = true) | ||
| 14 | -public class ErrorCodePageBO extends PageParam { | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 错误码编码 | ||
| 18 | - */ | ||
| 19 | - private Integer code; | ||
| 20 | - /** | ||
| 21 | - * 错误码错误提示 | ||
| 22 | - */ | ||
| 23 | - private String message; | ||
| 24 | - /** | ||
| 25 | - * 错误码分组 | ||
| 26 | - */ | ||
| 27 | - private String group; | ||
| 28 | - | ||
| 29 | -} | ||
| 30 | \ No newline at end of file | 0 | \ No newline at end of file |
src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeUpdateBO.java deleted
| 1 | -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; | ||
| 2 | - | ||
| 3 | -import lombok.Data; | ||
| 4 | -import lombok.experimental.Accessors; | ||
| 5 | - | ||
| 6 | -import javax.validation.constraints.NotEmpty; | ||
| 7 | -import javax.validation.constraints.NotNull; | ||
| 8 | - | ||
| 9 | -/** | ||
| 10 | - * 错误码更新 BO | ||
| 11 | - */ | ||
| 12 | -@Data | ||
| 13 | -@Accessors(chain = true) | ||
| 14 | -public class ErrorCodeUpdateBO { | ||
| 15 | - | ||
| 16 | - /** | ||
| 17 | - * 错误码编号 | ||
| 18 | - */ | ||
| 19 | - @NotNull(message = "错误码编号不能为空") | ||
| 20 | - private Integer id; | ||
| 21 | - /** | ||
| 22 | - * 错误码编码 | ||
| 23 | - */ | ||
| 24 | - @NotNull(message = "错误码编码不能为空") | ||
| 25 | - private Integer code; | ||
| 26 | - /** | ||
| 27 | - * 错误码错误提示 | ||
| 28 | - */ | ||
| 29 | - @NotEmpty(message = "错误码错误提示不能为空") | ||
| 30 | - private String message; | ||
| 31 | - /** | ||
| 32 | - * 错误码类型 | ||
| 33 | - */ | ||
| 34 | - @NotNull(message = "错误码类型不能为空") | ||
| 35 | - private Integer type; | ||
| 36 | - /** | ||
| 37 | - * 错误码分组 | ||
| 38 | - */ | ||
| 39 | - private String group; | ||
| 40 | - /** | ||
| 41 | - * 错误码备注 | ||
| 42 | - */ | ||
| 43 | - private String memo; | ||
| 44 | - | ||
| 45 | -} | ||
| 46 | \ No newline at end of file | 0 | \ No newline at end of file |
src/main/resources/application.yaml
| @@ -33,6 +33,7 @@ mybatis-plus: | @@ -33,6 +33,7 @@ mybatis-plus: | ||
| 33 | mapper-locations: classpath*:mapper/*.xml | 33 | mapper-locations: classpath*:mapper/*.xml |
| 34 | type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject | 34 | type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject |
| 35 | 35 | ||
| 36 | -ruoyi: | 36 | +yudao: |
| 37 | error-code: | 37 | error-code: |
| 38 | group: test1 | 38 | group: test1 |
| 39 | + constantsClass: cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants |