From fbf45cd6fef6ebc4f8354ab4a32e416d3311ed47 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 22 Apr 2021 00:07:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E7=9A=84=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/system/errorCode.js | 54 ++++ ruoyi-ui/src/utils/dict.js | 1 + ruoyi-ui/src/views/system/errorCode/index.vue | 256 ++++++++++++++++++ .../errorcode/InfErrorCodeConvert.java | 42 --- .../infra/enums/InfErrorCodeConstants.java | 5 - .../dept/vo/post/SysPostExportReqVO.java | 3 + .../dept/vo/post/SysPostPageReqVO.java | 3 + .../errorcode/SysErrorCodeController.http} | 0 .../errorcode/SysErrorCodeController.java} | 52 ++-- .../errorcode/vo/SysErrorCodeBaseVO.java} | 4 +- .../vo/SysErrorCodeCreateReqVO.java} | 4 +- .../errorcode/vo/SysErrorCodeExcelVO.java} | 8 +- .../vo/SysErrorCodeExportReqVO.java} | 4 +- .../errorcode/vo/SysErrorCodePageReqVO.java} | 4 +- .../errorcode/vo/SysErrorCodeRespVO.java} | 4 +- .../vo/SysErrorCodeUpdateReqVO.java} | 4 +- .../errorcode/SysErrorCodeConvert.java | 42 +++ .../dataobject/errorcode/SysErrorCodeDO.java} | 10 +- .../system/dal/mysql/dept/SysPostMapper.java | 5 +- .../mysql/errorcode/SysErrorCodeMapper.java} | 30 +- .../system/enums/SysErrorCodeConstants.java | 4 + .../system/enums/dict/SysDictTypeEnum.java | 2 +- .../errorcode/SysErrorCodeTypeEnum.java} | 6 +- .../errorcode/SysErrorCodeService.java} | 24 +- .../impl/SysErrorCodeServiceImpl.java} | 67 ++--- .../errorcode/SysErrorCodeServiceTest.java} | 77 +++--- src/test/resources/sql/clean.sql | 2 +- src/test/resources/sql/create_tables.sql | 2 +- 28 files changed, 519 insertions(+), 200 deletions(-) create mode 100644 ruoyi-ui/src/api/system/errorCode.js create mode 100644 ruoyi-ui/src/views/system/errorCode/index.vue delete mode 100644 src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/InfErrorCodeConvert.java rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/InfErrorCodeController.http => system/controller/errorcode/SysErrorCodeController.http} (100%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/InfErrorCodeController.java => system/controller/errorcode/SysErrorCodeController.java} (57%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodeBaseVO.java => system/controller/errorcode/vo/SysErrorCodeBaseVO.java} (89%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodeCreateReqVO.java => system/controller/errorcode/vo/SysErrorCodeCreateReqVO.java} (63%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodeExcelVO.java => system/controller/errorcode/vo/SysErrorCodeExcelVO.java} (83%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodeExportReqVO.java => system/controller/errorcode/vo/SysErrorCodeExportReqVO.java} (91%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodePageReqVO.java => system/controller/errorcode/vo/SysErrorCodePageReqVO.java} (91%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodeRespVO.java => system/controller/errorcode/vo/SysErrorCodeRespVO.java} (83%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/controller/errorcode/vo/InfErrorCodeUpdateReqVO.java => system/controller/errorcode/vo/SysErrorCodeUpdateReqVO.java} (78%) create mode 100644 src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java rename src/main/java/cn/iocoder/dashboard/modules/{infra/dal/dataobject/errorcode/InfErrorCodeDO.java => system/dal/dataobject/errorcode/SysErrorCodeDO.java} (74%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/dal/mysql/errorcode/InfErrorCodeMapper.java => system/dal/mysql/errorcode/SysErrorCodeMapper.java} (59%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/enums/errorcode/InfErrorCodeTypeEnum.java => system/enums/errorcode/SysErrorCodeTypeEnum.java} (75%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/service/errorcode/InfErrorCodeService.java => system/service/errorcode/SysErrorCodeService.java} (52%) rename src/main/java/cn/iocoder/dashboard/modules/{infra/service/errorcode/impl/InfErrorCodeServiceImpl.java => system/service/errorcode/impl/SysErrorCodeServiceImpl.java} (67%) rename src/test/java/cn/iocoder/dashboard/modules/{infra/service/errorcode/InfErrorCodeServiceTest.java => system/service/errorcode/SysErrorCodeServiceTest.java} (67%) diff --git a/ruoyi-ui/src/api/system/errorCode.js b/ruoyi-ui/src/api/system/errorCode.js new file mode 100644 index 000000000..29546b7f4 --- /dev/null +++ b/ruoyi-ui/src/api/system/errorCode.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 创建错误码 +export function createErrorCode(data) { + return request({ + url: '/system/error-code/create', + method: 'post', + data: data + }) +} + +// 更新错误码 +export function updateErrorCode(data) { + return request({ + url: '/system/error-code/update', + method: 'put', + data: data + }) +} + +// 删除错误码 +export function deleteErrorCode(id) { + return request({ + url: '/system/error-code/delete?id=' + id, + method: 'delete' + }) +} + +// 获得错误码 +export function getErrorCode(id) { + return request({ + url: '/system/error-code/get?id=' + id, + method: 'get' + }) +} + +// 获得错误码分页 +export function getErrorCodePage(query) { + return request({ + url: '/system/error-code/page', + method: 'get', + params: query + }) +} + +// 导出错误码 Excel +export function exportErrorCodeExcel(query) { + return request({ + url: '/system/error-code/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/ruoyi-ui/src/utils/dict.js b/ruoyi-ui/src/utils/dict.js index e3dc92d5b..17d5bd00e 100644 --- a/ruoyi-ui/src/utils/dict.js +++ b/ruoyi-ui/src/utils/dict.js @@ -21,6 +21,7 @@ export const DICT_TYPE = { SYS_SMS_TEMPLATE_TYPE: 'sys_sms_template_type', SYS_SMS_SEND_STATUS: 'sys_sms_send_status', SYS_SMS_RECEIVE_STATUS: 'sys_sms_receive_status', + SYS_ERROR_CODE_TYPE: 'sys_error_code_type', INF_REDIS_TIMEOUT_TYPE: 'inf_redis_timeout_type', INF_JOB_STATUS: 'inf_job_status', diff --git a/ruoyi-ui/src/views/system/errorCode/index.vue b/ruoyi-ui/src/views/system/errorCode/index.vue new file mode 100644 index 000000000..498fa5458 --- /dev/null +++ b/ruoyi-ui/src/views/system/errorCode/index.vue @@ -0,0 +1,256 @@ + + + diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/InfErrorCodeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/InfErrorCodeConvert.java deleted file mode 100644 index 433793150..000000000 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/convert/errorcode/InfErrorCodeConvert.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.dashboard.modules.infra.convert.errorcode; - -import cn.iocoder.dashboard.common.pojo.PageResult; -import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; -import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeRespDTO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeCreateReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeExcelVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeRespVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeUpdateReqVO; -import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 错误码 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface InfErrorCodeConvert { - - InfErrorCodeConvert INSTANCE = Mappers.getMapper(InfErrorCodeConvert.class); - - InfErrorCodeDO convert(InfErrorCodeCreateReqVO bean); - - InfErrorCodeDO convert(InfErrorCodeUpdateReqVO bean); - - InfErrorCodeRespVO convert(InfErrorCodeDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - - InfErrorCodeDO convert(ErrorCodeAutoGenerateReqDTO bean); - - List convertList03(List list); - -} diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java b/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java index 490c9f95c..e02119b6c 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java +++ b/src/main/java/cn/iocoder/dashboard/modules/infra/enums/InfErrorCodeConstants.java @@ -30,9 +30,4 @@ public interface InfErrorCodeConstants { // ========== 文件 1001003000 ========== ErrorCode FILE_NOT_EXISTS = new ErrorCode(1001003000, "文件不存在"); - // ========== 错误码模块 1001004000 ========== - ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1001004000, "错误码不存在"); - ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1001004001, "已经存在编码为【{}}】的错误码"); - ErrorCode ERROR_CAN_NOT_UPDATE_SYSTEM_TYPE_ERROR = new ErrorCode(1001004002, "不能修改类型为系统内置的错误码"); - } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostExportReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostExportReqVO.java index f714cdfee..8e66825dd 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostExportReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostExportReqVO.java @@ -8,6 +8,9 @@ import lombok.Data; @Data public class SysPostExportReqVO { + @ApiModelProperty(value = "岗位编码", example = "yudao", notes = "模糊匹配") + private String code; + @ApiModelProperty(value = "岗位名称", example = "芋道", notes = "模糊匹配") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostPageReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostPageReqVO.java index 331aba57e..777edcb42 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostPageReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/dept/vo/post/SysPostPageReqVO.java @@ -11,6 +11,9 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class SysPostPageReqVO extends PageParam { + @ApiModelProperty(value = "岗位编码", example = "yudao", notes = "模糊匹配") + private String code; + @ApiModelProperty(value = "岗位名称", example = "芋道", notes = "模糊匹配") private String name; diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/InfErrorCodeController.http b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/SysErrorCodeController.http similarity index 100% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/InfErrorCodeController.http rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/SysErrorCodeController.http diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/InfErrorCodeController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/SysErrorCodeController.java similarity index 57% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/InfErrorCodeController.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/SysErrorCodeController.java index 730f305b5..93d5bdffc 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/InfErrorCodeController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/SysErrorCodeController.java @@ -1,13 +1,13 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode; +package cn.iocoder.dashboard.modules.system.controller.errorcode; import cn.iocoder.dashboard.common.pojo.CommonResult; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.framework.excel.core.util.ExcelUtils; import cn.iocoder.dashboard.framework.logger.operatelog.core.annotations.OperateLog; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.*; -import cn.iocoder.dashboard.modules.infra.convert.errorcode.InfErrorCodeConvert; -import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; -import cn.iocoder.dashboard.modules.infra.service.errorcode.InfErrorCodeService; +import cn.iocoder.dashboard.modules.system.convert.errorcode.SysErrorCodeConvert; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.*; +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.SysErrorCodeDO; +import cn.iocoder.dashboard.modules.system.service.errorcode.SysErrorCodeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -26,24 +26,24 @@ import static cn.iocoder.dashboard.framework.logger.operatelog.core.enums.Operat @Api(tags = "错误码") @RestController -@RequestMapping("/infra/error-code") +@RequestMapping("/system/error-code") @Validated -public class InfErrorCodeController { +public class SysErrorCodeController { @Resource - private InfErrorCodeService errorCodeService; + private SysErrorCodeService errorCodeService; @PostMapping("/create") @ApiOperation("创建错误码") - @PreAuthorize("@ss.hasPermission('infra:error-code:create')") - public CommonResult createErrorCode(@Valid @RequestBody InfErrorCodeCreateReqVO createReqVO) { + @PreAuthorize("@ss.hasPermission('system:error-code:create')") + public CommonResult createErrorCode(@Valid @RequestBody SysErrorCodeCreateReqVO createReqVO) { return success(errorCodeService.createErrorCode(createReqVO)); } @PutMapping("/update") @ApiOperation("更新错误码") - @PreAuthorize("@ss.hasPermission('infra:error-code:update')") - public CommonResult updateErrorCode(@Valid @RequestBody InfErrorCodeUpdateReqVO updateReqVO) { + @PreAuthorize("@ss.hasPermission('system:error-code:update')") + public CommonResult updateErrorCode(@Valid @RequestBody SysErrorCodeUpdateReqVO updateReqVO) { errorCodeService.updateErrorCode(updateReqVO); return success(true); } @@ -51,7 +51,7 @@ public class InfErrorCodeController { @DeleteMapping("/delete") @ApiOperation("删除错误码") @ApiImplicitParam(name = "id", value = "编号", required = true) - @PreAuthorize("@ss.hasPermission('infra:error-code:delete')") + @PreAuthorize("@ss.hasPermission('system:error-code:delete')") public CommonResult deleteErrorCode(@RequestParam("id") Long id) { errorCodeService.deleteErrorCode(id); return success(true); @@ -60,30 +60,30 @@ public class InfErrorCodeController { @GetMapping("/get") @ApiOperation("获得错误码") @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) - @PreAuthorize("@ss.hasPermission('infra:error-code:query')") - public CommonResult getErrorCode(@RequestParam("id") Long id) { - InfErrorCodeDO errorCode = errorCodeService.getErrorCode(id); - return success(InfErrorCodeConvert.INSTANCE.convert(errorCode)); + @PreAuthorize("@ss.hasPermission('system:error-code:query')") + public CommonResult getErrorCode(@RequestParam("id") Long id) { + SysErrorCodeDO errorCode = errorCodeService.getErrorCode(id); + return success(SysErrorCodeConvert.INSTANCE.convert(errorCode)); } @GetMapping("/page") @ApiOperation("获得错误码分页") - @PreAuthorize("@ss.hasPermission('infra:error-code:query')") - public CommonResult> getErrorCodePage(@Valid InfErrorCodePageReqVO pageVO) { - PageResult pageResult = errorCodeService.getErrorCodePage(pageVO); - return success(InfErrorCodeConvert.INSTANCE.convertPage(pageResult)); + @PreAuthorize("@ss.hasPermission('system:error-code:query')") + public CommonResult> getErrorCodePage(@Valid SysErrorCodePageReqVO pageVO) { + PageResult pageResult = errorCodeService.getErrorCodePage(pageVO); + return success(SysErrorCodeConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") @ApiOperation("导出错误码 Excel") - @PreAuthorize("@ss.hasPermission('infra:error-code:export')") + @PreAuthorize("@ss.hasPermission('system:error-code:export')") @OperateLog(type = EXPORT) - public void exportErrorCodeExcel(@Valid InfErrorCodeExportReqVO exportReqVO, + public void exportErrorCodeExcel(@Valid SysErrorCodeExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = errorCodeService.getErrorCodeList(exportReqVO); + List list = errorCodeService.getErrorCodeList(exportReqVO); // 导出 Excel - List datas = InfErrorCodeConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "错误码.xls", "数据", InfErrorCodeExcelVO.class, datas); + List datas = SysErrorCodeConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "错误码.xls", "数据", SysErrorCodeExcelVO.class, datas); } } diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeBaseVO.java similarity index 89% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeBaseVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeBaseVO.java index 4e1b6cc80..235ba8880 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeBaseVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull; * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class InfErrorCodeBaseVO { +public class SysErrorCodeBaseVO { @ApiModelProperty(value = "应用名", required = true, example = "dashboard") @NotNull(message = "应用名不能为空") diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeCreateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeCreateReqVO.java similarity index 63% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeCreateReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeCreateReqVO.java index 64049a236..7daedf7d3 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeCreateReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import io.swagger.annotations.ApiModel; import lombok.Data; @@ -9,6 +9,6 @@ import lombok.ToString; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class InfErrorCodeCreateReqVO extends InfErrorCodeBaseVO { +public class SysErrorCodeCreateReqVO extends SysErrorCodeBaseVO { } diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeExcelVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeExcelVO.java similarity index 83% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeExcelVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeExcelVO.java index d0c82e154..81461103e 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeExcelVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeExcelVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import cn.iocoder.dashboard.framework.excel.core.annotations.DictFormat; import cn.iocoder.dashboard.framework.excel.core.convert.DictConvert; @@ -7,7 +7,7 @@ import lombok.Data; import java.util.Date; -import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.INF_ERROR_CODE_TYPE; +import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.SYS_ERROR_CODE_TYPE; /** * 错误码 Excel VO @@ -15,13 +15,13 @@ import static cn.iocoder.dashboard.modules.system.enums.dict.SysDictTypeEnum.INF * @author 芋道源码 */ @Data -public class InfErrorCodeExcelVO { +public class SysErrorCodeExcelVO { @ExcelProperty("错误码编号") private Long id; @ExcelProperty(value = "错误码类型", converter = DictConvert.class) - @DictFormat(INF_ERROR_CODE_TYPE) + @DictFormat(SYS_ERROR_CODE_TYPE) private Integer type; @ExcelProperty("应用名") diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeExportReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeExportReqVO.java similarity index 91% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeExportReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeExportReqVO.java index 5e06da3a6..a9253d4f8 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeExportReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeExportReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -11,7 +11,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU @ApiModel(value = "错误码 Excel 导出 Request VO", description = "参数和 InfErrorCodePageReqVO 是一致的") @Data -public class InfErrorCodeExportReqVO { +public class SysErrorCodeExportReqVO { @ApiModelProperty(value = "错误码类型", example = "1") private Integer type; diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodePageReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodePageReqVO.java similarity index 91% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodePageReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodePageReqVO.java index 73bcac5a9..667110cf2 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodePageReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodePageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import cn.iocoder.dashboard.common.pojo.PageParam; import io.swagger.annotations.ApiModel; @@ -16,7 +16,7 @@ import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOU @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class InfErrorCodePageReqVO extends PageParam { +public class SysErrorCodePageReqVO extends PageParam { @ApiModelProperty(value = "错误码类型", example = "1", notes = "参见 SysErrorCodeTypeEnum 枚举类") private Integer type; diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeRespVO.java similarity index 83% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeRespVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeRespVO.java index 09c416062..ef0e804f1 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,7 +12,7 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class InfErrorCodeRespVO extends InfErrorCodeBaseVO { +public class SysErrorCodeRespVO extends SysErrorCodeBaseVO { @ApiModelProperty(value = "错误码编号", required = true, example = "1024") private Long id; diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeUpdateReqVO.java similarity index 78% rename from src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeUpdateReqVO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeUpdateReqVO.java index 78f6c39aa..1659b47c4 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/controller/errorcode/vo/InfErrorCodeUpdateReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/errorcode/vo/SysErrorCodeUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.controller.errorcode.vo; +package cn.iocoder.dashboard.modules.system.controller.errorcode.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class InfErrorCodeUpdateReqVO extends InfErrorCodeBaseVO { +public class SysErrorCodeUpdateReqVO extends SysErrorCodeBaseVO { @ApiModelProperty(value = "错误码编号", required = true, example = "1024") @NotNull(message = "错误码编号不能为空") diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java new file mode 100644 index 000000000..695c2fa02 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/errorcode/SysErrorCodeConvert.java @@ -0,0 +1,42 @@ +package cn.iocoder.dashboard.modules.system.convert.errorcode; + +import cn.iocoder.dashboard.common.pojo.PageResult; +import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; +import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeRespDTO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeExcelVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeRespVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.SysErrorCodeDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 错误码 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface SysErrorCodeConvert { + + SysErrorCodeConvert INSTANCE = Mappers.getMapper(SysErrorCodeConvert.class); + + SysErrorCodeDO convert(SysErrorCodeCreateReqVO bean); + + SysErrorCodeDO convert(SysErrorCodeUpdateReqVO bean); + + SysErrorCodeRespVO convert(SysErrorCodeDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + + SysErrorCodeDO convert(ErrorCodeAutoGenerateReqDTO bean); + + List convertList03(List list); + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/errorcode/InfErrorCodeDO.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/SysErrorCodeDO.java similarity index 74% rename from src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/errorcode/InfErrorCodeDO.java rename to src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/SysErrorCodeDO.java index 9d9e3526b..75c541791 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/dataobject/errorcode/InfErrorCodeDO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/dataobject/errorcode/SysErrorCodeDO.java @@ -1,7 +1,7 @@ -package cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode; +package cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode; import cn.iocoder.dashboard.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.dashboard.modules.infra.enums.errorcode.InfErrorCodeTypeEnum; +import cn.iocoder.dashboard.modules.system.enums.errorcode.SysErrorCodeTypeEnum; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -13,11 +13,11 @@ import lombok.ToString; * * @author 芋道源码 */ -@TableName(value = "inf_error_code") +@TableName(value = "sys_error_code") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class InfErrorCodeDO extends BaseDO { +public class SysErrorCodeDO extends BaseDO { /** * 错误码编号,自增 @@ -27,7 +27,7 @@ public class InfErrorCodeDO extends BaseDO { /** * 错误码类型 * - * 枚举 {@link InfErrorCodeTypeEnum} + * 枚举 {@link SysErrorCodeTypeEnum} */ private Integer type; /** diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dept/SysPostMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dept/SysPostMapper.java index 70013fe74..39716e09c 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dept/SysPostMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/dept/SysPostMapper.java @@ -22,12 +22,15 @@ public interface SysPostMapper extends BaseMapperX { default PageResult selectPage(SysPostPageReqVO reqVO) { return selectPage(reqVO, new QueryWrapperX() + .likeIfPresent("code", reqVO.getCode()) .likeIfPresent("name", reqVO.getName()) .eqIfPresent("status", reqVO.getStatus())); } default List selectList(SysPostExportReqVO reqVO) { - return selectList(new QueryWrapperX().likeIfPresent("name", reqVO.getName()) + return selectList(new QueryWrapperX() + .likeIfPresent("code", reqVO.getCode()) + .likeIfPresent("name", reqVO.getName()) .eqIfPresent("status", reqVO.getStatus())); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/SysErrorCodeMapper.java similarity index 59% rename from src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java rename to src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/SysErrorCodeMapper.java index 1e19fa488..63be95295 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/dal/mysql/errorcode/InfErrorCodeMapper.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/dal/mysql/errorcode/SysErrorCodeMapper.java @@ -1,11 +1,11 @@ -package cn.iocoder.dashboard.modules.infra.dal.mysql.errorcode; +package cn.iocoder.dashboard.modules.system.dal.mysql.errorcode; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.dashboard.framework.mybatis.core.query.QueryWrapperX; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeExportReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodePageReqVO; -import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeExportReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodePageReqVO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.SysErrorCodeDO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.ibatis.annotations.Mapper; @@ -14,10 +14,10 @@ import java.util.Date; import java.util.List; @Mapper -public interface InfErrorCodeMapper extends BaseMapperX { +public interface SysErrorCodeMapper extends BaseMapperX { - default PageResult selectPage(InfErrorCodePageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() + default PageResult selectPage(SysErrorCodePageReqVO reqVO) { + return selectPage(reqVO, new QueryWrapperX() .eqIfPresent("type", reqVO.getType()) .likeIfPresent("application_name", reqVO.getApplicationName()) .eqIfPresent("code", reqVO.getCode()) @@ -26,8 +26,8 @@ public interface InfErrorCodeMapper extends BaseMapperX { .orderByAsc("application_name", "code")); } - default List selectList(InfErrorCodeExportReqVO reqVO) { - return selectList(new QueryWrapperX() + default List selectList(SysErrorCodeExportReqVO reqVO) { + return selectList(new QueryWrapperX() .eqIfPresent("type", reqVO.getType()) .likeIfPresent("application_name", reqVO.getApplicationName()) .eqIfPresent("code", reqVO.getCode()) @@ -36,16 +36,16 @@ public interface InfErrorCodeMapper extends BaseMapperX { .orderByAsc("application_name", "code")); } - default List selectListByCodes(Collection codes) { - return selectList(new QueryWrapper().in("code", codes)); + 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 SysErrorCodeDO 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) + 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/enums/SysErrorCodeConstants.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java index b89581430..2d6eb305c 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/SysErrorCodeConstants.java @@ -91,4 +91,8 @@ public interface SysErrorCodeConstants { ErrorCode SMS_SEND_MOBILE_NOT_EXISTS = new ErrorCode(1002012000, "手机号不存在"); ErrorCode SMS_SEND_MOBILE_TEMPLATE_PARAM_MISS = new ErrorCode(1002012001, "模板参数({})缺失"); + // ========== 错误码模块 1002013000 ========== + ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002013000, "错误码不存在"); + ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002013001, "已经存在编码为【{}】的错误码"); + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/enums/dict/SysDictTypeEnum.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/dict/SysDictTypeEnum.java index 323cf652e..59e6d0d13 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/enums/dict/SysDictTypeEnum.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/dict/SysDictTypeEnum.java @@ -22,12 +22,12 @@ public enum SysDictTypeEnum { SYS_SMS_TEMPLATE_TYPE("sys_sms_template_type"), // 短信模板类型 SYS_SMS_SEND_STATUS("sys_sms_send_status"), // 短信发送状态 SYS_SMS_RECEIVE_STATUS("sys_sms_receive_status"), // 短信接收状态 + SYS_ERROR_CODE_TYPE("inf_error_code_type"), // 错误码的类型枚举 INF_REDIS_TIMEOUT_TYPE("inf_redis_timeout_type"), // Redis 超时类型 INF_JOB_STATUS("inf_job_status"), // 定时任务状态的枚举 INF_JOB_LOG_STATUS("inf_job_log_status"), // 定时任务日志状态的枚举 INF_API_ERROR_LOG_PROCESS_STATUS("inf_api_error_log_process_status"), // API 错误日志的处理状态的枚举 - INF_ERROR_CODE_TYPE("inf_error_code_type"), // 错误码的类型枚举 ; diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/enums/errorcode/InfErrorCodeTypeEnum.java b/src/main/java/cn/iocoder/dashboard/modules/system/enums/errorcode/SysErrorCodeTypeEnum.java similarity index 75% rename from src/main/java/cn/iocoder/dashboard/modules/infra/enums/errorcode/InfErrorCodeTypeEnum.java rename to src/main/java/cn/iocoder/dashboard/modules/system/enums/errorcode/SysErrorCodeTypeEnum.java index b8d7d79de..be59a23ea 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/enums/errorcode/InfErrorCodeTypeEnum.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/enums/errorcode/SysErrorCodeTypeEnum.java @@ -1,4 +1,4 @@ -package cn.iocoder.dashboard.modules.infra.enums.errorcode; +package cn.iocoder.dashboard.modules.system.enums.errorcode; import cn.iocoder.dashboard.common.core.IntArrayValuable; import lombok.AllArgsConstructor; @@ -13,7 +13,7 @@ import java.util.Arrays; */ @AllArgsConstructor @Getter -public enum InfErrorCodeTypeEnum implements IntArrayValuable { +public enum SysErrorCodeTypeEnum implements IntArrayValuable { /** * 自动生成 @@ -24,7 +24,7 @@ public enum InfErrorCodeTypeEnum implements IntArrayValuable { */ MANUAL_OPERATION(2); - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(InfErrorCodeTypeEnum::getType).toArray(); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(SysErrorCodeTypeEnum::getType).toArray(); /** * 类型 diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/service/errorcode/InfErrorCodeService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/SysErrorCodeService.java similarity index 52% rename from src/main/java/cn/iocoder/dashboard/modules/infra/service/errorcode/InfErrorCodeService.java rename to src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/SysErrorCodeService.java index 8035c9929..5d7354e7a 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/service/errorcode/InfErrorCodeService.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/SysErrorCodeService.java @@ -1,12 +1,12 @@ -package cn.iocoder.dashboard.modules.infra.service.errorcode; +package cn.iocoder.dashboard.modules.system.service.errorcode; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.framework.errorcode.core.service.ErrorCodeFrameworkService; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeCreateReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeExportReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodePageReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeUpdateReqVO; -import cn.iocoder.dashboard.modules.infra.dal.dataobject.errorcode.InfErrorCodeDO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeExportReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodePageReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.SysErrorCodeDO; import javax.validation.Valid; import java.util.List; @@ -16,7 +16,7 @@ import java.util.List; * * @author 芋道源码 */ -public interface InfErrorCodeService extends ErrorCodeFrameworkService { +public interface SysErrorCodeService extends ErrorCodeFrameworkService { /** * 创建错误码 @@ -24,14 +24,14 @@ public interface InfErrorCodeService extends ErrorCodeFrameworkService { * @param createReqVO 创建信息 * @return 编号 */ - Long createErrorCode(@Valid InfErrorCodeCreateReqVO createReqVO); + Long createErrorCode(@Valid SysErrorCodeCreateReqVO createReqVO); /** * 更新错误码 * * @param updateReqVO 更新信息 */ - void updateErrorCode(@Valid InfErrorCodeUpdateReqVO updateReqVO); + void updateErrorCode(@Valid SysErrorCodeUpdateReqVO updateReqVO); /** * 删除错误码 @@ -46,7 +46,7 @@ public interface InfErrorCodeService extends ErrorCodeFrameworkService { * @param id 编号 * @return 错误码 */ - InfErrorCodeDO getErrorCode(Long id); + SysErrorCodeDO getErrorCode(Long id); /** * 获得错误码分页 @@ -54,7 +54,7 @@ public interface InfErrorCodeService extends ErrorCodeFrameworkService { * @param pageReqVO 分页查询 * @return 错误码分页 */ - PageResult getErrorCodePage(InfErrorCodePageReqVO pageReqVO); + PageResult getErrorCodePage(SysErrorCodePageReqVO pageReqVO); /** * 获得错误码列表, 用于 Excel 导出 @@ -62,6 +62,6 @@ public interface InfErrorCodeService extends ErrorCodeFrameworkService { * @param exportReqVO 查询条件 * @return 错误码列表 */ - List getErrorCodeList(InfErrorCodeExportReqVO exportReqVO); + List getErrorCodeList(SysErrorCodeExportReqVO exportReqVO); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/infra/service/errorcode/impl/InfErrorCodeServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/SysErrorCodeServiceImpl.java similarity index 67% rename from src/main/java/cn/iocoder/dashboard/modules/infra/service/errorcode/impl/InfErrorCodeServiceImpl.java rename to src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/SysErrorCodeServiceImpl.java index 9b4cb6fd6..d0ba9b214 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/infra/service/errorcode/impl/InfErrorCodeServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/errorcode/impl/SysErrorCodeServiceImpl.java @@ -1,18 +1,18 @@ -package cn.iocoder.dashboard.modules.infra.service.errorcode.impl; +package cn.iocoder.dashboard.modules.system.service.errorcode.impl; import cn.hutool.core.collection.CollUtil; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeAutoGenerateReqDTO; import cn.iocoder.dashboard.framework.errorcode.core.dto.ErrorCodeRespDTO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeCreateReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeExportReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodePageReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeUpdateReqVO; -import cn.iocoder.dashboard.modules.infra.convert.errorcode.InfErrorCodeConvert; -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.infra.enums.errorcode.InfErrorCodeTypeEnum; -import cn.iocoder.dashboard.modules.infra.service.errorcode.InfErrorCodeService; +import cn.iocoder.dashboard.modules.system.convert.errorcode.SysErrorCodeConvert; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeExportReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodePageReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.SysErrorCodeDO; +import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.SysErrorCodeMapper; +import cn.iocoder.dashboard.modules.system.enums.errorcode.SysErrorCodeTypeEnum; +import cn.iocoder.dashboard.modules.system.service.errorcode.SysErrorCodeService; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -25,45 +25,46 @@ import java.util.List; import java.util.Map; import static cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.ERROR_CODE_DUPLICATE; -import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.ERROR_CODE_NOT_EXISTS; +import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*; import static cn.iocoder.dashboard.util.collection.CollectionUtils.convertMap; import static cn.iocoder.dashboard.util.collection.CollectionUtils.convertSet; /** * 错误码 Service 实现类 + * + * @author dlyan */ @Service @Validated @Slf4j -public class InfErrorCodeServiceImpl implements InfErrorCodeService { +public class SysErrorCodeServiceImpl implements SysErrorCodeService { @Resource - private InfErrorCodeMapper errorCodeMapper; + private SysErrorCodeMapper errorCodeMapper; @Override - public Long createErrorCode(InfErrorCodeCreateReqVO createReqVO) { + public Long createErrorCode(SysErrorCodeCreateReqVO createReqVO) { // 校验 code 重复 validateCodeDuplicate(createReqVO.getCode(), null); // 插入 - InfErrorCodeDO errorCode = InfErrorCodeConvert.INSTANCE.convert(createReqVO) - .setType(InfErrorCodeTypeEnum.MANUAL_OPERATION.getType()); + SysErrorCodeDO errorCode = SysErrorCodeConvert.INSTANCE.convert(createReqVO) + .setType(SysErrorCodeTypeEnum.MANUAL_OPERATION.getType()); errorCodeMapper.insert(errorCode); // 返回 return errorCode.getId(); } @Override - public void updateErrorCode(InfErrorCodeUpdateReqVO updateReqVO) { + public void updateErrorCode(SysErrorCodeUpdateReqVO updateReqVO) { // 校验存在 this.validateErrorCodeExists(updateReqVO.getId()); // 校验 code 重复 validateCodeDuplicate(updateReqVO.getCode(), updateReqVO.getId()); // 更新 - InfErrorCodeDO updateObj = InfErrorCodeConvert.INSTANCE.convert(updateReqVO) - .setType(InfErrorCodeTypeEnum.MANUAL_OPERATION.getType()); + SysErrorCodeDO updateObj = SysErrorCodeConvert.INSTANCE.convert(updateReqVO) + .setType(SysErrorCodeTypeEnum.MANUAL_OPERATION.getType()); errorCodeMapper.updateById(updateObj); } @@ -85,7 +86,7 @@ public class InfErrorCodeServiceImpl implements InfErrorCodeService { */ @VisibleForTesting public void validateCodeDuplicate(Integer code, Long id) { - InfErrorCodeDO errorCodeDO = errorCodeMapper.selectByCode(code); + SysErrorCodeDO errorCodeDO = errorCodeMapper.selectByCode(code); if (errorCodeDO == null) { return; } @@ -106,17 +107,17 @@ public class InfErrorCodeServiceImpl implements InfErrorCodeService { } @Override - public InfErrorCodeDO getErrorCode(Long id) { + public SysErrorCodeDO getErrorCode(Long id) { return errorCodeMapper.selectById(id); } @Override - public PageResult getErrorCodePage(InfErrorCodePageReqVO pageReqVO) { + public PageResult getErrorCodePage(SysErrorCodePageReqVO pageReqVO) { return errorCodeMapper.selectPage(pageReqVO); } @Override - public List getErrorCodeList(InfErrorCodeExportReqVO exportReqVO) { + public List getErrorCodeList(SysErrorCodeExportReqVO exportReqVO) { return errorCodeMapper.selectList(exportReqVO); } @@ -127,23 +128,23 @@ public class InfErrorCodeServiceImpl implements InfErrorCodeService { return; } // 获得错误码 - List errorCodeDOs = errorCodeMapper.selectListByCodes( + List errorCodeDOs = errorCodeMapper.selectListByCodes( convertSet(autoGenerateDTOs, ErrorCodeAutoGenerateReqDTO::getCode)); - Map errorCodeDOMap = convertMap(errorCodeDOs, InfErrorCodeDO::getCode); + Map errorCodeDOMap = convertMap(errorCodeDOs, SysErrorCodeDO::getCode); // 遍历 autoGenerateBOs 数组,逐个插入或更新。考虑到每次量级不大,就不走批量了 autoGenerateDTOs.forEach(autoGenerateDTO -> { - InfErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateDTO.getCode()); + SysErrorCodeDO errorCodeDO = errorCodeDOMap.get(autoGenerateDTO.getCode()); // 不存在,则进行新增 if (errorCodeDO == null) { - errorCodeDO = InfErrorCodeConvert.INSTANCE.convert(autoGenerateDTO) - .setType(InfErrorCodeTypeEnum.AUTO_GENERATION.getType()); + errorCodeDO = SysErrorCodeConvert.INSTANCE.convert(autoGenerateDTO) + .setType(SysErrorCodeTypeEnum.AUTO_GENERATION.getType()); errorCodeMapper.insert(errorCodeDO); return; } // 存在,则进行更新。更新有三个前置条件: // 条件 1. 只更新自动生成的错误码,即 Type 为 ErrorCodeTypeEnum.AUTO_GENERATION - if (!InfErrorCodeTypeEnum.AUTO_GENERATION.getType().equals(errorCodeDO.getType())) { + if (!SysErrorCodeTypeEnum.AUTO_GENERATION.getType().equals(errorCodeDO.getType())) { return; } // 条件 2. 分组 group 必须匹配,避免存在错误码冲突的情况 @@ -158,15 +159,15 @@ public class InfErrorCodeServiceImpl implements InfErrorCodeService { return; } // 最终匹配,进行更新 - errorCodeMapper.updateById(new InfErrorCodeDO().setId(errorCodeDO.getId()).setMessage(autoGenerateDTO.getMessage())); + errorCodeMapper.updateById(new SysErrorCodeDO().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 InfErrorCodeConvert.INSTANCE.convertList03(errorCodeDOs); + return SysErrorCodeConvert.INSTANCE.convertList03(errorCodeDOs); } } diff --git a/src/test/java/cn/iocoder/dashboard/modules/infra/service/errorcode/InfErrorCodeServiceTest.java b/src/test/java/cn/iocoder/dashboard/modules/system/service/errorcode/SysErrorCodeServiceTest.java similarity index 67% rename from src/test/java/cn/iocoder/dashboard/modules/infra/service/errorcode/InfErrorCodeServiceTest.java rename to src/test/java/cn/iocoder/dashboard/modules/system/service/errorcode/SysErrorCodeServiceTest.java index 1fe1b4712..300fc1627 100644 --- a/src/test/java/cn/iocoder/dashboard/modules/infra/service/errorcode/InfErrorCodeServiceTest.java +++ b/src/test/java/cn/iocoder/dashboard/modules/system/service/errorcode/SysErrorCodeServiceTest.java @@ -1,16 +1,16 @@ -package cn.iocoder.dashboard.modules.infra.service.errorcode; +package cn.iocoder.dashboard.modules.system.service.errorcode; import cn.iocoder.dashboard.BaseDbUnitTest; import cn.iocoder.dashboard.common.pojo.PageResult; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeCreateReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeExportReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodePageReqVO; -import cn.iocoder.dashboard.modules.infra.controller.errorcode.vo.InfErrorCodeUpdateReqVO; -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.controller.errorcode.vo.SysErrorCodeCreateReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeExportReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodePageReqVO; +import cn.iocoder.dashboard.modules.system.controller.errorcode.vo.SysErrorCodeUpdateReqVO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.errorcode.SysErrorCodeDO; +import cn.iocoder.dashboard.modules.system.dal.mysql.errorcode.SysErrorCodeMapper; import cn.iocoder.dashboard.modules.infra.enums.config.InfConfigTypeEnum; -import cn.iocoder.dashboard.modules.infra.enums.errorcode.InfErrorCodeTypeEnum; -import cn.iocoder.dashboard.modules.infra.service.errorcode.impl.InfErrorCodeServiceImpl; +import cn.iocoder.dashboard.modules.system.enums.errorcode.SysErrorCodeTypeEnum; +import cn.iocoder.dashboard.modules.system.service.errorcode.impl.SysErrorCodeServiceImpl; import cn.iocoder.dashboard.util.collection.ArrayUtils; import cn.iocoder.dashboard.util.object.ObjectUtils; import org.junit.jupiter.api.Test; @@ -21,8 +21,7 @@ import java.util.List; import java.util.function.Consumer; import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.ERROR_CODE_DUPLICATE; -import static cn.iocoder.dashboard.modules.infra.enums.InfErrorCodeConstants.ERROR_CODE_NOT_EXISTS; +import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.*; import static cn.iocoder.dashboard.util.AssertUtils.assertPojoEquals; import static cn.iocoder.dashboard.util.AssertUtils.assertServiceException; import static cn.iocoder.dashboard.util.RandomUtils.*; @@ -30,56 +29,56 @@ import static cn.iocoder.dashboard.util.date.DateUtils.buildTime; import static org.junit.jupiter.api.Assertions.*; /** -* {@link InfErrorCodeServiceImpl} 的单元测试类 +* {@link SysErrorCodeServiceImpl} 的单元测试类 * * @author 芋道源码 */ -@Import(InfErrorCodeServiceImpl.class) -public class InfErrorCodeServiceTest extends BaseDbUnitTest { +@Import(SysErrorCodeServiceImpl.class) +public class SysErrorCodeServiceTest extends BaseDbUnitTest { @Resource - private InfErrorCodeServiceImpl errorCodeService; + private SysErrorCodeServiceImpl errorCodeService; @Resource - private InfErrorCodeMapper errorCodeMapper; + private SysErrorCodeMapper errorCodeMapper; @Test public void testCreateErrorCode_success() { // 准备参数 - InfErrorCodeCreateReqVO reqVO = randomPojo(InfErrorCodeCreateReqVO.class); + SysErrorCodeCreateReqVO reqVO = randomPojo(SysErrorCodeCreateReqVO.class); // 调用 Long errorCodeId = errorCodeService.createErrorCode(reqVO); // 断言 assertNotNull(errorCodeId); // 校验记录的属性是否正确 - InfErrorCodeDO errorCode = errorCodeMapper.selectById(errorCodeId); + SysErrorCodeDO errorCode = errorCodeMapper.selectById(errorCodeId); assertPojoEquals(reqVO, errorCode); - assertEquals(InfErrorCodeTypeEnum.MANUAL_OPERATION.getType(), errorCode.getType()); + assertEquals(SysErrorCodeTypeEnum.MANUAL_OPERATION.getType(), errorCode.getType()); } @Test public void testUpdateErrorCode_success() { // mock 数据 - InfErrorCodeDO dbErrorCode = randomInfErrorCodeDO(); + SysErrorCodeDO dbErrorCode = randomInfErrorCodeDO(); errorCodeMapper.insert(dbErrorCode);// @Sql: 先插入出一条存在的数据 // 准备参数 - InfErrorCodeUpdateReqVO reqVO = randomPojo(InfErrorCodeUpdateReqVO.class, o -> { + SysErrorCodeUpdateReqVO reqVO = randomPojo(SysErrorCodeUpdateReqVO.class, o -> { o.setId(dbErrorCode.getId()); // 设置更新的 ID }); // 调用 errorCodeService.updateErrorCode(reqVO); // 校验是否更新正确 - InfErrorCodeDO errorCode = errorCodeMapper.selectById(reqVO.getId()); // 获取最新的 + SysErrorCodeDO errorCode = errorCodeMapper.selectById(reqVO.getId()); // 获取最新的 assertPojoEquals(reqVO, errorCode); - assertEquals(InfErrorCodeTypeEnum.MANUAL_OPERATION.getType(), errorCode.getType()); + assertEquals(SysErrorCodeTypeEnum.MANUAL_OPERATION.getType(), errorCode.getType()); } @Test public void testDeleteErrorCode_success() { // mock 数据 - InfErrorCodeDO dbErrorCode = randomInfErrorCodeDO(); + SysErrorCodeDO dbErrorCode = randomInfErrorCodeDO(); errorCodeMapper.insert(dbErrorCode);// @Sql: 先插入出一条存在的数据 // 准备参数 Long id = dbErrorCode.getId(); @@ -93,10 +92,10 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { @Test public void testGetErrorCodePage() { // mock 数据 - InfErrorCodeDO dbErrorCode = initGetErrorCodePage(); + SysErrorCodeDO dbErrorCode = initGetErrorCodePage(); // 准备参数 - InfErrorCodePageReqVO reqVO = new InfErrorCodePageReqVO(); - reqVO.setType(InfErrorCodeTypeEnum.AUTO_GENERATION.getType()); + SysErrorCodePageReqVO reqVO = new SysErrorCodePageReqVO(); + reqVO.setType(SysErrorCodeTypeEnum.AUTO_GENERATION.getType()); reqVO.setApplicationName("yudao"); reqVO.setCode(1); reqVO.setMessage("yu"); @@ -104,7 +103,7 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { reqVO.setEndCreateTime(buildTime(2020, 11, 30)); // 调用 - PageResult pageResult = errorCodeService.getErrorCodePage(reqVO); + PageResult pageResult = errorCodeService.getErrorCodePage(reqVO); // 断言 assertEquals(1, pageResult.getTotal()); assertEquals(1, pageResult.getList().size()); @@ -114,9 +113,9 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { /** * 初始化 getErrorCodePage 方法的测试数据 */ - private InfErrorCodeDO initGetErrorCodePage() { - InfErrorCodeDO dbErrorCode = randomInfErrorCodeDO(o -> { // 等会查询到 - o.setType(InfErrorCodeTypeEnum.AUTO_GENERATION.getType()); + private SysErrorCodeDO initGetErrorCodePage() { + SysErrorCodeDO dbErrorCode = randomInfErrorCodeDO(o -> { // 等会查询到 + o.setType(SysErrorCodeTypeEnum.AUTO_GENERATION.getType()); o.setApplicationName("yudaoyuanma"); o.setCode(1); o.setMessage("yudao"); @@ -124,7 +123,7 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { }); errorCodeMapper.insert(dbErrorCode); // 测试 type 不匹配 - errorCodeMapper.insert(ObjectUtils.clone(dbErrorCode, o -> o.setType(InfErrorCodeTypeEnum.MANUAL_OPERATION.getType()))); + errorCodeMapper.insert(ObjectUtils.clone(dbErrorCode, o -> o.setType(SysErrorCodeTypeEnum.MANUAL_OPERATION.getType()))); // 测试 applicationName 不匹配 errorCodeMapper.insert(ObjectUtils.clone(dbErrorCode, o -> o.setApplicationName("yunai"))); // 测试 code 不匹配 @@ -139,10 +138,10 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { @Test public void testGetErrorCodeList() { // mock 数据 - InfErrorCodeDO dbErrorCode = initGetErrorCodePage(); + SysErrorCodeDO dbErrorCode = initGetErrorCodePage(); // 准备参数 - InfErrorCodeExportReqVO reqVO = new InfErrorCodeExportReqVO(); - reqVO.setType(InfErrorCodeTypeEnum.AUTO_GENERATION.getType()); + SysErrorCodeExportReqVO reqVO = new SysErrorCodeExportReqVO(); + reqVO.setType(SysErrorCodeTypeEnum.AUTO_GENERATION.getType()); reqVO.setApplicationName("yudao"); reqVO.setCode(1); reqVO.setMessage("yu"); @@ -150,7 +149,7 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { reqVO.setEndCreateTime(buildTime(2020, 11, 30)); // 调用 - List list = errorCodeService.getErrorCodeList(reqVO); + List list = errorCodeService.getErrorCodeList(reqVO); // 断言 assertEquals(1, list.size()); assertPojoEquals(dbErrorCode, list.get(0)); @@ -190,11 +189,11 @@ public class InfErrorCodeServiceTest extends BaseDbUnitTest { // ========== 随机对象 ========== @SafeVarargs - private static InfErrorCodeDO randomInfErrorCodeDO(Consumer... consumers) { - Consumer consumer = (o) -> { + private static SysErrorCodeDO randomInfErrorCodeDO(Consumer... consumers) { + Consumer consumer = (o) -> { o.setType(randomEle(InfConfigTypeEnum.values()).getType()); // 保证 key 的范围 }; - return randomPojo(InfErrorCodeDO.class, ArrayUtils.append(consumer, consumers)); + return randomPojo(SysErrorCodeDO.class, ArrayUtils.append(consumer, consumers)); } } diff --git a/src/test/resources/sql/clean.sql b/src/test/resources/sql/clean.sql index 47b84c62b..78f02ee4f 100644 --- a/src/test/resources/sql/clean.sql +++ b/src/test/resources/sql/clean.sql @@ -5,7 +5,6 @@ DELETE FROM "inf_job"; DELETE FROM "inf_job_log"; DELETE FROM "inf_api_access_log"; DELETE FROM "inf_api_error_log"; -DELETE FROM "inf_error_code"; -- sys 开头的 DB DELETE FROM "sys_dept"; @@ -23,3 +22,4 @@ DELETE FROM "sys_user"; DELETE FROM "sys_sms_channel"; DELETE FROM "sys_sms_template"; DELETE FROM "sys_sms_log"; +DELETE FROM "sys_error_code"; diff --git a/src/test/resources/sql/create_tables.sql b/src/test/resources/sql/create_tables.sql index cf89b64b6..b9060373d 100644 --- a/src/test/resources/sql/create_tables.sql +++ b/src/test/resources/sql/create_tables.sql @@ -412,7 +412,7 @@ CREATE TABLE IF NOT EXISTS "sys_sms_log" ( PRIMARY KEY ("id") ) COMMENT '短信日志'; -CREATE TABLE IF NOT EXISTS "inf_error_code" ( +CREATE TABLE IF NOT EXISTS "sys_error_code" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, "type" tinyint NOT NULL DEFAULT '0', "application_name" varchar(50) NOT NULL,