使用 UnifiedResponse 替代 RestfulResult
parent
208d7c93c9
commit
b25d7589c2
|
@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
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,
|
DataAccessException.class,
|
||||||
MethodArgumentNotValidException.class
|
MethodArgumentNotValidException.class
|
||||||
})
|
})
|
||||||
public ResponseEntity<RestfulResult> handleException(Exception e) {
|
public ResponseEntity<UnifiedResponse> handleException(Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return buildExceptionResponse(e);
|
return buildExceptionResponse(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
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;
|
import xyz.zhouxy.plusone.exception.SysException;
|
||||||
|
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
|
@ -21,9 +21,9 @@ public class SysExceptionHandler extends BaseExceptionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler({ SysException.class })
|
@ExceptionHandler({ SysException.class })
|
||||||
public ResponseEntity<RestfulResult> handleException(@Nonnull Exception e) {
|
public ResponseEntity<UnifiedResponse> handleException(@Nonnull Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
HttpStatus httpStatus = getHttpStatus(e);
|
HttpStatus httpStatus = getHttpStatus(e);
|
||||||
return new ResponseEntity<>(RestfulResult.error(getErrorCode(e), "系统错误"), httpStatus);
|
return new ResponseEntity<>(UnifiedResponse.error(getErrorCode(e), "系统错误"), httpStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,26 @@
|
||||||
package xyz.zhouxy.plusone.system.application.common.exception.handler;
|
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.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
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;
|
import xyz.zhouxy.plusone.system.application.common.exception.AccountLoginException;
|
||||||
|
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
public class AccountLoginExceptionHandler extends BaseExceptionHandler {
|
public class AccountLoginExceptionHandler extends BaseExceptionHandler {
|
||||||
|
|
||||||
public AccountLoginExceptionHandler(ExceptionInfoHolder exceptionInfoHolder) {
|
public AccountLoginExceptionHandler(@Nonnull ExceptionInfoHolder exceptionInfoHolder) {
|
||||||
super(exceptionInfoHolder);
|
super(exceptionInfoHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler({ AccountLoginException.class })
|
@ExceptionHandler({ AccountLoginException.class })
|
||||||
public ResponseEntity<RestfulResult> handleException(Exception e) {
|
public ResponseEntity<UnifiedResponse> handleException(Exception e) {
|
||||||
return buildExceptionResponse(e);
|
return buildExceptionResponse(Objects.requireNonNull(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import cn.dev33.satoken.exception.SaTokenException;
|
||||||
import cn.dev33.satoken.exception.SameTokenInvalidException;
|
import cn.dev33.satoken.exception.SameTokenInvalidException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
import xyz.zhouxy.plusone.commons.exception.handler.BaseExceptionHandler;
|
||||||
import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
import xyz.zhouxy.plusone.commons.util.UnifiedResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sa-Token 异常处理器
|
* Sa-Token 异常处理器
|
||||||
|
@ -52,7 +52,7 @@ public class SaTokenExceptionHandler extends BaseExceptionHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ExceptionHandler(SaTokenException.class)
|
@ExceptionHandler(SaTokenException.class)
|
||||||
public ResponseEntity<RestfulResult> handleSaTokenException(SaTokenException e) {
|
public ResponseEntity<UnifiedResponse> handleSaTokenException(SaTokenException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return buildExceptionResponse(e);
|
return buildExceptionResponse(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.AccountContextService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordCommand;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordWithoutLoginCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.ChangePasswordWithoutLoginCommand;
|
||||||
|
@ -28,34 +28,34 @@ public class AccountContextController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("info")
|
@GetMapping("info")
|
||||||
public RestfulResult getAccountInfo() {
|
public UnifiedResponse getAccountInfo() {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
var result = service.getAccountInfo();
|
var result = service.getAccountInfo();
|
||||||
return RestfulResult.success("查询成功", result);
|
return UnifiedResponse.success("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("logout")
|
@GetMapping("logout")
|
||||||
public RestfulResult logout() {
|
public UnifiedResponse logout() {
|
||||||
service.logout();
|
service.logout();
|
||||||
return RestfulResult.success("注销成功");
|
return UnifiedResponse.success("注销成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("menus")
|
@GetMapping("menus")
|
||||||
public RestfulResult getMenuTree() {
|
public UnifiedResponse getMenuTree() {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
var result = service.getMenuTree();
|
var result = service.getMenuTree();
|
||||||
return RestfulResult.success("查询成功", result);
|
return UnifiedResponse.success("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("changePassword")
|
@PostMapping("changePassword")
|
||||||
public RestfulResult changePassword(ChangePasswordCommand command) {
|
public UnifiedResponse changePassword(ChangePasswordCommand command) {
|
||||||
service.changePassword(command);
|
service.changePassword(command);
|
||||||
return RestfulResult.success("修改成功,请重新登录。");
|
return UnifiedResponse.success("修改成功,请重新登录。");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("changePasswordWithoutLogin")
|
@PostMapping("changePasswordWithoutLogin")
|
||||||
public RestfulResult changePasswordWithoutLogin(ChangePasswordWithoutLoginCommand command) {
|
public UnifiedResponse changePasswordWithoutLogin(ChangePasswordWithoutLoginCommand command) {
|
||||||
service.changePasswordWithoutLogin(command);
|
service.changePasswordWithoutLogin(command);
|
||||||
return RestfulResult.success("修改成功,请重新登录。");
|
return UnifiedResponse.success("修改成功,请重新登录。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package xyz.zhouxy.plusone.system.application.web.controller;
|
package xyz.zhouxy.plusone.system.application.web.controller;
|
||||||
|
|
||||||
import static xyz.zhouxy.plusone.system.constant.AuthLogic.adminAuthLogic;
|
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;
|
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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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.query.params.AccountQueryParams;
|
||||||
import xyz.zhouxy.plusone.system.application.service.AccountManagementService;
|
import xyz.zhouxy.plusone.system.application.service.AccountManagementService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.CreateAccountCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.CreateAccountCommand;
|
||||||
|
@ -38,7 +38,7 @@ public class AccountManagementController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public RestfulResult createAccount(@RequestBody @Valid CreateAccountCommand command) {
|
public UnifiedResponse createAccount(@RequestBody @Valid CreateAccountCommand command) {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
adminAuthLogic.checkPermission("sys-account-create");
|
adminAuthLogic.checkPermission("sys-account-create");
|
||||||
service.createAccount(command);
|
service.createAccount(command);
|
||||||
|
@ -46,7 +46,7 @@ public class AccountManagementController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
public RestfulResult deleteAccounts(@RequestBody List<Long> ids) {
|
public UnifiedResponse deleteAccounts(@RequestBody List<Long> ids) {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
adminAuthLogic.checkPermission("sys-account-delete");
|
adminAuthLogic.checkPermission("sys-account-delete");
|
||||||
service.deleteAccounts(ids);
|
service.deleteAccounts(ids);
|
||||||
|
@ -54,7 +54,7 @@ public class AccountManagementController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("{id}")
|
@PatchMapping("{id}")
|
||||||
public RestfulResult updateAccountInfo(
|
public UnifiedResponse updateAccountInfo(
|
||||||
@PathVariable("id") Long id,
|
@PathVariable("id") Long id,
|
||||||
@RequestBody @Valid UpdateAccountCommand command) {
|
@RequestBody @Valid UpdateAccountCommand command) {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
|
@ -64,7 +64,7 @@ public class AccountManagementController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("query")
|
@GetMapping("query")
|
||||||
public RestfulResult queryAccountOverviewList(AccountQueryParams queryParams) {
|
public UnifiedResponse queryAccountOverviewList(AccountQueryParams queryParams) {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
adminAuthLogic.checkPermission("sys-account-list");
|
adminAuthLogic.checkPermission("sys-account-list");
|
||||||
var accountOverviewList = service.queryAccountOverviewList(queryParams);
|
var accountOverviewList = service.queryAccountOverviewList(queryParams);
|
||||||
|
@ -72,7 +72,7 @@ public class AccountManagementController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{accountId}")
|
@GetMapping("{accountId}")
|
||||||
public RestfulResult queryAccountDetails(@PathVariable("accountId") Long accountId) {
|
public UnifiedResponse queryAccountDetails(@PathVariable("accountId") Long accountId) {
|
||||||
adminAuthLogic.checkLogin();
|
adminAuthLogic.checkLogin();
|
||||||
adminAuthLogic.checkPermission("sys-account-details");
|
adminAuthLogic.checkPermission("sys-account-details");
|
||||||
var accountDetails = service.queryAccountDetails(accountId);
|
var accountDetails = service.queryAccountDetails(accountId);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package xyz.zhouxy.plusone.system.application.web.controller;
|
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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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.AdminLoginService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.LoginByOtpCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.LoginByOtpCommand;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.LoginByPasswordCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.LoginByPasswordCommand;
|
||||||
import xyz.zhouxy.plusone.commons.util.RestfulResult;
|
import xyz.zhouxy.plusone.commons.util.UnifiedResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin 账号登录
|
* Admin 账号登录
|
||||||
|
@ -30,19 +30,19 @@ public class AdminLoginController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("byPassword")
|
@PostMapping("byPassword")
|
||||||
public RestfulResult loginByPassword(@RequestBody LoginByPasswordCommand command) {
|
public UnifiedResponse loginByPassword(@RequestBody LoginByPasswordCommand command) {
|
||||||
var loginInfo = service.loginByPassword(command);
|
var loginInfo = service.loginByPassword(command);
|
||||||
return success("登录成功", loginInfo);
|
return success("登录成功", loginInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("byOtp")
|
@PostMapping("byOtp")
|
||||||
public RestfulResult loginByOtp(@RequestBody LoginByOtpCommand command) {
|
public UnifiedResponse loginByOtp(@RequestBody LoginByOtpCommand command) {
|
||||||
var loginInfo = service.loginByOtp(command);
|
var loginInfo = service.loginByOtp(command);
|
||||||
return success("登录成功", loginInfo);
|
return success("登录成功", loginInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("sendOtp")
|
@GetMapping("sendOtp")
|
||||||
public RestfulResult sendOtp(@RequestParam String principal) {
|
public UnifiedResponse sendOtp(@RequestParam String principal) {
|
||||||
service.sendOtp(principal);
|
service.sendOtp(principal);
|
||||||
return success("发送成功");
|
return success("发送成功");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package xyz.zhouxy.plusone.system.application.web.controller;
|
package xyz.zhouxy.plusone.system.application.web.controller;
|
||||||
|
|
||||||
import static xyz.zhouxy.plusone.system.constant.AuthLogic.adminAuthLogic;
|
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;
|
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.DictManagementService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.CreateDictCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.CreateDictCommand;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.UpdateDictCommand;
|
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
|
@PostMapping
|
||||||
public RestfulResult createDict(@RequestBody @Valid CreateDictCommand command) {
|
public UnifiedResponse createDict(@RequestBody @Valid CreateDictCommand command) {
|
||||||
adminAuthLogic.checkPermission("sys-dict-create");
|
adminAuthLogic.checkPermission("sys-dict-create");
|
||||||
service.createDict(command);
|
service.createDict(command);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
public RestfulResult deleteDicts(@RequestBody List<Long> ids) {
|
public UnifiedResponse deleteDicts(@RequestBody List<Long> ids) {
|
||||||
adminAuthLogic.checkPermission("sys-dict-delete");
|
adminAuthLogic.checkPermission("sys-dict-delete");
|
||||||
service.deleteDicts(ids);
|
service.deleteDicts(ids);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping("{id}")
|
@PatchMapping("{id}")
|
||||||
public RestfulResult updateDict(
|
public UnifiedResponse updateDict(
|
||||||
@PathVariable("id") Long id,
|
@PathVariable("id") Long id,
|
||||||
@RequestBody @Valid UpdateDictCommand command) {
|
@RequestBody @Valid UpdateDictCommand command) {
|
||||||
adminAuthLogic.checkPermission("sys-dict-update");
|
adminAuthLogic.checkPermission("sys-dict-update");
|
||||||
|
@ -61,21 +61,21 @@ public class DictManagementController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{dictId}")
|
@GetMapping("{dictId}")
|
||||||
public RestfulResult findDictDetails(@PathVariable("dictId") Long dictId) {
|
public UnifiedResponse findDictDetails(@PathVariable("dictId") Long dictId) {
|
||||||
adminAuthLogic.checkPermission("sys-dict-details");
|
adminAuthLogic.checkPermission("sys-dict-details");
|
||||||
var dictDetails = service.findDictDetails(dictId);
|
var dictDetails = service.findDictDetails(dictId);
|
||||||
return success("查询成功", dictDetails);
|
return success("查询成功", dictDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("all")
|
@GetMapping("all")
|
||||||
public RestfulResult loadAllDicts() {
|
public UnifiedResponse loadAllDicts() {
|
||||||
adminAuthLogic.checkPermissionAnd("sys-dict-list", "sys-dict-details");
|
adminAuthLogic.checkPermissionAnd("sys-dict-list", "sys-dict-details");
|
||||||
var dicts = service.loadAllDicts();
|
var dicts = service.loadAllDicts();
|
||||||
return success("查询成功", dicts);
|
return success("查询成功", dicts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("query")
|
@GetMapping("query")
|
||||||
public RestfulResult queryDictOverviewList(@Valid DictQueryParams queryParams) {
|
public UnifiedResponse queryDictOverviewList(@Valid DictQueryParams queryParams) {
|
||||||
adminAuthLogic.checkPermission("sys-dict-list");
|
adminAuthLogic.checkPermission("sys-dict-list");
|
||||||
var dicts = service.queryDictOverviewList(queryParams);
|
var dicts = service.queryDictOverviewList(queryParams);
|
||||||
return success("查询成功", dicts);
|
return success("查询成功", dicts);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package xyz.zhouxy.plusone.system.application.web.controller;
|
package xyz.zhouxy.plusone.system.application.web.controller;
|
||||||
|
|
||||||
import static xyz.zhouxy.plusone.system.constant.AuthLogic.adminAuthLogic;
|
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;
|
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.MenuManagementService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.CreateMenuCommand;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.UpdateMenuCommand;
|
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 ====================
|
// ==================== create ====================
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public RestfulResult createMenu(@RequestBody @Valid CreateMenuCommand command) {
|
public UnifiedResponse createMenu(@RequestBody @Valid CreateMenuCommand command) {
|
||||||
adminAuthLogic.checkPermission("sys-menu-create");
|
adminAuthLogic.checkPermission("sys-menu-create");
|
||||||
service.createMenu(command);
|
service.createMenu(command);
|
||||||
return success();
|
return success();
|
||||||
|
@ -45,7 +45,7 @@ public class MenuManagementController {
|
||||||
|
|
||||||
// ==================== delete ====================
|
// ==================== delete ====================
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
public RestfulResult deleteMenu(@PathVariable("id") Long id) {
|
public UnifiedResponse deleteMenu(@PathVariable("id") Long id) {
|
||||||
adminAuthLogic.checkPermission("sys-menu-delete");
|
adminAuthLogic.checkPermission("sys-menu-delete");
|
||||||
service.deleteMenu(id);
|
service.deleteMenu(id);
|
||||||
return success();
|
return success();
|
||||||
|
@ -53,7 +53,7 @@ public class MenuManagementController {
|
||||||
|
|
||||||
// ==================== update ====================
|
// ==================== update ====================
|
||||||
@PatchMapping("{id}")
|
@PatchMapping("{id}")
|
||||||
public RestfulResult updateMenu(
|
public UnifiedResponse updateMenu(
|
||||||
@PathVariable("id") Long id,
|
@PathVariable("id") Long id,
|
||||||
@RequestBody @Valid UpdateMenuCommand command) {
|
@RequestBody @Valid UpdateMenuCommand command) {
|
||||||
adminAuthLogic.checkPermission("sys-menu-update");
|
adminAuthLogic.checkPermission("sys-menu-update");
|
||||||
|
@ -63,21 +63,21 @@ public class MenuManagementController {
|
||||||
|
|
||||||
// ==================== query ====================
|
// ==================== query ====================
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
public RestfulResult findById(@PathVariable("id") Long id) {
|
public UnifiedResponse findById(@PathVariable("id") Long id) {
|
||||||
adminAuthLogic.checkPermission("sys-menu-details");
|
adminAuthLogic.checkPermission("sys-menu-details");
|
||||||
var result = service.findById(id);
|
var result = service.findById(id);
|
||||||
return RestfulResult.success("查询成功", result);
|
return UnifiedResponse.success("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("queryByAccountId")
|
@GetMapping("queryByAccountId")
|
||||||
public RestfulResult queryByAccountId(@RequestParam Long accountId) {
|
public UnifiedResponse queryByAccountId(@RequestParam Long accountId) {
|
||||||
adminAuthLogic.checkPermission("sys-menu-details");
|
adminAuthLogic.checkPermission("sys-menu-details");
|
||||||
var result = service.queryByAccountId(accountId);
|
var result = service.queryByAccountId(accountId);
|
||||||
return success("查询成功", result);
|
return success("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("queryByRoleId")
|
@GetMapping("queryByRoleId")
|
||||||
public RestfulResult queryByRoleId(@RequestParam Long roleId) {
|
public UnifiedResponse queryByRoleId(@RequestParam Long roleId) {
|
||||||
adminAuthLogic.checkPermission("sys-menu-details");
|
adminAuthLogic.checkPermission("sys-menu-details");
|
||||||
var result = service.queryByRoleId(roleId);
|
var result = service.queryByRoleId(roleId);
|
||||||
return success("查询成功", result);
|
return success("查询成功", result);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package xyz.zhouxy.plusone.system.application.web.controller;
|
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.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
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.RegisterAccountService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.RegisterAccountCommand;
|
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
|
@PostMapping
|
||||||
public RestfulResult registerAccount(@RequestBody RegisterAccountCommand command) {
|
public UnifiedResponse registerAccount(@RequestBody RegisterAccountCommand command) {
|
||||||
service.registerAccount(command);
|
service.registerAccount(command);
|
||||||
return success("注册成功");
|
return success("注册成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("sendCode")
|
@GetMapping("sendCode")
|
||||||
public RestfulResult sendCode(@RequestParam String principal) {
|
public UnifiedResponse sendCode(@RequestParam String principal) {
|
||||||
service.sendCode(principal);
|
service.sendCode(principal);
|
||||||
return success("发送成功");
|
return success("发送成功");
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.RoleManagementService;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.CreateRoleCommand;
|
import xyz.zhouxy.plusone.system.application.service.command.CreateRoleCommand;
|
||||||
import xyz.zhouxy.plusone.system.application.service.command.UpdateRoleCommand;
|
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
|
@PostMapping
|
||||||
public RestfulResult createRole(@RequestBody @Valid CreateRoleCommand command) {
|
public UnifiedResponse createRole(@RequestBody @Valid CreateRoleCommand command) {
|
||||||
adminAuthLogic.checkPermission("sys-role-create");
|
adminAuthLogic.checkPermission("sys-role-create");
|
||||||
service.createRole(command);
|
service.createRole(command);
|
||||||
return RestfulResult.success();
|
return UnifiedResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PatchMapping
|
@PatchMapping
|
||||||
public RestfulResult updateRole(@RequestBody @Valid UpdateRoleCommand command) {
|
public UnifiedResponse updateRole(@RequestBody @Valid UpdateRoleCommand command) {
|
||||||
adminAuthLogic.checkPermission("sys-role-update");
|
adminAuthLogic.checkPermission("sys-role-update");
|
||||||
service.updateRole(command);
|
service.updateRole(command);
|
||||||
return RestfulResult.success();
|
return UnifiedResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
public RestfulResult delete(@PathVariable("id") Long id) {
|
public UnifiedResponse delete(@PathVariable("id") Long id) {
|
||||||
adminAuthLogic.checkPermission("sys-role-delete");
|
adminAuthLogic.checkPermission("sys-role-delete");
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
return RestfulResult.success();
|
return UnifiedResponse.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("exists")
|
@GetMapping("exists")
|
||||||
public RestfulResult exists(@RequestParam("id") Long id) {
|
public UnifiedResponse exists(@RequestParam("id") Long id) {
|
||||||
adminAuthLogic.checkPermissionOr("sys-role-list", "sys-role-details");
|
adminAuthLogic.checkPermissionOr("sys-role-list", "sys-role-details");
|
||||||
var isExists = service.exists(id);
|
var isExists = service.exists(id);
|
||||||
return RestfulResult.success(isExists ? "存在" : "不存在", isExists);
|
return UnifiedResponse.success(isExists ? "存在" : "不存在", isExists);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
public RestfulResult findById(@PathVariable("id") Long id) {
|
public UnifiedResponse findById(@PathVariable("id") Long id) {
|
||||||
adminAuthLogic.checkPermission("sys-role-details");
|
adminAuthLogic.checkPermission("sys-role-details");
|
||||||
var result = service.findById(id);
|
var result = service.findById(id);
|
||||||
return RestfulResult.success("查询成功", result);
|
return UnifiedResponse.success("查询成功", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("query")
|
@GetMapping("query")
|
||||||
public RestfulResult query(RoleQueryParams params) {
|
public UnifiedResponse query(RoleQueryParams params) {
|
||||||
adminAuthLogic.checkPermission("sys-role-list");
|
adminAuthLogic.checkPermission("sys-role-list");
|
||||||
var result = service.query(params);
|
var result = service.query(params);
|
||||||
return RestfulResult.success("查询成功", result);
|
return UnifiedResponse.success("查询成功", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue