|
|
@@ -6,6 +6,9 @@ import feign.RequestTemplate;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* 功能概要:[feign拦截器主要用于透传用户信息等数据] <br>
|
|
|
*/
|
|
|
@@ -21,18 +24,33 @@ public class FeignRequestInterceptor implements RequestInterceptor {
|
|
|
*/
|
|
|
@Override
|
|
|
public void apply(RequestTemplate requestTemplate) {
|
|
|
- if(StringUtils.isNotBlank(RpcRequestInfo.getIp())){
|
|
|
+ if(StringUtils.isNotBlank(RpcRequestInfo.getIp())) {
|
|
|
requestTemplate.header(HeaderConstant.IP,RpcRequestInfo.getIp());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(RpcRequestInfo.getTenantId())){
|
|
|
+ if(StringUtils.isNotBlank(RpcRequestInfo.getTenantId())) {
|
|
|
requestTemplate.header(HeaderConstant.TENANT_ID,RpcRequestInfo.getTenantId());
|
|
|
}
|
|
|
requestTemplate.header(HeaderConstant.FROM_SERVICE_NAME,fromServiceName);
|
|
|
- if(StringUtils.isNotBlank(RpcRequestInfo.getUsername())){
|
|
|
+ if(StringUtils.isNotBlank(RpcRequestInfo.getUsername())) {
|
|
|
requestTemplate.header(HeaderConstant.USER_NAME,RpcRequestInfo.getUsername());
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(RpcRequestInfo.getTraceId())){
|
|
|
+ if(StringUtils.isNotBlank(RpcRequestInfo.getTraceId())) {
|
|
|
requestTemplate.header(HeaderConstant.TRACE_ID,RpcRequestInfo.getTraceId());
|
|
|
}
|
|
|
+
|
|
|
+ if(RpcRequestInfo.getScopeDeptIds() != null) {
|
|
|
+ requestTemplate.header(HeaderConstant.SCOPE_DEPT_IDS, intToStrArray(RpcRequestInfo.getScopeDeptIds()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> intToStrArray(List<Integer> list) {
|
|
|
+ if(list == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<String> rs = new ArrayList<>();
|
|
|
+ for(Integer temp : list) {
|
|
|
+ rs.add(String.valueOf(temp));
|
|
|
+ }
|
|
|
+ return rs;
|
|
|
}
|
|
|
}
|