*/
@Component @Aspect
public class AdviceMethod { private Log log = LogFactory.getLog(getClass()); @Around("execution(* com..*.controller..*(..))") public Object myprocess(ProceedingJoinPoint point) throws Throwable { // 打印访问的目标方法 System.out.println("类名:" + point.getTarget().toString()); System.out.println("方法名:" + point.getStaticPart()); // 获取目标方法执行的参数 Object[] args = point.getArgs(); Map<String, Object> map = JsonUtil.jsonToMap(args[0]); String key = String.valueOf(map.get("key")); String message = String.valueOf(map.get("message")); Test2 des = new Test2(key);// 生成密钥 // 解密传输参数 用解密后的参数去执行目标方法 并获得返回值 message = des.decrypt(message, true); args[0] = message; Object returnValue = point.proceed(args); // 获取当前时间 生成秘钥对返回值进行加密 String currentTime = CommonUtils.getCurrentTime(16); Test2 tokey = new Test2(currentTime); String values = tokey.encrypt(returnValue.toString()); // 将加密后的返回值转化为json 进行返回 Map<String, Object> toMap = new HashMap<String, Object>(); toMap.put("message", values); toMap.put("key", currentTime); return JsonUtil.objectToJson(map); } }