全局异常处理
AjaxResult 返回结果
编写一个类返回状态码code和异常描述message
/**
* @Auther: ARong
* @Description: 处理结果
*/
@Data
public class AjaxResult {
public AjaxResult() {
}
public AjaxResult(int code, String message) {
this.code = code;
this.message = message;
}
private int code;
private String message;
}
GlobalException 全局异常,里边使用内部类定义自定义异常
/**
* @Auther: ARong
* @Description: 全局异常定义
*/
public class GlobalException {
/*
* @Author ARong
* @Description 参数缺少异常
**/
@Data
public static class ArgsLoseException extends RuntimeException{
private int code = 501;
private String message;
public ArgsLoseException(String message)