2 changed files with 44 additions and 24 deletions
			
			
		@ -0,0 +1,40 @@ | 
				
			|||||
 | 
					/** | 
				
			||||
 | 
					 * Copyright (c) 2018 人人开源 All rights reserved. | 
				
			||||
 | 
					 * <p> | 
				
			||||
 | 
					 * https://www.renren.io
 | 
				
			||||
 | 
					 * <p> | 
				
			||||
 | 
					 * 版权所有,侵权必究! | 
				
			||||
 | 
					 */ | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					package com.epmet.commons.mybatis.aspect; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
				
			||||
 | 
					import org.aspectj.lang.JoinPoint; | 
				
			||||
 | 
					import org.aspectj.lang.annotation.Aspect; | 
				
			||||
 | 
					import org.aspectj.lang.annotation.Before; | 
				
			||||
 | 
					import org.slf4j.Logger; | 
				
			||||
 | 
					import org.slf4j.LoggerFactory; | 
				
			||||
 | 
					import org.springframework.stereotype.Component; | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					/** | 
				
			||||
 | 
					 * 每次请求,清理ThreadLocal线程中的变量 | 
				
			||||
 | 
					 * @Author wxz | 
				
			||||
 | 
					 * @Description | 
				
			||||
 | 
					 * @Date 2020/4/23 16:16 | 
				
			||||
 | 
					 **/ | 
				
			||||
 | 
					@Aspect | 
				
			||||
 | 
					@Component | 
				
			||||
 | 
					public class ThreadLocalPreCleanAspect { | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    private static final Logger log = LoggerFactory.getLogger(ThreadLocalPreCleanAspect.class); | 
				
			||||
 | 
					
 | 
				
			||||
 | 
					    @Before(value = "execution(* com.epmet.controller.*Controller*.*(..)) ") | 
				
			||||
 | 
					    public void before(JoinPoint point) throws Throwable { | 
				
			||||
 | 
					        // 清理权限过滤中的变量残留
 | 
				
			||||
 | 
					        try { | 
				
			||||
 | 
					            DataFilterAspect.sqlFilter.remove(); | 
				
			||||
 | 
					        } catch (Exception e) { | 
				
			||||
 | 
					            log.error("清理sqlFilter缓存失败:{}", ExceptionUtils.getErrorStackTrace(e)); | 
				
			||||
 | 
					        } | 
				
			||||
 | 
					    } | 
				
			||||
 | 
					} | 
				
			||||
					Loading…
					
					
				
		Reference in new issue