perf:可以不实现TsAuthorityHandler类

This commit is contained in:
曾文豪
2024-09-18 16:47:29 +08:00
parent 456a95778c
commit 2621c6dedc
3 changed files with 7 additions and 8 deletions

View File

@@ -15,6 +15,7 @@ import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@@ -24,6 +25,7 @@ import java.util.stream.Collectors;
@Aspect
@Component
@ConditionalOnBean(value = TsAuthorityHandler.class)
public class RoleAuthorityAspect {
@Resource

View File

@@ -5,12 +5,13 @@ import cn.hutool.core.date.DateUtil;
import com.tiesheng.annotation.role.RoleAuthority;
import com.tiesheng.util.service.role.TsAuthorityHandler;
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.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
@@ -18,19 +19,15 @@ import java.util.List;
import java.util.Map;
@Service
@ConditionalOnBean(value = TsAuthorityHandler.class)
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
@Autowired(required = false)
@Resource
TsAuthorityHandler tsAuthorityHandler;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (tsAuthorityHandler == null) {
return;
}
ApplicationContext applicationContext = event.getApplicationContext();
Map<String, Object> beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class);