perf:key不用实现TsAuthorityHandler类

This commit is contained in:
曾文豪
2024-08-27 13:41:00 +08:00
parent 0310bd4a15
commit fd30c5cf36

View File

@@ -5,12 +5,12 @@ 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.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;
@@ -20,12 +20,17 @@ import java.util.Map;
@Service @Service
public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> { public class RoleAuthorityCreator implements ApplicationListener<ContextRefreshedEvent> {
@Resource @Autowired(required = false)
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);