perf:可以不实现TsAuthorityHandler类
This commit is contained in:
@@ -10,7 +10,7 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class, TsCacheTimedHandler.class})
|
@ConditionalOnMissingBean(value = TsCacheHandler.class, ignored = {TsCacheTimedHandler.class})
|
||||||
public class TsCacheTimedHandler implements TsCacheHandler {
|
public class TsCacheTimedHandler implements TsCacheHandler {
|
||||||
|
|
||||||
private static volatile TimedCache<String, String> timedCache;
|
private static volatile TimedCache<String, String> timedCache;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.aspectj.lang.JoinPoint;
|
|||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
|
@ConditionalOnBean(value = TsAuthorityHandler.class)
|
||||||
public class RoleAuthorityAspect {
|
public class RoleAuthorityAspect {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
|
|||||||
@@ -5,12 +5,13 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import com.tiesheng.annotation.role.RoleAuthority;
|
import com.tiesheng.annotation.role.RoleAuthority;
|
||||||
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
import com.tiesheng.util.service.role.TsAuthorityHandler;
|
||||||
import org.springframework.aop.support.AopUtils;
|
import org.springframework.aop.support.AopUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationListener;
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.context.event.ContextRefreshedEvent;
|
import org.springframework.context.event.ContextRefreshedEvent;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -18,19 +19,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ConditionalOnBean(value = TsAuthorityHandler.class)
|
||||||
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
|
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
|
||||||
|
|
||||||
@Autowired(required = false)
|
@Resource
|
||||||
TsAuthorityHandler tsAuthorityHandler;
|
TsAuthorityHandler tsAuthorityHandler;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||||
|
|
||||||
if (tsAuthorityHandler == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplicationContext applicationContext = event.getApplicationContext();
|
ApplicationContext applicationContext = event.getApplicationContext();
|
||||||
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);
|
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user