From b25d7589c297e8138ec9d753b327e4f7d58fcd1a Mon Sep 17 00:00:00 2001 From: ZhouXY108 Date: Sat, 9 Sep 2023 18:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20UnifiedResponse=20?= =?UTF-8?q?=E6=9B=BF=E4=BB=A3=20RestfulResult?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../handler/DefaultExceptionHandler.java | 4 +-- .../handler/SysExceptionHandler.java | 6 ++--- .../handler/AccountLoginExceptionHandler.java | 12 ++++++--- .../handler/SaTokenExceptionHandler.java | 4 +-- .../controller/AccountContextController.java | 22 ++++++++-------- .../AccountManagementController.java | 14 +++++----- .../web/controller/AdminLoginController.java | 10 +++---- .../controller/DictManagementController.java | 16 ++++++------ .../controller/MenuManagementController.java | 18 ++++++------- .../controller/RegisterAccountController.java | 8 +++--- .../controller/RoleManagementController.java | 26 +++++++++---------- 11 files changed, 72 insertions(+), 68 deletions(-) diff --git a/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/DefaultExceptionHandler.java b/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/DefaultExceptionHandler.java index 6374a97..d8cc94c 100644 --- a/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/DefaultExceptionHandler.java +++ b/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/DefaultExceptionHandler.java @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import lombok.extern.slf4j.Slf4j; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * 默认异常的处理器 @@ -62,7 +62,7 @@ public class DefaultExceptionHandler extends BaseExceptionHandler { DataAccessException.class, MethodArgumentNotValidException.class }) - public ResponseEntity handleException(Exception e) { + public ResponseEntity handleException(Exception e) { log.error(e.getMessage(), e); return buildExceptionResponse(e); } diff --git a/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/SysExceptionHandler.java b/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/SysExceptionHandler.java index 9fd763f..680db42 100644 --- a/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/SysExceptionHandler.java +++ b/plusone-basic/plusone-basic-application/src/main/java/xyz/zhouxy/plusone/exception/handler/SysExceptionHandler.java @@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import lombok.extern.slf4j.Slf4j; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; import xyz.zhouxy.plusone.exception.SysException; @RestControllerAdvice @@ -21,9 +21,9 @@ public class SysExceptionHandler extends BaseExceptionHandler { } @ExceptionHandler({ SysException.class }) - public ResponseEntity handleException(@Nonnull Exception e) { + public ResponseEntity handleException(@Nonnull Exception e) { log.error(e.getMessage(), e); HttpStatus httpStatus = getHttpStatus(e); - return new ResponseEntity<>(RestfulResult.error(getErrorCode(e), "系统错误"), httpStatus); + return new ResponseEntity<>(UnifiedResponse.error(getErrorCode(e), "系统错误"), httpStatus); } } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/AccountLoginExceptionHandler.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/AccountLoginExceptionHandler.java index b54c697..5a2ff27 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/AccountLoginExceptionHandler.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/AccountLoginExceptionHandler.java @@ -1,22 +1,26 @@ package xyz.zhouxy.plusone.system.application.common.exception.handler; +import java.util.Objects; + +import javax.annotation.Nonnull; + import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; import xyz.zhouxy.plusone.system.application.common.exception.AccountLoginException; @RestControllerAdvice public class AccountLoginExceptionHandler extends BaseExceptionHandler { - public AccountLoginExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) { + public AccountLoginExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) { super(exceptionInfoHolder); } @ExceptionHandler({ AccountLoginException.class }) - public ResponseEntity handleException(Exception e) { - return buildExceptionResponse(e); + public ResponseEntity handleException(Exception e) { + return buildExceptionResponse(Objects.requireNonNull(e)); } } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/SaTokenExceptionHandler.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/SaTokenExceptionHandler.java index ea11279..27a7602 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/SaTokenExceptionHandler.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/common/exception/handler/SaTokenExceptionHandler.java @@ -17,7 +17,7 @@ import cn.dev33.satoken.exception.SaTokenException; import cn.dev33.satoken.exception.SameTokenInvalidException; import lombok.extern.slf4j.Slf4j; import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * Sa-Token 异常处理器 @@ -52,7 +52,7 @@ public class SaTokenExceptionHandler extends BaseExceptionHandler { } @ExceptionHandler(SaTokenException.class) - public ResponseEntity handleSaTokenException(SaTokenException e) { + public ResponseEntity handleSaTokenException(SaTokenException e) { log.error(e.getMessage(), e); return buildExceptionResponse(e); } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountContextController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountContextController.java index c982444..bb56d45 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountContextController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountContextController.java @@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; import xyz.zhouxy.plusone.system.application.service.AccountContextService; import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordCommand; import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordWithoutLoginCommand; @@ -28,34 +28,34 @@ public class AccountContextController { } @GetMapping("info") - public RestfulResult getAccountInfo() { + public UnifiedResponse getAccountInfo() { adminAuthLogic.checkLogin(); var result = service.getAccountInfo(); - return RestfulResult.success("查询成功", result); + return UnifiedResponse.success("查询成功", result); } @GetMapping("logout") - public RestfulResult logout() { + public UnifiedResponse logout() { service.logout(); - return RestfulResult.success("注销成功"); + return UnifiedResponse.success("注销成功"); } @GetMapping("menus") - public RestfulResult getMenuTree() { + public UnifiedResponse getMenuTree() { adminAuthLogic.checkLogin(); var result = service.getMenuTree(); - return RestfulResult.success("查询成功", result); + return UnifiedResponse.success("查询成功", result); } @PostMapping("changePassword") - public RestfulResult changePassword(ChangePasswordCommand command) { + public UnifiedResponse changePassword(ChangePasswordCommand command) { service.changePassword(command); - return RestfulResult.success("修改成功,请重新登录。"); + return UnifiedResponse.success("修改成功,请重新登录。"); } @PostMapping("changePasswordWithoutLogin") - public RestfulResult changePasswordWithoutLogin(ChangePasswordWithoutLoginCommand command) { + public UnifiedResponse changePasswordWithoutLogin(ChangePasswordWithoutLoginCommand command) { service.changePasswordWithoutLogin(command); - return RestfulResult.success("修改成功,请重新登录。"); + return UnifiedResponse.success("修改成功,请重新登录。"); } } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountManagementController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountManagementController.java index 55a6070..c989761 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountManagementController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AccountManagementController.java @@ -1,7 +1,7 @@ package xyz.zhouxy.plusone.system.application.web.controller; import static xyz.zhouxy.plusone.system.constant.AuthLogic.adminAuthLogic; -import static xyz.zhouxy.plusone.commons.util.RestfulResult.success; +import static xyz.zhouxy.plusone.commons.util.UnifiedResponse.success; import java.util.List; @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; import xyz.zhouxy.plusone.system.application.query.params.AccountQueryParams; import xyz.zhouxy.plusone.system.application.service.AccountManagementService; import xyz.zhouxy.plusone.system.application.service.command.CreateAccountCommand; @@ -38,7 +38,7 @@ public class AccountManagementController { } @PostMapping - public RestfulResult createAccount(@RequestBody @Valid CreateAccountCommand command) { + public UnifiedResponse createAccount(@RequestBody @Valid CreateAccountCommand command) { adminAuthLogic.checkLogin(); adminAuthLogic.checkPermission("sys-account-create"); service.createAccount(command); @@ -46,7 +46,7 @@ public class AccountManagementController { } @DeleteMapping - public RestfulResult deleteAccounts(@RequestBody List ids) { + public UnifiedResponse deleteAccounts(@RequestBody List ids) { adminAuthLogic.checkLogin(); adminAuthLogic.checkPermission("sys-account-delete"); service.deleteAccounts(ids); @@ -54,7 +54,7 @@ public class AccountManagementController { } @PatchMapping("{id}") - public RestfulResult updateAccountInfo( + public UnifiedResponse updateAccountInfo( @PathVariable("id") Long id, @RequestBody @Valid UpdateAccountCommand command) { adminAuthLogic.checkLogin(); @@ -64,7 +64,7 @@ public class AccountManagementController { } @GetMapping("query") - public RestfulResult queryAccountOverviewList(AccountQueryParams queryParams) { + public UnifiedResponse queryAccountOverviewList(AccountQueryParams queryParams) { adminAuthLogic.checkLogin(); adminAuthLogic.checkPermission("sys-account-list"); var accountOverviewList = service.queryAccountOverviewList(queryParams); @@ -72,7 +72,7 @@ public class AccountManagementController { } @GetMapping("{accountId}") - public RestfulResult queryAccountDetails(@PathVariable("accountId") Long accountId) { + public UnifiedResponse queryAccountDetails(@PathVariable("accountId") Long accountId) { adminAuthLogic.checkLogin(); adminAuthLogic.checkPermission("sys-account-details"); var accountDetails = service.queryAccountDetails(accountId); diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AdminLoginController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AdminLoginController.java index dec0730..3ebd290 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AdminLoginController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/AdminLoginController.java @@ -1,6 +1,6 @@ package xyz.zhouxy.plusone.system.application.web.controller; -import static xyz.zhouxy.plusone.commons.util.RestfulResult.success; +import static xyz.zhouxy.plusone.commons.util.UnifiedResponse.success; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController; import xyz.zhouxy.plusone.system.application.service.AdminLoginService; import xyz.zhouxy.plusone.system.application.service.command.LoginByOtpCommand; import xyz.zhouxy.plusone.system.application.service.command.LoginByPasswordCommand; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * Admin 账号登录 @@ -30,19 +30,19 @@ public class AdminLoginController { } @PostMapping("byPassword") - public RestfulResult loginByPassword(@RequestBody LoginByPasswordCommand command) { + public UnifiedResponse loginByPassword(@RequestBody LoginByPasswordCommand command) { var loginInfo = service.loginByPassword(command); return success("登录成功", loginInfo); } @PostMapping("byOtp") - public RestfulResult loginByOtp(@RequestBody LoginByOtpCommand command) { + public UnifiedResponse loginByOtp(@RequestBody LoginByOtpCommand command) { var loginInfo = service.loginByOtp(command); return success("登录成功", loginInfo); } @GetMapping("sendOtp") - public RestfulResult sendOtp(@RequestParam String principal) { + public UnifiedResponse sendOtp(@RequestParam String principal) { service.sendOtp(principal); return success("发送成功"); } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/DictManagementController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/DictManagementController.java index 737c049..29c24a3 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/DictManagementController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/DictManagementController.java @@ -1,7 +1,7 @@ package xyz.zhouxy.plusone.system.application.web.controller; import static xyz.zhouxy.plusone.system.constant.AuthLogic.adminAuthLogic; -import static xyz.zhouxy.plusone.commons.util.RestfulResult.success; +import static xyz.zhouxy.plusone.commons.util.UnifiedResponse.success; import java.util.List; @@ -20,7 +20,7 @@ import xyz.zhouxy.plusone.system.application.query.params.DictQueryParams; import xyz.zhouxy.plusone.system.application.service.DictManagementService; import xyz.zhouxy.plusone.system.application.service.command.CreateDictCommand; import xyz.zhouxy.plusone.system.application.service.command.UpdateDictCommand; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * 数据字典管理 @@ -38,21 +38,21 @@ public class DictManagementController { } @PostMapping - public RestfulResult createDict(@RequestBody @Valid CreateDictCommand command) { + public UnifiedResponse createDict(@RequestBody @Valid CreateDictCommand command) { adminAuthLogic.checkPermission("sys-dict-create"); service.createDict(command); return success(); } @DeleteMapping - public RestfulResult deleteDicts(@RequestBody List ids) { + public UnifiedResponse deleteDicts(@RequestBody List ids) { adminAuthLogic.checkPermission("sys-dict-delete"); service.deleteDicts(ids); return success(); } @PatchMapping("{id}") - public RestfulResult updateDict( + public UnifiedResponse updateDict( @PathVariable("id") Long id, @RequestBody @Valid UpdateDictCommand command) { adminAuthLogic.checkPermission("sys-dict-update"); @@ -61,21 +61,21 @@ public class DictManagementController { } @GetMapping("{dictId}") - public RestfulResult findDictDetails(@PathVariable("dictId") Long dictId) { + public UnifiedResponse findDictDetails(@PathVariable("dictId") Long dictId) { adminAuthLogic.checkPermission("sys-dict-details"); var dictDetails = service.findDictDetails(dictId); return success("查询成功", dictDetails); } @GetMapping("all") - public RestfulResult loadAllDicts() { + public UnifiedResponse loadAllDicts() { adminAuthLogic.checkPermissionAnd("sys-dict-list", "sys-dict-details"); var dicts = service.loadAllDicts(); return success("查询成功", dicts); } @GetMapping("query") - public RestfulResult queryDictOverviewList(@Valid DictQueryParams queryParams) { + public UnifiedResponse queryDictOverviewList(@Valid DictQueryParams queryParams) { adminAuthLogic.checkPermission("sys-dict-list"); var dicts = service.queryDictOverviewList(queryParams); return success("查询成功", dicts); diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/MenuManagementController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/MenuManagementController.java index 076a238..aad1e19 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/MenuManagementController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/MenuManagementController.java @@ -1,7 +1,7 @@ package xyz.zhouxy.plusone.system.application.web.controller; import static xyz.zhouxy.plusone.system.constant.AuthLogic.adminAuthLogic; -import static xyz.zhouxy.plusone.commons.util.RestfulResult.success; +import static xyz.zhouxy.plusone.commons.util.UnifiedResponse.success; import javax.validation.Valid; @@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController; import xyz.zhouxy.plusone.system.application.service.MenuManagementService; import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand; import xyz.zhouxy.plusone.system.application.service.command.UpdateMenuCommand; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * 菜单管理 @@ -37,7 +37,7 @@ public class MenuManagementController { // ==================== create ==================== @PostMapping - public RestfulResult createMenu(@RequestBody @Valid CreateMenuCommand command) { + public UnifiedResponse createMenu(@RequestBody @Valid CreateMenuCommand command) { adminAuthLogic.checkPermission("sys-menu-create"); service.createMenu(command); return success(); @@ -45,7 +45,7 @@ public class MenuManagementController { // ==================== delete ==================== @DeleteMapping("{id}") - public RestfulResult deleteMenu(@PathVariable("id") Long id) { + public UnifiedResponse deleteMenu(@PathVariable("id") Long id) { adminAuthLogic.checkPermission("sys-menu-delete"); service.deleteMenu(id); return success(); @@ -53,7 +53,7 @@ public class MenuManagementController { // ==================== update ==================== @PatchMapping("{id}") - public RestfulResult updateMenu( + public UnifiedResponse updateMenu( @PathVariable("id") Long id, @RequestBody @Valid UpdateMenuCommand command) { adminAuthLogic.checkPermission("sys-menu-update"); @@ -63,21 +63,21 @@ public class MenuManagementController { // ==================== query ==================== @GetMapping("{id}") - public RestfulResult findById(@PathVariable("id") Long id) { + public UnifiedResponse findById(@PathVariable("id") Long id) { adminAuthLogic.checkPermission("sys-menu-details"); var result = service.findById(id); - return RestfulResult.success("查询成功", result); + return UnifiedResponse.success("查询成功", result); } @GetMapping("queryByAccountId") - public RestfulResult queryByAccountId(@RequestParam Long accountId) { + public UnifiedResponse queryByAccountId(@RequestParam Long accountId) { adminAuthLogic.checkPermission("sys-menu-details"); var result = service.queryByAccountId(accountId); return success("查询成功", result); } @GetMapping("queryByRoleId") - public RestfulResult queryByRoleId(@RequestParam Long roleId) { + public UnifiedResponse queryByRoleId(@RequestParam Long roleId) { adminAuthLogic.checkPermission("sys-menu-details"); var result = service.queryByRoleId(roleId); return success("查询成功", result); diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RegisterAccountController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RegisterAccountController.java index 07477e0..98bd52b 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RegisterAccountController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RegisterAccountController.java @@ -1,6 +1,6 @@ package xyz.zhouxy.plusone.system.application.web.controller; -import static xyz.zhouxy.plusone.commons.util.RestfulResult.success; +import static xyz.zhouxy.plusone.commons.util.UnifiedResponse.success; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController; import xyz.zhouxy.plusone.system.application.service.RegisterAccountService; import xyz.zhouxy.plusone.system.application.service.command.RegisterAccountCommand; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * 注册账号服务 @@ -29,13 +29,13 @@ public class RegisterAccountController { } @PostMapping - public RestfulResult registerAccount(@RequestBody RegisterAccountCommand command) { + public UnifiedResponse registerAccount(@RequestBody RegisterAccountCommand command) { service.registerAccount(command); return success("注册成功"); } @GetMapping("sendCode") - public RestfulResult sendCode(@RequestParam String principal) { + public UnifiedResponse sendCode(@RequestParam String principal) { service.sendCode(principal); return success("发送成功"); } diff --git a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RoleManagementController.java b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RoleManagementController.java index 5466894..3772f9f 100644 --- a/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RoleManagementController.java +++ b/plusone-system/plusone-system-application/src/main/java/xyz/zhouxy/plusone/system/application/web/controller/RoleManagementController.java @@ -17,7 +17,7 @@ import xyz.zhouxy.plusone.system.application.query.params.RoleQueryParams; import xyz.zhouxy.plusone.system.application.service.RoleManagementService; import xyz.zhouxy.plusone.system.application.service.command.CreateRoleCommand; import xyz.zhouxy.plusone.system.application.service.command.UpdateRoleCommand; -import xyz.zhouxy.plusone.commons.util.RestfulResult; +import xyz.zhouxy.plusone.commons.util.UnifiedResponse; /** * 角色管理服务 @@ -35,44 +35,44 @@ public class RoleManagementController { } @PostMapping - public RestfulResult createRole(@RequestBody @Valid CreateRoleCommand command) { + public UnifiedResponse createRole(@RequestBody @Valid CreateRoleCommand command) { adminAuthLogic.checkPermission("sys-role-create"); service.createRole(command); - return RestfulResult.success(); + return UnifiedResponse.success(); } @PatchMapping - public RestfulResult updateRole(@RequestBody @Valid UpdateRoleCommand command) { + public UnifiedResponse updateRole(@RequestBody @Valid UpdateRoleCommand command) { adminAuthLogic.checkPermission("sys-role-update"); service.updateRole(command); - return RestfulResult.success(); + return UnifiedResponse.success(); } @DeleteMapping("{id}") - public RestfulResult delete(@PathVariable("id") Long id) { + public UnifiedResponse delete(@PathVariable("id") Long id) { adminAuthLogic.checkPermission("sys-role-delete"); service.delete(id); - return RestfulResult.success(); + return UnifiedResponse.success(); } @GetMapping("exists") - public RestfulResult exists(@RequestParam("id") Long id) { + public UnifiedResponse exists(@RequestParam("id") Long id) { adminAuthLogic.checkPermissionOr("sys-role-list", "sys-role-details"); var isExists = service.exists(id); - return RestfulResult.success(isExists ? "存在" : "不存在", isExists); + return UnifiedResponse.success(isExists ? "存在" : "不存在", isExists); } @GetMapping("{id}") - public RestfulResult findById(@PathVariable("id") Long id) { + public UnifiedResponse findById(@PathVariable("id") Long id) { adminAuthLogic.checkPermission("sys-role-details"); var result = service.findById(id); - return RestfulResult.success("查询成功", result); + return UnifiedResponse.success("查询成功", result); } @GetMapping("query") - public RestfulResult query(RoleQueryParams params) { + public UnifiedResponse query(RoleQueryParams params) { adminAuthLogic.checkPermission("sys-role-list"); var result = service.query(params); - return RestfulResult.success("查询成功", result); + return UnifiedResponse.success("查询成功", result); } }