liupeng 4 年之前
父节点
当前提交
2d97f76975

+ 3 - 0
code/sapparent/sapservice/src/main/java/org/fouram/constants/WebConstants.java

@@ -31,4 +31,7 @@ public final class WebConstants {
 	
 	public static final String CACHE_SYNC_SAP = "CACHE_SYNC_SAP";
 	
+	public static boolean isProduct() {
+		return "product".equals(ConfConfig.getConfigString("env"));
+	}
 }

+ 43 - 40
code/sapparent/sapservice/src/main/java/org/fouram/core/base/exception/ControllerExceptionHandler.java

@@ -1,41 +1,44 @@
-package org.fouram.core.base.exception;
-
-import org.fouram.core.base.model.PageData;
-import org.fouram.core.plugin.weixin.cp.util.WXCpMessageUtil;
-import org.fouram.core.util.AppUtil;
-import org.fouram.core.util.AppUtil.ResultConstant;
-import org.fouram.core.util.Tools;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.error.WxErrorException;
-
-/**
- * @author Liup
- */
-@Slf4j
-@ControllerAdvice
-public class ControllerExceptionHandler {
-
-	/**
-	 * 异常处理
-	 */
-	@ResponseBody
-	@ExceptionHandler(Throwable.class)
-	public PageData exceptionHandler(Throwable ex) {
-		// 提示不输出报错日志
-		if (PromptException.class.getSimpleName().equals(ex.getClass().getSimpleName())) {
-			return AppUtil.error(ex.getMessage());
-		}
-		String messageContent = Tools.getExceptionAllInfo(ex);
-//		WXCpMessageUtil.sendAdminError(messageContent);
-		log.error(messageContent);
-		if (ex.getClass().getSimpleName().equals(WxErrorException.class.getSimpleName())) {
-			WxErrorException wxErrorException = (WxErrorException) ex;
-			return AppUtil.error(wxErrorException.getError().getErrorMsg());
-		}
-		return AppUtil.error(ResultConstant.WEB_ERR_MSG);
-	}
+package org.fouram.core.base.exception;
+
+import org.fouram.constants.WebConstants;
+import org.fouram.core.base.model.PageData;
+import org.fouram.core.plugin.weixin.cp.util.WXCpMessageUtil;
+import org.fouram.core.util.AppUtil;
+import org.fouram.core.util.AppUtil.ResultConstant;
+import org.fouram.core.util.Tools;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
+
+/**
+ * @author Liup
+ */
+@Slf4j
+@ControllerAdvice
+public class ControllerExceptionHandler {
+
+	/**
+	 * 异常处理
+	 */
+	@ResponseBody
+	@ExceptionHandler(Throwable.class)
+	public PageData exceptionHandler(Throwable ex) {
+		// 提示不输出报错日志
+		if (PromptException.class.getSimpleName().equals(ex.getClass().getSimpleName())) {
+			return AppUtil.error(ex.getMessage());
+		}
+		String messageContent = Tools.getExceptionAllInfo(ex);
+		if(WebConstants.isProduct()) {
+			WXCpMessageUtil.sendAdminError(messageContent);
+		}
+		log.error(messageContent);
+		if (ex.getClass().getSimpleName().equals(WxErrorException.class.getSimpleName())) {
+			WxErrorException wxErrorException = (WxErrorException) ex;
+			return AppUtil.error(wxErrorException.getError().getErrorMsg());
+		}
+		return AppUtil.error(ResultConstant.WEB_ERR_MSG);
+	}
 }