|
@@ -15,7 +15,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
@ControllerAdvice
|
|
@ControllerAdvice
|
|
public class BaseController {
|
|
public class BaseController {
|
|
-
|
|
|
|
|
|
+
|
|
private final static Logger logger = LoggerFactory.getLogger(BaseController.class);
|
|
private final static Logger logger = LoggerFactory.getLogger(BaseController.class);
|
|
|
|
|
|
public static <T> HttpResponseResult<T> succeed(T object) {
|
|
public static <T> HttpResponseResult<T> succeed(T object) {
|
|
@@ -30,19 +30,19 @@ public class BaseController {
|
|
return getResponseData(true, HttpStatus.OK, obj, "操作成功");
|
|
return getResponseData(true, HttpStatus.OK, obj, "操作成功");
|
|
}
|
|
}
|
|
|
|
|
|
- public static HttpResponseResult<String> warned(String message) {
|
|
|
|
|
|
+ public static <T> HttpResponseResult<T> warned(String message) {
|
|
return failed(HttpStatus.MULTI_STATUS, message);
|
|
return failed(HttpStatus.MULTI_STATUS, message);
|
|
}
|
|
}
|
|
|
|
|
|
- public static HttpResponseResult<String> failed() {
|
|
|
|
|
|
+ public static <T> HttpResponseResult<T> failed() {
|
|
return failed("");
|
|
return failed("");
|
|
}
|
|
}
|
|
|
|
|
|
- public static HttpResponseResult<String> failed(String msg) {
|
|
|
|
|
|
+ public static <T> HttpResponseResult<T> failed(String msg) {
|
|
return failed(HttpStatus.INTERNAL_SERVER_ERROR, msg);
|
|
return failed(HttpStatus.INTERNAL_SERVER_ERROR, msg);
|
|
}
|
|
}
|
|
|
|
|
|
- public static HttpResponseResult<String> failed(HttpStatus statusCode, String msg) {
|
|
|
|
|
|
+ public static <T> HttpResponseResult<T> failed(HttpStatus statusCode, String msg) {
|
|
return getResponseData(false, statusCode, null, msg);
|
|
return getResponseData(false, statusCode, null, msg);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,7 +54,7 @@ public class BaseController {
|
|
obj.setMsg(message);
|
|
obj.setMsg(message);
|
|
return obj;
|
|
return obj;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 处理一般异常
|
|
* 处理一般异常
|
|
*
|
|
*
|
|
@@ -69,10 +69,10 @@ public class BaseController {
|
|
e = ex;
|
|
e = ex;
|
|
}
|
|
}
|
|
logger.error("System Error", ex);
|
|
logger.error("System Error", ex);
|
|
-// return failed(e.getMessage());
|
|
|
|
- if(e instanceof BizException || e instanceof ThirdpartyException){
|
|
|
|
|
|
+ // return failed(e.getMessage());
|
|
|
|
+ if (e instanceof BizException || e instanceof ThirdpartyException) {
|
|
return failed(e.getMessage());
|
|
return failed(e.getMessage());
|
|
- }else if(e instanceof AccessDeniedException){
|
|
|
|
|
|
+ } else if (e instanceof AccessDeniedException) {
|
|
return failed("禁止访问");
|
|
return failed("禁止访问");
|
|
}
|
|
}
|
|
return failed("系统繁忙");
|
|
return failed("系统繁忙");
|