feat:(REQ-2300) 上下文中增加resultKey
This commit is contained in:
parent
2d06b6a4fe
commit
9771a5affa
@ -6,9 +6,11 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -20,9 +22,9 @@ import static cn.axzo.framework.datapermission.context.DataPermissionContextHold
|
|||||||
* @author tanjie@axzo.cn
|
* @author tanjie@axzo.cn
|
||||||
* @date 2024/5/31 16:37
|
* @date 2024/5/31 16:37
|
||||||
*/
|
*/
|
||||||
@Order(2)
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DataPermissionFilter implements HandlerInterceptor {
|
public class DataPermissionFilter implements HandlerInterceptor, WebMvcConfigurer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拦截@DataPermission
|
* 拦截@DataPermission
|
||||||
@ -56,4 +58,9 @@ public class DataPermissionFilter implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,12 +7,14 @@ import cn.axzo.framework.datapermission.context.DataPermissionContextHolder;
|
|||||||
import cn.axzo.karma.client.feign.tyr.DataObjectApi;
|
import cn.axzo.karma.client.feign.tyr.DataObjectApi;
|
||||||
import cn.axzo.karma.client.feign.tyr.request.MatchDataObjectReq;
|
import cn.axzo.karma.client.feign.tyr.request.MatchDataObjectReq;
|
||||||
import cn.axzo.karma.client.feign.tyr.response.MatchDataObjectResp;
|
import cn.axzo.karma.client.feign.tyr.response.MatchDataObjectResp;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.springframework.core.annotation.Order;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@ -21,12 +23,12 @@ import java.util.Optional;
|
|||||||
/**
|
/**
|
||||||
* 解析数据权限规则,把解析后的数据放置在上下文中DataPermissionContext
|
* 解析数据权限规则,把解析后的数据放置在上下文中DataPermissionContext
|
||||||
*/
|
*/
|
||||||
@Order(2)
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
public class ResolveDataPermissionRuleFilter implements HandlerInterceptor, WebMvcConfigurer {
|
||||||
public class ResolveDataPermissionRuleFilter implements HandlerInterceptor {
|
|
||||||
|
|
||||||
private final DataObjectApi dataObjectApi;
|
@Autowired
|
||||||
|
private DataObjectApi dataObjectApi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拦截@DataPermission
|
* 拦截@DataPermission
|
||||||
@ -70,6 +72,7 @@ public class ResolveDataPermissionRuleFilter implements HandlerInterceptor {
|
|||||||
.personId(contextInfo.getUserInfo().getPersonId())
|
.personId(contextInfo.getUserInfo().getPersonId())
|
||||||
.dataPermissionNodeIds(matchDataObjectOptional.get().getNodeIds())
|
.dataPermissionNodeIds(matchDataObjectOptional.get().getNodeIds())
|
||||||
.dataPermissionPersonIds(matchDataObjectOptional.get().getPersonIds())
|
.dataPermissionPersonIds(matchDataObjectOptional.get().getPersonIds())
|
||||||
|
.resultKey(matchDataObjectOptional.get().getResultKey())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
DataPermissionContextHolder.setContext(dataPermissionContext);
|
DataPermissionContextHolder.setContext(dataPermissionContext);
|
||||||
@ -90,4 +93,9 @@ public class ResolveDataPermissionRuleFilter implements HandlerInterceptor {
|
|||||||
|
|
||||||
return Optional.ofNullable(dataObjectApi.match(matchDataObjectReq).getData());
|
return Optional.ofNullable(dataObjectApi.match(matchDataObjectReq).getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,11 @@ public class DataPermissionContextHolder {
|
|||||||
* 解析后的部门id
|
* 解析后的部门id
|
||||||
*/
|
*/
|
||||||
private Set<Long> dataPermissionNodeIds;
|
private Set<Long> dataPermissionNodeIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匹配的解析规则放在redis中的key
|
||||||
|
*/
|
||||||
|
private String resultKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove() {
|
public static void remove() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user