日志 aop 中 @Around(“execution(?)“)中路径的配置

    技术2022-07-12  70

    //环绕通知 首先是:包名 然后是: 类名 然后是方法名:方法名 括号内是:参数 @Around("execution(* com.sinosoft.*.controller.*.*(..))") public Object around(ProceedingJoinPoint point) throws Throwable{ //参数是目标方法 try { String typeName=""; String locat=""; Signature signature = point.getSignature(); MethodSignature methodSignature = (MethodSignature)signature; //获取当前执行的方法 Method targetMethod = methodSignature.getMethod(); //判断是否具有RequestMapping注解 UserExtend eUser = (UserExtend) request.getSession().getAttribute("CURRENT_USER_INFO"); if (targetMethod.isAnnotationPresent(LogAnno.class)) { typeName=targetMethod.getAnnotation(LogAnno.class).operationType(); locat=targetMethod.getAnnotation(LogAnno.class).operationName(); Logger logger=new Logger(); logger.setCreateTime(new Date()); logger.setUserid(eUser.getId()); logger.setOrgid(eUser.getOrgid()); logger.setOpType(typeName); logger.setLocation(locat); loggerMapper.insertSelective(logger); } } catch (Exception e) { e.printStackTrace(); } return point.proceed(); //代理方法的返回值 }
    Processed: 0.011, SQL: 9