|
@ -4,6 +4,8 @@ package com.yihu.jw.restmodel.web.endpoint;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.yihu.jw.entity.base.dict.BaseExceptionDictDO;
|
|
|
|
import com.yihu.jw.restmodel.exception.dao.BaseExceptionDictDao;
|
|
import com.yihu.jw.restmodel.web.*;
|
|
import com.yihu.jw.restmodel.web.*;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -34,6 +36,8 @@ public abstract class EnvelopRestEndpoint extends Exception {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
protected ObjectMapper objectMapper;
|
|
protected ObjectMapper objectMapper;
|
|
|
|
@Autowired
|
|
|
|
protected BaseExceptionDictDao baseExceptionDictDao;
|
|
|
|
|
|
protected Envelop success() {
|
|
protected Envelop success() {
|
|
return success("success");
|
|
return success("success");
|
|
@ -199,61 +203,53 @@ public abstract class EnvelopRestEndpoint extends Exception {
|
|
}
|
|
}
|
|
|
|
|
|
protected Envelop failedException(Exception e){
|
|
protected Envelop failedException(Exception e){
|
|
if (e.getClass().equals(DataAccessException.class))
|
|
|
|
{
|
|
|
|
|
|
BaseExceptionDictDO baseExceptionDictDO =baseExceptionDictDao.findByExceptionInfo(DataAccessException.class.toString());
|
|
|
|
if (baseExceptionDictDO!=null){
|
|
|
|
e.printStackTrace();
|
|
|
|
return failed(baseExceptionDictDO.getRemindContent(),Integer.parseInt(baseExceptionDictDO.getCode()));
|
|
|
|
}
|
|
|
|
if (e.getClass().equals(DataAccessException.class)) {
|
|
e.printStackTrace();//数据库操作失败
|
|
e.printStackTrace();//数据库操作失败
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().toString().equals(
|
|
} else if (e.getClass().toString().equals(
|
|
NullPointerException.class.toString()))
|
|
|
|
{
|
|
|
|
|
|
NullPointerException.class.toString())) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
//调用了未经初始化的对象或者是不存在的对象!
|
|
//调用了未经初始化的对象或者是不存在的对象!
|
|
return failed("空指针",170004);
|
|
return failed("空指针",170004);
|
|
} else if (e.getClass().equals(IOException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(IOException.class)) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
//IO异常!
|
|
//IO异常!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(ClassNotFoundException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(ClassNotFoundException.class)) {
|
|
e.printStackTrace();//指定的类不存在!
|
|
e.printStackTrace();//指定的类不存在!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(ArithmeticException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(ArithmeticException.class)) {
|
|
e.printStackTrace();//数学运算异常!
|
|
e.printStackTrace();//数学运算异常!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(ArrayIndexOutOfBoundsException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(ArrayIndexOutOfBoundsException.class)) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
//数组下标越界!
|
|
//数组下标越界!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(IllegalArgumentException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(IllegalArgumentException.class)) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
//方法的参数错误!
|
|
//方法的参数错误!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(ClassCastException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(ClassCastException.class)) {
|
|
e.printStackTrace();//类型强制转换错误!
|
|
e.printStackTrace();//类型强制转换错误!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(SecurityException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(SecurityException.class)) {
|
|
e.printStackTrace();//违背安全原则异常!
|
|
e.printStackTrace();//违背安全原则异常!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(SQLException.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(SQLException.class)) {
|
|
e.printStackTrace();//操作数据库异常!
|
|
e.printStackTrace();//操作数据库异常!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(NoSuchMethodError.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(NoSuchMethodError.class)) {
|
|
e.printStackTrace();//方法末找到异常!
|
|
e.printStackTrace();//方法末找到异常!
|
|
return null;
|
|
return null;
|
|
} else if (e.getClass().equals(InternalError.class))
|
|
|
|
{
|
|
|
|
|
|
} else if (e.getClass().equals(InternalError.class)) {
|
|
e.printStackTrace();//Java虚拟机发生了内部错误
|
|
e.printStackTrace();//Java虚拟机发生了内部错误
|
|
return null;
|
|
return null;
|
|
} else
|
|
|
|
{
|
|
|
|
|
|
} else {
|
|
e.printStackTrace();//程序内部错误,操作失败!
|
|
e.printStackTrace();//程序内部错误,操作失败!
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|