错误码的管理的迁移
This commit is contained in:
parent
187b17ed01
commit
e6201b00c1
|
@ -38,7 +38,7 @@ public class ErrorCodeRemoteLoader {
|
|||
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void loadErrorCodes() {
|
||||
// 从 ErrorCodeRpc 加载 ErrorCode 错误码
|
||||
// 从 ErrorCodeRpc 全量加载 ErrorCode 错误码
|
||||
CommonResult<List<ErrorCodeVO>> 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<List<ErrorCodeVO>> listErrorCodesResult = errorCodeRpc.listErrorCodes(group, maxUpdateTime);
|
||||
listErrorCodesResult.checkError();
|
||||
if (CollectionUtils.isEmpty(listErrorCodesResult.getData())) {
|
||||
|
|
|
@ -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<Integer> createErrorCode(@Valid ErrorCodeCreateDTO createDTO) {
|
||||
return success(errorCodeManager.createErrorCode(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新错误码")
|
||||
@RequiresPermissions("system:error-code:update")
|
||||
public CommonResult<Boolean> 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<Boolean> 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<ErrorCodeVO> getErrorCode(@RequestParam("errorCodeId") Integer errorCodeId) {
|
||||
return success(errorCodeManager.getErrorCode(errorCodeId));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得错误码分页")
|
||||
@RequiresPermissions("system:error-code:page")
|
||||
public CommonResult<PageResult<ErrorCodeVO>> pageErrorCode(ErrorCodePageDTO pageDTO) {
|
||||
return success(errorCodeManager.pageErrorCode(pageDTO));
|
||||
}
|
||||
|
|
|
@ -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<Integer> createErrorCodeResult = errorCodeRpc.createErrorCode(ErrorCodeConvert.INSTANCE.convert(createDTO));
|
||||
CommonResult<Integer> 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<Boolean> updateErrorCodeResult = errorCodeRpc.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO));
|
||||
CommonResult<Boolean> updateErrorCodeResult = errorCodeRpc.updateErrorCode(ErrorCodeConvert.INSTANCE.convert(updateDTO)
|
||||
.setType(ErrorCodeTypeEnum.MANUAL_OPERATION.getType()));
|
||||
updateErrorCodeResult.checkError();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public enum ErrorCodeTypeEnum implements IntArrayValuable {
|
|||
*/
|
||||
AUTO_GENERATION(1),
|
||||
/**
|
||||
* 手动处理
|
||||
* 手动编辑
|
||||
*/
|
||||
MANUAL_OPERATION(2);
|
||||
|
||||
|
|
Loading…
Reference in New Issue