统一异常处理:
统一的异常
public class BusinessException extends RuntimeException{
private int code;
private String msg;
BusinessException(ResultCode resultCode){
this.code=resultCode.getCode();
this.msg=resultCode.getMsg();
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
}
统一的返回:
public class R {
private int code;
private String msg;
public R(int code, String msg) {
this.code = code;
this.msg = msg;
}
public static R of(ResultCode resultCode){
return new R(resultCode.getCode(),resultCode.getMsg());
}
public int getCode