错误码的管理的迁移

This commit is contained in:
YunaiV
2020-07-20 20:29:41 +08:00
parent 187b17ed01
commit e6201b00c1
4 changed files with 15 additions and 5 deletions

View File

@@ -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));
}

View File

@@ -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();
}