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 e96370611..6b3dbc459 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 @@ -1,39 +1,25 @@ package cn.iocoder.dashboard.framework.errorcode.config; +import lombok.Getter; +import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotNull; -@ConfigurationProperties("ruoyi.error-code") +@ConfigurationProperties("yudao.error-code") @Validated +@Getter +@Setter public class ErrorCodeProperties { /** * 应用分组 */ - @NotNull(message = "应用分组不能为空,请设置 ruoyi.error-code.group 配置项,推荐直接使用 spring. application.name 配置项") + @NotNull(message = "应用分组不能为空,请设置 yudao.error-code.group 配置项,推荐直接使用 spring.application.name 配置项") private String group; /** * 错误码枚举类 */ private String constantsClass; - - public String getGroup() { - return group; - } - - public ErrorCodeProperties setGroup(String group) { - this.group = group; - return this; - } - - public String getConstantsClass() { - return constantsClass; - } - - public ErrorCodeProperties setConstantsClass(String constantsClass) { - this.constantsClass = constantsClass; - return this; - } } \ No newline at end of file diff --git a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeAutoGenerator.java b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeAutoGenerator.java index d458578a4..0a892a31c 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeAutoGenerator.java +++ b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeAutoGenerator.java @@ -3,10 +3,8 @@ package cn.iocoder.dashboard.framework.errorcode.core; import cn.iocoder.dashboard.common.exception.ErrorCode; import cn.iocoder.dashboard.common.pojo.CommonResult; import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; -import cn.iocoder.dashboard.modules.system.convert.errorcode.ErrorCodeConvert; import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; @@ -17,10 +15,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +@Slf4j public class ErrorCodeAutoGenerator { - private Logger logger = LoggerFactory.getLogger(ErrorCodeAutoGenerator.class); - /** * 应用分组 */ @@ -47,18 +44,18 @@ public class ErrorCodeAutoGenerator { public void execute() { // 校验 errorCodeConstantsClass 参数 if (!StringUtils.hasText(errorCodeConstantsClass)) { - logger.info("[execute][未配置 ruoyi.error-code.constants-class 配置项,不进行自动写入到 system-service 服务]"); + log.info("[execute][未配置 yudao.error-code.constants-class 配置项,不进行自动写入到当前服务中]"); return; } Class errorCodeConstantsClazz; try { errorCodeConstantsClazz = Class.forName(errorCodeConstantsClass); } catch (ClassNotFoundException e) { - logger.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); + log.error("[execute][配置的 ({}) 找不到对应的类]", errorCodeConstantsClass); return; } // 写入 system-service 服务 - logger.info("[execute][自动将 ({}) 类的错误码,准备写入到 system-service 服务]", errorCodeConstantsClass); + log.info("[execute][自动将 ({}) 类的错误码,准备写入到当前服务]", errorCodeConstantsClass); List autoGenerateDTOs = new ArrayList<>(); Arrays.stream(errorCodeConstantsClazz.getFields()).forEach(field -> { if (field.getType() != ErrorCode.class) { @@ -73,11 +70,11 @@ public class ErrorCodeAutoGenerator { throw new RuntimeException(e); } }); - CommonResult autoGenerateErrorCodesResult = errorCodeService.autoGenerateErrorCodes1(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); + CommonResult autoGenerateErrorCodesResult = errorCodeService.autoGenerateErrorCodes1(autoGenerateDTOs); if (autoGenerateErrorCodesResult.isSuccess()) { - logger.info("[execute][自动将 ({}) 类的错误码,成功写入到 system-service 服务]", errorCodeConstantsClass); + log.info("[execute][自动将 ({}) 类的错误码,成功写入到当前服务]", errorCodeConstantsClass); } else { - logger.error("[execute][自动将 ({}) 类的错误码,失败写入到 system-service 服务,原因为 ({}/{})]", errorCodeConstantsClass, + log.error("[execute][自动将 ({}) 类的错误码,失败写入到当前服务,原因为 ({}/{})]", errorCodeConstantsClass, autoGenerateErrorCodesResult.getCode(), autoGenerateErrorCodesResult.getMsg()); } } diff --git a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeRemoteLoader.java b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeRemoteLoader.java index 41ea7b3bc..1a1ce0d3a 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeRemoteLoader.java +++ b/src/main/java/cn/iocoder/dashboard/framework/errorcode/core/ErrorCodeRemoteLoader.java @@ -5,10 +5,8 @@ import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; import cn.iocoder.dashboard.common.pojo.CommonResult; import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.ErrorCodeVO; import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; import cn.iocoder.dashboard.util.date.DateUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Scheduled; @@ -17,12 +15,11 @@ import javax.annotation.Resource; import java.util.Date; import java.util.List; +@Slf4j public class ErrorCodeRemoteLoader { private static final int REFRESH_ERROR_CODE_PERIOD = 60 * 1000; - private Logger logger = LoggerFactory.getLogger(ErrorCodeRemoteLoader.class); - /** * 应用分组 */ @@ -42,7 +39,7 @@ public class ErrorCodeRemoteLoader { // 从 ErrorCodeRpc 全量加载 ErrorCode 错误码 CommonResult> listErrorCodesResult = errorCodeService.listErrorCodes1(group, null); listErrorCodesResult.checkError(); - logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); + log.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); // 写入到 ServiceExceptionUtil 到 listErrorCodesResult.getData().forEach(errorCodeVO -> { ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); @@ -60,7 +57,7 @@ public class ErrorCodeRemoteLoader { if (CollUtil.isEmpty(listErrorCodesResult.getData())) { return; } - logger.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); + log.info("[refreshErrorCodes][从 group({}) 增量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); // 写入到 ServiceExceptionUtil 到 listErrorCodesResult.getData().forEach(errorCodeVO -> { ServiceExceptionUtil.put(errorCodeVO.getCode(), errorCodeVO.getMessage()); diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/ErrorCodeController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/ErrorCodeController.java index f50fc70e8..40bd10451 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/ErrorCodeController.java +++ b/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 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.ErrorCodeConvert; import cn.iocoder.dashboard.modules.system.service.errorcode.ErrorCodeService; -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodeBO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.propertyeditors.CustomDateEditor; @@ -44,7 +42,7 @@ public class ErrorCodeController { @ApiOperation("获取指定分组下的状态码") @GetMapping("/list-group") public CommonResult> listErrorCodes(@NotNull(message = "错误码分组不能为空") String group, Date minUpdateTime) { - return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(group, minUpdateTime))); + return success(errorCodeService.listErrorCodes(group, minUpdateTime)); } /** @@ -55,7 +53,7 @@ public class ErrorCodeController { @ApiOperation("自动生成错误码") @PostMapping("/generate") public CommonResult autoGenerateErrorCodes(@RequestBody List autoGenerateDTOs) { - errorCodeService.autoGenerateErrorCodes(ErrorCodeConvert.INSTANCE.convertList03(autoGenerateDTOs)); + errorCodeService.autoGenerateErrorCodes(autoGenerateDTOs); return success(Boolean.TRUE); } @@ -69,7 +67,7 @@ public class ErrorCodeController { @ApiOperation("创建错误码") @PostMapping("/create") public CommonResult createErrorCode(@RequestBody ErrorCodeCreateDTO createDTO) { - return success(errorCodeService.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)).getId()); + return success(errorCodeService.createErrorCode(createDTO).getId()); } /** @@ -80,7 +78,7 @@ public class ErrorCodeController { @ApiOperation("更新错误码") @PatchMapping("/update") public CommonResult updateErrorCode(@RequestBody ErrorCodeUpdateDTO updateDTO) { - errorCodeService.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)); + errorCodeService.updateErrorCode(updateDTO); return success(Boolean.TRUE); } @@ -105,7 +103,7 @@ public class ErrorCodeController { @ApiOperation("获取错误码") @GetMapping("/query") public CommonResult getErrorCode(Integer errorCodeId) { - return success(ErrorCodeConvert.INSTANCE.convert(errorCodeService.getErrorCode(errorCodeId))); + return success(errorCodeService.getErrorCode(errorCodeId)); } /** @@ -117,7 +115,7 @@ public class ErrorCodeController { @ApiOperation("获取错误码列表") @GetMapping("/query-ids") public CommonResult> listErrorCodes(@RequestBody List errorCodeIds) { - return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeService.listErrorCodes(errorCodeIds))); + return success(errorCodeService.listErrorCodes(errorCodeIds)); } /** @@ -129,8 +127,7 @@ public class ErrorCodeController { @ApiOperation("获取错误码分页列表") @GetMapping("/page") public CommonResult> pageErrorCode(ErrorCodePageDTO pageDTO) { - final PageResult pageResult = errorCodeService.pageErrorCode(ErrorCodeConvert.INSTANCE.convert(pageDTO)); - return success(ErrorCodeConvert.INSTANCE.convertPage(pageResult)); + return success(errorCodeService.pageErrorCode(pageDTO)); } @InitBinder diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/ErrorCodeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/ErrorCodeConvert.java index d6f669081..376911d3e 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/ErrorCodeConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/ErrorCodeConvert.java @@ -3,47 +3,37 @@ package cn.iocoder.dashboard.modules.system.convert.errorcode; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; -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.dal.dataobject.errorcode.ErrorCodeDO; -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.*; import com.baomidou.mybatisplus.core.metadata.IPage; import org.mapstruct.Mapper; import org.mapstruct.Mapping; +import org.mapstruct.ReportingPolicy; import org.mapstruct.factory.Mappers; import java.util.List; -@Mapper +/** + * @author dylan + */ +@Mapper(unmappedSourcePolicy = ReportingPolicy.IGNORE) public interface ErrorCodeConvert { ErrorCodeConvert INSTANCE = Mappers.getMapper(ErrorCodeConvert.class); - ErrorCodeDO convert(ErrorCodeCreateBO bean); + ErrorCodeVO convert (ErrorCodeDO bean); - ErrorCodeBO convert(ErrorCodeDO bean); - - List convertList(List list); + List convertList(List list); @Mapping(source = "records", target = "list") - PageResult convertPage(IPage page); + PageResult convertPage(IPage page); - ErrorCodeDO convert(ErrorCodeUpdateBO bean); + ErrorCodeDO convert (ErrorCodeCreateDTO bean); - ErrorCodeCreateBO convert(ErrorCodeCreateDTO bean); + ErrorCodeDO convert (ErrorCodeUpdateDTO bean); - ErrorCodeUpdateBO convert(ErrorCodeUpdateDTO bean); + ErrorCodeDO convert(ErrorCodeAutoGenerateDTO bean); - ErrorCodeVO convert(ErrorCodeBO bean); - List convertList02(List list); - - PageResult convertPage(PageResult page); - - ErrorCodePageBO convert(ErrorCodePageDTO bean); - - ErrorCodeDO convert(ErrorCodeAutoGenerateBO bean); - - List convertList03(List list); } 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 index 13c53f1ee..0ae75b934 100644 --- 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 @@ -1,8 +1,8 @@ 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 cn.iocoder.dashboard.modules.system.service.errorcode.bo.ErrorCodePageBO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -15,10 +15,10 @@ import java.util.List; @Mapper public interface ErrorCodeMapper extends BaseMapper { - default IPage selectPage(ErrorCodePageBO pageBO) { - return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), - new QueryWrapperX().likeIfPresent("`group`", pageBO.getGroup()) - .eqIfPresent("code", pageBO.getCode()).likeIfPresent("message", pageBO.getMessage())); + 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) { diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java index c09e19591..1573e7d0c 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/ErrorCodeService.java @@ -4,12 +4,15 @@ import cn.hutool.core.collection.CollUtil; import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; import cn.iocoder.dashboard.common.pojo.CommonResult; import cn.iocoder.dashboard.common.pojo.PageResult; +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeAutoGenerateDTO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.dto.ErrorCodeCreateDTO; +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.ErrorCodeConvert; 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.system.enums.errorcode.ErrorCodeTypeEnum; -import cn.iocoder.dashboard.modules.system.service.errorcode.bo.*; import cn.iocoder.dashboard.util.collection.CollectionUtils; import com.baomidou.mybatisplus.core.metadata.IPage; import lombok.extern.slf4j.Slf4j; @@ -41,13 +44,13 @@ public class ErrorCodeService { /** * 创建错误码 * - * @param createBO 创建错误码 BO + * @param createDTO 创建错误码 DTO * @return 错误码 */ - public ErrorCodeBO createErrorCode(@Valid ErrorCodeCreateBO createBO) { - checkDuplicateErrorCode(createBO.getCode(), null); + public ErrorCodeVO createErrorCode(@Valid ErrorCodeCreateDTO createDTO) { + checkDuplicateErrorCode(createDTO.getCode(), null); // 插入到数据库 - ErrorCodeDO errorCodeDO = ErrorCodeConvert.INSTANCE.convert(createBO); + ErrorCodeDO errorCodeDO = ErrorCodeConvert.INSTANCE.convert(createDTO); errorCodeMapper.insert(errorCodeDO); // 返回 return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); @@ -56,33 +59,33 @@ public class ErrorCodeService { /** * 更新错误码 * - * @param updateBO 更新错误码 BO + * @param updateDTO 更新错误码 DTO */ - public void updateErrorCode(@Valid ErrorCodeUpdateBO updateBO) { - checkDuplicateErrorCode(updateBO.getCode(), updateBO.getId()); + public void updateErrorCode(@Valid ErrorCodeUpdateDTO updateDTO) { + checkDuplicateErrorCode(updateDTO.getCode(), updateDTO.getId()); // 校验更新的错误码是否存在 - if (errorCodeMapper.selectById(updateBO.getId()) == null) { + if (errorCodeMapper.selectById(updateDTO.getId()) == null) { throw ServiceExceptionUtil.exception(ERROR_CODE_NOT_EXISTS); } // 更新到数据库 - ErrorCodeDO updateObject = ErrorCodeConvert.INSTANCE.convert(updateBO); + ErrorCodeDO updateObject = ErrorCodeConvert.INSTANCE.convert(updateDTO); errorCodeMapper.updateById(updateObject); } @Transactional - public void autoGenerateErrorCodes(@Valid List autoGenerateBOs) { - if (CollUtil.isEmpty(autoGenerateBOs)) { + public void autoGenerateErrorCodes(@Valid List autoGenerateDTOs) { + if (CollUtil.isEmpty(autoGenerateDTOs)) { return; } List errorCodeDOs = errorCodeMapper.selectListByCodes( - CollectionUtils.convertSet(autoGenerateBOs, ErrorCodeAutoGenerateBO::getCode)); + CollectionUtils.convertSet(autoGenerateDTOs, ErrorCodeAutoGenerateDTO::getCode)); Map errorCodeDOMap = CollectionUtils.convertMap(errorCodeDOs, ErrorCodeDO::getCode); // 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了 - autoGenerateBOs.forEach(autoGenerateBO -> { - ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateBO.getCode()); + autoGenerateDTOs.forEach(autoGenerateDTO -> { + ErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateDTO.getCode()); // 不存在,则进行新增 if (errorCodeDO == null) { - errorCodeDO = ErrorCodeConvert.INSTANCE.convert(autoGenerateBO) + errorCodeDO = ErrorCodeConvert.INSTANCE.convert(autoGenerateDTO) .setType(ErrorCodeTypeEnum.AUTO_GENERATION.getType()); errorCodeMapper.insert(errorCodeDO); return; @@ -93,23 +96,23 @@ public class ErrorCodeService { return; } // 条件 2. 分组 group 必须匹配,避免存在错误码冲突的情况 - if (!autoGenerateBO.getGroup().equals(errorCodeDO.getGroup())) { + if (!autoGenerateDTO.getGroup().equals(errorCodeDO.getGroup())) { log.error("[autoGenerateErrorCodes][自动创建({}/{}) 错误码失败,数据库中已经存在({}/{})]", - autoGenerateBO.getCode(), autoGenerateBO.getGroup(), + autoGenerateDTO.getCode(), autoGenerateDTO.getGroup(), errorCodeDO.getCode(), errorCodeDO.getGroup()); return; } // 条件 3. 错误提示语存在差异 - if (autoGenerateBO.getMessage().equals(errorCodeDO.getMessage())) { + if (autoGenerateDTO.getMessage().equals(errorCodeDO.getMessage())) { return; } // 最终匹配,进行更新 - errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateBO.getMessage())); + errorCodeMapper.updateById(new ErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateDTO.getMessage())); }); } - public CommonResult autoGenerateErrorCodes1(@Valid List autoGenerateBOs) { - autoGenerateErrorCodes(autoGenerateBOs); + public CommonResult autoGenerateErrorCodes1(@Valid List autoGenerateDTOs) { + autoGenerateErrorCodes(autoGenerateDTOs); return success(Boolean.TRUE); } @@ -134,7 +137,7 @@ public class ErrorCodeService { * @param errorCodeId 错误码编号 * @return 错误码 */ - public ErrorCodeBO getErrorCode(Integer errorCodeId) { + public ErrorCodeVO getErrorCode(Integer errorCodeId) { ErrorCodeDO errorCodeDO = errorCodeMapper.selectById(errorCodeId); return ErrorCodeConvert.INSTANCE.convert(errorCodeDO); } @@ -145,7 +148,7 @@ public class ErrorCodeService { * @param errorCodeIds 错误码编号列表 * @return 错误码列表 */ - public List listErrorCodes(List errorCodeIds) { + public List listErrorCodes(List errorCodeIds) { List errorCodeDOs = errorCodeMapper.selectBatchIds(errorCodeIds); return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); } @@ -153,11 +156,11 @@ public class ErrorCodeService { /** * 获得错误码分页 * - * @param pageBO 错误码分页查询 + * @param pageDTO 错误码分页查询 * @return 错误码分页结果 */ - public PageResult pageErrorCode(ErrorCodePageBO pageBO) { - IPage errorCodeDOPage = errorCodeMapper.selectPage(pageBO); + public PageResult pageErrorCode(ErrorCodePageDTO pageDTO) { + IPage errorCodeDOPage = errorCodeMapper.selectPage(pageDTO); return ErrorCodeConvert.INSTANCE.convertPage(errorCodeDOPage); } @@ -183,15 +186,14 @@ public class ErrorCodeService { } } - public List listErrorCodes(String group, Date minUpdateTime) { + public List listErrorCodes(String group, Date minUpdateTime) { List errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); return ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); } public CommonResult> listErrorCodes1(String group, Date minUpdateTime) { List errorCodeDOs = errorCodeMapper.selectListByGroup(group, minUpdateTime); - final List errorCodeBOS = ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs); - return success(ErrorCodeConvert.INSTANCE.convertList02(errorCodeBOS)); + return success(ErrorCodeConvert.INSTANCE.convertList(errorCodeDOs)); } } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeAutoGenerateBO.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeAutoGenerateBO.java deleted file mode 100644 index ab232cefa..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeAutoGenerateBO.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * 错误码自动生成 BO - */ -@Data -@Accessors(chain = true) -public class ErrorCodeAutoGenerateBO implements Serializable { - - /** - * 错误码编码 - */ - @NotNull(message = "错误码编码不能为空") - private Integer code; - /** - * 错误码错误提示 - */ - @NotEmpty(message = "错误码错误提示不能为空") - private String message; - /** - * 错误码分组 - */ - @NotNull(message = "错误码分组不能为空") - private String group; - -} \ No newline at end of file diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeBO.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeBO.java deleted file mode 100644 index bce150e70..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeBO.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * 错误码 BO - */ -@Data -@Accessors(chain = true) -public class ErrorCodeBO { - - /** - * 错误码编号 - */ - private Integer id; - /** - * 错误码编码 - */ - private Integer code; - /** - * 错误码错误提示 - */ - private String message; - /** - * 错误码类型 - */ - private Integer type; - /** - * 错误码分组 - */ - private String group; - /** - * 错误码备注 - */ - private String memo; - /** - * 创建时间 - */ - private Date createTime; - /** - * 最后更新时间 - */ - private Date updateTime; - -} \ No newline at end of file diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeCreateBO.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeCreateBO.java deleted file mode 100644 index ec4d810c4..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeCreateBO.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -@Data -@Accessors(chain = true) -public class ErrorCodeCreateBO { - - /** - * 错误码编码 - */ - @NotNull(message = "错误码编码不能为空") - private Integer code; - /** - * 错误码错误提示 - */ - @NotEmpty(message = "错误码错误提示不能为空") - private String message; - /** - * 错误码类型 - */ - @NotNull(message = "错误码类型不能为空") - private Integer type; - /** - * 错误码分组 - */ - private String group; - /** - * 错误码备注 - */ - private String memo; -} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodePageBO.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodePageBO.java deleted file mode 100644 index 4bf6b1ac1..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodePageBO.java +++ /dev/null @@ -1,29 +0,0 @@ -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; - -import cn.iocoder.dashboard.common.pojo.PageParam; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.experimental.Accessors; - -/** - * 错误码分页 BO - */ -@Data -@EqualsAndHashCode(callSuper = true) -@Accessors(chain = true) -public class ErrorCodePageBO extends PageParam { - - /** - * 错误码编码 - */ - private Integer code; - /** - * 错误码错误提示 - */ - private String message; - /** - * 错误码分组 - */ - private String group; - -} \ No newline at end of file diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeUpdateBO.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeUpdateBO.java deleted file mode 100644 index 58e8f80a3..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/bo/ErrorCodeUpdateBO.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.dashboard.modules.system.service.errorcode.bo; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 错误码更新 BO - */ -@Data -@Accessors(chain = true) -public class ErrorCodeUpdateBO { - - /** - * 错误码编号 - */ - @NotNull(message = "错误码编号不能为空") - private Integer id; - /** - * 错误码编码 - */ - @NotNull(message = "错误码编码不能为空") - private Integer code; - /** - * 错误码错误提示 - */ - @NotEmpty(message = "错误码错误提示不能为空") - private String message; - /** - * 错误码类型 - */ - @NotNull(message = "错误码类型不能为空") - private Integer type; - /** - * 错误码分组 - */ - private String group; - /** - * 错误码备注 - */ - private String memo; - -} \ No newline at end of file diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index b26ee176a..f704932ed 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -33,6 +33,7 @@ mybatis-plus: mapper-locations: classpath*:mapper/*.xml type-aliases-package: ${yudao.info.base-package}.modules.*.dal.dataobject -ruoyi: +yudao: error-code: group: test1 + constantsClass: cn.iocoder.dashboard.common.exception.enums.GlobalErrorCodeConstants