|
@@ -1,14 +1,11 @@
|
|
|
package com.yonge.cooleshow.common.controller;
|
|
|
|
|
|
-import java.net.URLEncoder;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-import javax.crypto.Mac;
|
|
|
-import javax.crypto.spec.SecretKeySpec;
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
-
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.toolset.base.exception.BizException;
|
|
|
+import com.yonge.toolset.base.exception.ThirdpartyException;
|
|
|
+import com.yonge.toolset.utils.http.HttpUtil;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
@@ -23,12 +20,13 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
|
|
|
import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
-import com.yonge.toolset.base.exception.BizException;
|
|
|
-import com.yonge.toolset.base.exception.ThirdpartyException;
|
|
|
-import com.yonge.toolset.utils.http.HttpUtil;
|
|
|
+import javax.crypto.Mac;
|
|
|
+import javax.crypto.spec.SecretKeySpec;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@ControllerAdvice
|
|
|
public class BaseController {
|
|
@@ -111,6 +109,14 @@ public class BaseController {
|
|
|
if (e.getMessage().equals("205")) {
|
|
|
return failed(HttpStatus.RESET_CONTENT, e.getMessage());
|
|
|
}
|
|
|
+
|
|
|
+ // 自定义错误码
|
|
|
+ if (e instanceof BizException) {
|
|
|
+ BizException bizException = (BizException) e;
|
|
|
+ return getResponseData(false, bizException.getCode(), null, bizException.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 默认返回错误码
|
|
|
return failed(e.getMessage());
|
|
|
} else if (e instanceof AccessDeniedException) {
|
|
|
return failed("禁止访问");
|