From 186ec9dcec258b3cead27c6874a828b9f48e1c8b Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Fri, 28 Aug 2020 13:55:15 +0800
Subject: [PATCH] update

---
 src/main/java/com/moral/common/aop/ControllerAOP.java |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/moral/common/aop/ControllerAOP.java b/src/main/java/com/moral/common/aop/ControllerAOP.java
index 8c90a0b..0c1c441 100644
--- a/src/main/java/com/moral/common/aop/ControllerAOP.java
+++ b/src/main/java/com/moral/common/aop/ControllerAOP.java
@@ -33,7 +33,7 @@
 
 		try {
 			result = pjp.proceed();
-			log.info(pjp.getSignature() + "use time:" + (System.currentTimeMillis() - startTime));
+			// log.info(pjp.getSignature() + "use time:" + (System.currentTimeMillis() - startTime));
 		} catch (Throwable e) {
 			result = handlerException(pjp, e);
 		}
@@ -52,29 +52,29 @@
 		Object target = pjp.getTarget();
 		Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
 		Type type = currentMethod.getGenericReturnType();
-		String message = "";
+		String message = e.getMessage();
+		Map<String, Object> resultMap = new HashMap<String, Object>();
 		if (e instanceof BusinessException) {
-			message = e.getLocalizedMessage();
+			log.error(e.getMessage());
+			resultMap.put("msg", message);
 		} else if (e instanceof ValidateException) {
-			message = e.getLocalizedMessage();
 		} else {
-			log.error(pjp.getSignature() + " error ", e);
-			message = e.toString();
+			log.error(pjp.getSignature() + " error: " + e.toString(), e);
 		}
-
 		if (type instanceof ParameterizedType) {
-			Type rawType = ((ParameterizedType) type).getRawType();
-			if (rawType == AppData.class) {
-				return new AppData(message,AppData.FAIL);
-			} else if (rawType == ResultBean.class) {
-				return new ResultBean(message,ResultBean.FAIL);
-			} else if (rawType == Map.class) {
-				Map<String, Object> resultMap = new HashMap<String, Object>();
-				resultMap.put("msg", message);
-				return resultMap;
-			}
+			type = ((ParameterizedType) type).getRawType();
 		}
-		return null;
-
+		if (type == AppData.class) {
+			return new AppData(message, AppData.FAIL);
+		} else if (type == ResultBean.class) {
+			return new ResultBean(e);
+		} else if (type == Map.class) {
+			resultMap.put("msg", message);
+			return resultMap;
+		} else if (type == Void.TYPE) {
+			return null;
+		} else {
+			return type.getClass().newInstance();
+		}
 	}
 }

--
Gitblit v1.8.0