From e6201b00c12b6cb9f80565f427018c6aa5913ae9 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Mon, 20 Jul 2020 20:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=A0=81=E7=9A=84=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=9A=84=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/system/errorcode/core/ErrorCodeRemoteLoader.java | 5 +++-- .../controller/errorcode/ErrorCodeController.java | 6 ++++++ .../managementweb/manager/errorcode/ErrorCodeManager.java | 7 +++++-- .../systemservice/enums/errorcode/ErrorCodeTypeEnum.java | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java index 5a0fa5fac..db5d8d2de 100644 --- a/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java +++ b/common/mall-spring-boot-starter-system-error-code/src/main/java/cn/iocoder/mall/system/errorcode/core/ErrorCodeRemoteLoader.java @@ -38,7 +38,7 @@ public class ErrorCodeRemoteLoader { @EventListener(ApplicationReadyEvent.class) public void loadErrorCodes() { - // 从 ErrorCodeRpc 加载 ErrorCode 错误码 + // 从 ErrorCodeRpc 全量加载 ErrorCode 错误码 CommonResult> listErrorCodesResult = errorCodeRpc.listErrorCodes(group, null); listErrorCodesResult.checkError(); logger.info("[loadErrorCodes][从 group({}) 全量加载到 {} 个 ErrorCode 错误码]", group, listErrorCodesResult.getData().size()); @@ -52,7 +52,8 @@ public class ErrorCodeRemoteLoader { @Scheduled(fixedDelay = REFRESH_ERROR_CODE_PERIOD, initialDelay = REFRESH_ERROR_CODE_PERIOD) public void refreshErrorCodes() { - // 从 ErrorCodeRpc 加载 ErrorCode 错误码 + // 从 ErrorCodeRpc 增量加载 ErrorCode 错误码 + // TODO 优化点:假设删除错误码的配置,会存在问题; CommonResult> listErrorCodesResult = errorCodeRpc.listErrorCodes(group, maxUpdateTime); listErrorCodesResult.checkError(); if (CollectionUtils.isEmpty(listErrorCodesResult.getData())) { diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/errorcode/ErrorCodeController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/errorcode/ErrorCodeController.java index e81cf72e9..de43d18d2 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/errorcode/ErrorCodeController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/errorcode/ErrorCodeController.java @@ -7,6 +7,7 @@ import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodePageDTO; import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeUpdateDTO; import cn.iocoder.mall.managementweb.controller.errorcode.vo.ErrorCodeVO; import cn.iocoder.mall.managementweb.manager.errorcode.ErrorCodeManager; +import cn.iocoder.security.annotations.RequiresPermissions; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -32,12 +33,14 @@ public class ErrorCodeController { @PostMapping("/create") @ApiOperation("创建错误码") + @RequiresPermissions("system:error-code:create") public CommonResult createErrorCode(@Valid ErrorCodeCreateDTO createDTO) { return success(errorCodeManager.createErrorCode(createDTO)); } @PostMapping("/update") @ApiOperation("更新错误码") + @RequiresPermissions("system:error-code:update") public CommonResult updateErrorCode(@Valid ErrorCodeUpdateDTO updateDTO) { errorCodeManager.updateErrorCode(updateDTO); return success(true); @@ -46,6 +49,7 @@ public class ErrorCodeController { @PostMapping("/delete") @ApiOperation("删除错误码") @ApiImplicitParam(name = "errorCodeId", value = "错误码编号", required = true) + @RequiresPermissions("system:error-code:delete") public CommonResult deleteErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) { errorCodeManager.deleteErrorCode(errorCodeId); return success(true); @@ -54,12 +58,14 @@ public class ErrorCodeController { @GetMapping("/get") @ApiOperation("获得错误码") @ApiImplicitParam(name = "errorCodeId", value = "错误码编号", required = true) + @RequiresPermissions("system:error-code:page") public CommonResult getErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) { return success(errorCodeManager.getErrorCode(errorCodeId)); } @GetMapping("/page") @ApiOperation("获得错误码分页") + @RequiresPermissions("system:error-code:page") public CommonResult> pageErrorCode(ErrorCodePageDTO pageDTO) { return success(errorCodeManager.pageErrorCode(pageDTO)); } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/errorcode/ErrorCodeManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/errorcode/ErrorCodeManager.java index 2eccd05ba..da8059d1d 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/errorcode/ErrorCodeManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/errorcode/ErrorCodeManager.java @@ -7,6 +7,7 @@ import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodePageDTO; import cn.iocoder.mall.managementweb.controller.errorcode.dto.ErrorCodeUpdateDTO; import cn.iocoder.mall.managementweb.controller.errorcode.vo.ErrorCodeVO; import cn.iocoder.mall.managementweb.convert.errorcode.ErrorCodeConvert; +import cn.iocoder.mall.systemservice.enums.errorcode.ErrorCodeTypeEnum; import cn.iocoder.mall.systemservice.rpc.errorcode.ErrorCodeRpc; import org.apache.dubbo.config.annotation.Reference; import org.springframework.stereotype.Service; @@ -29,7 +30,8 @@ public class ErrorCodeManager { * @return 错误码 */ public Integer createErrorCode(ErrorCodeCreateDTO createDTO) { - CommonResult createErrorCodeResult = errorCodeRpc.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO)); + CommonResult createErrorCodeResult = errorCodeRpc.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO) + .setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType())); createErrorCodeResult.checkError(); return createErrorCodeResult.getData(); } @@ -40,7 +42,8 @@ public class ErrorCodeManager { * @param updateDTO 更新错误码 DTO */ public void updateErrorCode(ErrorCodeUpdateDTO updateDTO) { - CommonResult updateErrorCodeResult = errorCodeRpc.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)); + CommonResult updateErrorCodeResult = errorCodeRpc.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO) + .setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType())); updateErrorCodeResult.checkError(); } diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/errorcode/ErrorCodeTypeEnum.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/errorcode/ErrorCodeTypeEnum.java index 9c40b38fe..9d87481d4 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/errorcode/ErrorCodeTypeEnum.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/errorcode/ErrorCodeTypeEnum.java @@ -19,7 +19,7 @@ public enum ErrorCodeTypeEnum implements IntArrayValuable { */ AUTO_GENERATION(1), /** - * 手动处理 + * 手动编辑 */ MANUAL_OPERATION(2);