From 0e8110030b0eb4e8be3d1504554d56217e64d236 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Thu, 04 Jan 2018 16:25:57 +0800
Subject: [PATCH] 组织模块

---
 src/main/java/com/moral/common/aop/ControllerAOP.java |   34 ++++++++++++++++------------------
 1 files changed, 16 insertions(+), 18 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..1b6072d 100644
--- a/src/main/java/com/moral/common/aop/ControllerAOP.java
+++ b/src/main/java/com/moral/common/aop/ControllerAOP.java
@@ -52,29 +52,27 @@
 		Object target = pjp.getTarget();
 		Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
 		Type type = currentMethod.getGenericReturnType();
-		String message = "";
+		String message = e.getMessage();
 		if (e instanceof BusinessException) {
-			message = e.getLocalizedMessage();
 		} 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) {
+			Map<String, Object> resultMap = new HashMap<String, Object>();
+			resultMap.put("msg", message);
+			return resultMap;
+		} else if (type == Void.TYPE) {
+			return null;
+		} else {
+			return type.getClass().newInstance();
+		}
 	}
 }

--
Gitblit v1.8.0