|
|
@@ -4,18 +4,29 @@ package com.fs.framework.config;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
import com.fs.common.config.LoginContextCallback;
|
|
|
import com.fs.common.enums.DataScopeEnum;
|
|
|
+import com.fs.common.utils.spring.SpringUtils;
|
|
|
import com.fs.company.domain.CompanyRole;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyRoleMapper;
|
|
|
import com.fs.framework.security.LoginUser;
|
|
|
import com.fs.framework.security.SecurityUtils;
|
|
|
+import org.springframework.beans.BeansException;
|
|
|
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
|
|
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+import org.springframework.context.ApplicationContextAware;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 登录上下文回调实现
|
|
|
*/
|
|
|
-public class CompanyLoginContextCallback implements LoginContextCallback {
|
|
|
+@Component
|
|
|
+public class CompanyLoginContextCallback implements LoginContextCallback, ApplicationContextAware {
|
|
|
+
|
|
|
+ private static ApplicationContext applicationContext;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Long getUserId() {
|
|
|
@@ -55,7 +66,7 @@ public class CompanyLoginContextCallback implements LoginContextCallback {
|
|
|
|
|
|
@Override
|
|
|
public DataScopeEnum getDataScope(){
|
|
|
- CompanyRoleMapper companyRoleMapper = SpringUtil.getBean(CompanyRoleMapper.class);
|
|
|
+ CompanyRoleMapper companyRoleMapper = applicationContext.getBean(CompanyRoleMapper.class);
|
|
|
List<String> dataScope = companyRoleMapper.queryCompanyUserDataScope(getCompanyUserId());
|
|
|
if (dataScope == null || dataScope.isEmpty()) {
|
|
|
return null;
|
|
|
@@ -77,4 +88,9 @@ public class CompanyLoginContextCallback implements LoginContextCallback {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
+ CompanyLoginContextCallback.applicationContext = applicationContext;
|
|
|
+ }
|
|
|
}
|