refactor(exception): 重构异常处理逻辑

- 新增基础异常类 ApiException
- 定义错误码枚举 ErrorCode
- 修改原有代码,使用 ApiException 替代 Assert 和 BaseException
- 更新全局异常处理器,支持 ApiException 处理
main-p
shi 2025-02-19 16:41:44 +08:00
parent 73d24986e6
commit 5fce3d77c9
8 changed files with 171 additions and 60 deletions

View File

@ -11,8 +11,10 @@ import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.page.TableDataInfo;
import com.ff.base.enums.ErrorCode;
import com.ff.base.enums.OperationType;
import com.ff.base.enums.TransferType;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.bean.BeanUtils;
@ -133,10 +135,10 @@ public class ApiGameController extends BaseController {
public AjaxResult login(@Validated @RequestBody GameLoginRequest memberCreateApiRequest) {
Game game = gameService.selectGameById(memberCreateApiRequest.getGameId());
Assert.notNull(game, "游戏不存在");
ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode());
GamePlatform gamePlatform = gamePlatformService.selectGamePlatformById(game.getPlatformId());
Assert.notNull(gamePlatform, "游戏平台不存在");
ApiException.notNull(gamePlatform, ErrorCode.PLATFORM_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gamePlatform.getPlatformCode() + Constants.SERVICE);
@ -144,13 +146,13 @@ public class ApiGameController extends BaseController {
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gamePlatform.getPlatformCode(), memberCreateApiRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
GameSecretKey gameSecretKeyLang = gameSecretKeyService.findByPlatformAndSystemLangCode(gamePlatform.getPlatformCode(), memberCreateApiRequest.getLangCode());
Assert.notNull(gameSecretKeyLang, "当前语言不存在");
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
GamesLogin gamesLogin = GamesLogin.builder()
.agentId(gameSecretKey.getCode())
@ -185,11 +187,11 @@ public class ApiGameController extends BaseController {
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gameExchangeBalanceRequest.getPlatformCode(), gameExchangeBalanceRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameExchangeBalanceRequest.getAccount(), gameExchangeBalanceRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
//操作租户额度
boolean isOut = gameExchangeBalanceRequest.getTransferType() == 1;
@ -260,16 +262,15 @@ public class ApiGameController extends BaseController {
IGamesService iGamesService = gamesService.get(gameCreateFreeSpinRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "游戏平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gameCreateFreeSpinRequest.getPlatformCode(), gameCreateFreeSpinRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameCreateFreeSpinRequest.getAccount(), gameCreateFreeSpinRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
CreateFreeSpinRequestDTO createFreeSpinRequestDTO = CreateFreeSpinRequestDTO.builder()
.account(member.getGameAccount())
.currency(gameCreateFreeSpinRequest.getCurrencyCode())
@ -336,11 +337,11 @@ public class ApiGameController extends BaseController {
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gameGetDetailRequest.getPlatformCode(), gameGetDetailRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameGetDetailRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "游戏平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
GameSecretKey gameSecretKeyLang = gameSecretKeyService.findByPlatformAndSystemLangCode(gameGetDetailRequest.getPlatformCode(), gameGetDetailRequest.getLangCode());
Assert.notNull(gameSecretKeyLang, "当前语言不存在");
@ -364,14 +365,14 @@ public class ApiGameController extends BaseController {
@PostMapping("/kick/member")
public AjaxResult kickMember(@Validated @RequestBody GameKickMemeberRequest gameKickMemeberRequest) {
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gameKickMemeberRequest.getPlatformCode(), gameKickMemeberRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameKickMemeberRequest.getAccount(), gameKickMemeberRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameKickMemeberRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "游戏平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
return AjaxResult.success(iGamesService.kickMember(KickMemberRequestDTO.builder()
@ -384,10 +385,10 @@ public class ApiGameController extends BaseController {
@PostMapping("/kick/member/all")
public AjaxResult kickMemberAll(@Validated @RequestBody GameKickMemeberAllRequest gameKickMemeberAllRequest) {
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gameKickMemeberAllRequest.getPlatformCode(), gameKickMemeberAllRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameKickMemeberAllRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "游戏平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
KickMemberAllDTO kickMemberAllDTO = KickMemberAllDTO.builder()
.agentId(gameSecretKey.getCode())
@ -395,7 +396,7 @@ public class ApiGameController extends BaseController {
.build();
if (!ObjectUtils.isEmpty(gameKickMemeberAllRequest.getGameId())) {
Game game = gameService.selectGameById(gameKickMemeberAllRequest.getGameId());
Assert.notNull(game, "游戏不存在");
ApiException.notNull(game, ErrorCode.GAME_NOT_EXIST.getCode());
kickMemberAllDTO.setGameId(game.getGameCode());
}
@ -446,10 +447,10 @@ public class ApiGameController extends BaseController {
@PostMapping("/cancel/free/spin")
public AjaxResult cancelFreeSpin(@Validated @RequestBody GameCancelFreeSpinRequest gameGetFreeSpinDashflowRequest) {
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(gameGetFreeSpinDashflowRequest.getPlatformCode(), gameGetFreeSpinDashflowRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
IGamesService iGamesService = gamesService.get(gameGetFreeSpinDashflowRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "游戏平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
Boolean cancelFreeSpin = iGamesService.cancelFreeSpin(CancelFreeSpinRequestDTO.builder()
.agentId(gameSecretKey.getCode())
@ -470,7 +471,7 @@ public class ApiGameController extends BaseController {
TenantSecretKey tenantSecretKey = keyConfig.get();
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(gameExchangeBalanceAllRequest.getAccount(), gameExchangeBalanceAllRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
List<GameSecretKey> gameSecretKeys = gameSecretKeyService.selectGameSecretKeyList(GameSecretKey.builder().systemCode(gameExchangeBalanceAllRequest.getCurrencyCode()).build());

View File

@ -11,6 +11,8 @@ import com.ff.api.response.MemberInfoResponse;
import com.ff.base.constant.Constants;
import com.ff.base.core.controller.BaseController;
import com.ff.base.core.domain.AjaxResult;
import com.ff.base.enums.ErrorCode;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.manager.AsyncManager;
import com.ff.base.utils.StringUtils;
@ -90,12 +92,11 @@ public class ApiMemberController extends BaseController {
public AjaxResult createMember(@Validated @RequestBody MemberCreateApiRequest memberCreateApiRequest) {
IGamesService iGamesService = gamesService.get(memberCreateApiRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(memberCreateApiRequest.getPlatformCode(), memberCreateApiRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
String gameAccount = StringUtils.addSuffix(memberCreateApiRequest.getAccount(), memberCreateApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn());
//向第三方注册账号
@ -134,15 +135,15 @@ public class ApiMemberController extends BaseController {
@PostMapping("/info")
public AjaxResult getMemberInfo(@Validated @RequestBody MemberInfoApiRequest memberInfoApiRequest) {
IGamesService iGamesService = gamesService.get(memberInfoApiRequest.getPlatformCode() + Constants.SERVICE);
Assert.notNull(iGamesService, "平台不存在");
ApiException.notNull(iGamesService, ErrorCode.PLATFORM_NOT_EXIST.getCode());
TenantSecretKey tenantSecretKey = keyConfig.get();
GameSecretKey gameSecretKey = gameSecretKeyService.findSecretKeyByPlatformAndSystemCode(memberInfoApiRequest.getPlatformCode(), memberInfoApiRequest.getCurrencyCode());
Assert.notNull(gameSecretKey, "货币游戏平台不存在");
ApiException.notNull(gameSecretKey, ErrorCode.CURRENCY_NOT_EXIST.getCode());
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberInfoApiRequest.getAccount(), memberInfoApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
//向第三方查询账号
MemberInfoRequestDTO gamesBaseRequestDTO = MemberInfoRequestDTO.builder()
@ -168,7 +169,7 @@ public class ApiMemberController extends BaseController {
TenantSecretKey tenantSecretKey = keyConfig.get();
Member member = memberService.selectMemberByGameAccount(StringUtils.addSuffix(memberInfoAllApiRequest.getAccount(), memberInfoAllApiRequest.getCurrencyCode() + tenantSecretKey.getTenantSn()));
Assert.notNull(member, "会员不存在");
ApiException.notNull(member, ErrorCode.ACCOUNT_NOT_EXIST.getCode());
List<GameSecretKey> gameSecretKeys = gameSecretKeyService.selectGameSecretKeyList(GameSecretKey.builder().systemCode(memberInfoAllApiRequest.getCurrencyCode()).build());

View File

@ -6,6 +6,7 @@ import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
import com.ff.base.core.redis.RedisCache;
import com.ff.base.enums.*;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils;
@ -140,12 +141,15 @@ public class GamesJILIServiceImpl implements IGamesService {
createMemberRequestDTO.setQuery(query);
String key = this.getKey(createMemberRequestDTO);
JILICreateMemberResponseDTO createMemberResponseDTO = jiliClient.createMember(query + "&Key=" + key);
Boolean isSuccess = this.getIsSuccess(createMemberResponseDTO.getErrorCode());
if (!isSuccess) {
throw new BaseException(createMemberResponseDTO.getMessage());
int errorCode = createMemberResponseDTO.getErrorCode();
if (0 == errorCode){
return Boolean.TRUE;
}
if (101 == errorCode){
throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode());
}
//判断是否获取成功
return isSuccess;
return Boolean.FALSE;
}

View File

@ -5,9 +5,11 @@ import com.alibaba.fastjson2.JSON;
import com.ff.base.constant.CacheConstants;
import com.ff.base.constant.Constants;
import com.ff.base.core.redis.RedisCache;
import com.ff.base.enums.ErrorCode;
import com.ff.base.enums.GamePlatforms;
import com.ff.base.enums.GameStatus;
import com.ff.base.enums.XKGameType;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.system.service.ISysConfigService;
import com.ff.base.utils.DateUtils;
@ -142,12 +144,15 @@ public class GamesXKServiceImpl implements IGamesService {
String key = this.getKey(createMemberRequestDTO);
params.put("key", key);
XKCreateMemberResponseDTO xkCreateMemberResponseDTO = xkClient.createMember(params);
Boolean isSuccess = this.getIsSuccess(xkCreateMemberResponseDTO.getCode());
if (!isSuccess) {
throw new BaseException(xkCreateMemberResponseDTO.getMsg());
int errorCode = xkCreateMemberResponseDTO.getCode();
if (0 == errorCode){
return Boolean.TRUE;
}
if (101 == errorCode){
throw new ApiException(ErrorCode.GAME_ACCOUNT_CREATION_FAILED.getCode());
}
//判断是否获取成功
return isSuccess;
return Boolean.FALSE;
}

View File

@ -0,0 +1,48 @@
package com.ff.base.enums;
import lombok.Getter;
import java.util.Optional;
import java.util.stream.Stream;
/**
*
*
* @author shi
* @date 2025/02/19
*/
@Getter
public enum ErrorCode {
ERROR(500, "系统业务异常"),
GAME_ACCOUNT_CREATION_FAILED(1001, "当前游戏账号已存在"),
ACCOUNT_NOT_EXIST(1002, "当前游戏账号不存在"),
PLATFORM_NOT_EXIST(1003, "游戏平台不存在"),
CURRENCY_NOT_EXIST(1004, "游戏平台不支持的货币"),
GAME_NOT_EXIST(1005, "游戏不存在"),
;
// 获取错误码
private final int code;
// 获取错误信息
private final String message;
// 构造函数
ErrorCode(int code, String message) {
this.code = code;
this.message = message;
}
/**
*
*
* @param code
* @return {@link String }
*/
public static String findByCode(Integer code) {
Optional<String> system = Stream.of(ErrorCode.values())
.filter(errorCode -> errorCode.getCode() == code)
.map(ErrorCode::getMessage)
.findFirst();
return system.orElse(null);
}
}

View File

@ -0,0 +1,55 @@
package com.ff.base.exception.base;
import com.ff.base.enums.ErrorCode;
import com.ff.base.utils.MessageUtils;
import com.ff.base.utils.StringUtils;
import lombok.Getter;
import org.springframework.lang.Nullable;
/**
*
*
* @author ff
*/
@Getter
public class ApiException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
*
*/
private Integer code;
/**
*
*/
private String message;
public ApiException(Integer code, String message) {
this.code = code;
this.message = message;
}
public ApiException(Integer code) {
this.code = code;
this.message = ErrorCode.findByCode(code);
}
@Override
public String getMessage() {
return message;
}
/**
*
*
* @param object
* @param code
*/
public static void notNull(@Nullable Object object, Integer code) {
if (object == null) {
throw new ApiException(code);
}
}
}

View File

@ -5,6 +5,8 @@ import com.ff.base.core.domain.AjaxResult;
import com.ff.base.core.text.Convert;
import com.ff.base.exception.DemoModeException;
import com.ff.base.exception.ServiceException;
import com.ff.base.exception.base.ApiException;
import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.StringUtils;
import com.ff.base.utils.html.EscapeUtil;
import org.slf4j.Logger;
@ -26,16 +28,14 @@ import javax.servlet.http.HttpServletRequest;
* @author ff
*/
@RestControllerAdvice
public class GlobalExceptionHandler
{
public class GlobalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
*
*/
@ExceptionHandler(AccessDeniedException.class)
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
{
public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
@ -46,8 +46,7 @@ public class GlobalExceptionHandler
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
HttpServletRequest request)
{
HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
return AjaxResult.error(e.getMessage());
@ -57,8 +56,7 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(ServiceException.class)
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request)
{
public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
log.error(e.getMessage(), e);
Integer code = e.getCode();
return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
@ -68,8 +66,7 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(MissingPathVariableException.class)
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request)
{
public AjaxResult handleMissingPathVariableException(MissingPathVariableException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求路径中缺少必需的路径变量'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(String.format("请求路径中缺少必需的路径变量[%s]", e.getVariableName()));
@ -79,12 +76,10 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request)
{
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
String value = Convert.toStr(e.getValue());
if (StringUtils.isNotEmpty(value))
{
if (StringUtils.isNotEmpty(value)) {
value = EscapeUtil.clean(value);
}
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
@ -95,19 +90,24 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(RuntimeException.class)
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
{
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
@ExceptionHandler(ApiException.class)
public AjaxResult handleBaseException(ApiException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getCode(), e.getMessage());
}
/**
*
*/
@ExceptionHandler(Exception.class)
public AjaxResult handleException(Exception e, HttpServletRequest request)
{
public AjaxResult handleException(Exception e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
@ -117,8 +117,7 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(BindException.class)
public AjaxResult handleBindException(BindException e)
{
public AjaxResult handleBindException(BindException e) {
log.error(e.getMessage(), e);
String message = e.getAllErrors().get(0).getDefaultMessage();
return AjaxResult.error(message);
@ -128,8 +127,7 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
{
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
log.error(e.getMessage(), e);
String message = e.getBindingResult().getFieldError().getDefaultMessage();
return AjaxResult.error(message);
@ -139,8 +137,7 @@ public class GlobalExceptionHandler
*
*/
@ExceptionHandler(DemoModeException.class)
public AjaxResult handleDemoModeException(DemoModeException e)
{
public AjaxResult handleDemoModeException(DemoModeException e) {
return AjaxResult.error("演示模式,不允许操作");
}
}