|
|
|
@@ -1,13 +1,11 @@ |
|
|
|
package com.xueyi.common.web.interceptor; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.csp.sentinel.util.StringUtil; |
|
|
|
import com.xueyi.common.core.constant.basic.SecurityConstants; |
|
|
|
import com.xueyi.common.core.context.SecurityContextHolder; |
|
|
|
import com.xueyi.common.core.utils.DecodeRequestUtils; |
|
|
|
import com.xueyi.common.core.web.vo.DeviceTenantSourceMergeVo; |
|
|
|
import com.xueyi.common.web.entity.domain.mapper.DeviceTenantMergeMapper; |
|
|
|
import com.xueyi.system.api.device.feign.RemoteDeviceTenantMergeService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@@ -41,22 +39,26 @@ public class ApiRequestInterceptor implements HandlerInterceptor { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
String str = DecodeRequestUtils.getRequestPostStr(request); |
|
|
|
String deviceId = request.getHeader("deviceId"); |
|
|
|
logger.info("请求头参数:deviceId={}", deviceId); |
|
|
|
|
|
|
|
/* String str = DecodeRequestUtils.getRequestPostStr(request); |
|
|
|
|
|
|
|
logger.info("请求参数:{}", str); |
|
|
|
|
|
|
|
JSONObject jsonObject = null; |
|
|
|
if (str.indexOf("{")>-1) { |
|
|
|
jsonObject = JSONObject.parseObject(str);// 解析请求参数 |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
if ((request.getParameterMap().containsKey("deviceId")||request.getParameterMap().containsKey("devId")) || (jsonObject!=null && (jsonObject.containsKey("deviceId")||jsonObject.containsKey("devId")))) { |
|
|
|
String devId = request.getParameter("deviceId"); |
|
|
|
// if ((request.getParameterMap().containsKey("deviceId")||request.getParameterMap().containsKey("devId")) || (jsonObject!=null && (jsonObject.containsKey("deviceId")||jsonObject.containsKey("devId")))) { |
|
|
|
if (StringUtil.isNotBlank(deviceId)) { |
|
|
|
/*String devId = request.getParameter("deviceId"); |
|
|
|
devId = StringUtils.isEmpty(devId) ? request.getParameter("devId") : devId; |
|
|
|
if (StringUtils.isEmpty(devId) && jsonObject != null) { |
|
|
|
devId = jsonObject.getString("deviceId"); |
|
|
|
devId = StringUtils.isEmpty(devId) ? jsonObject.getString("devId") : devId; |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
/*DeviceTenantSourceMergeVo vo = null; |
|
|
|
if (RedisUtil.existed("saas:source:device:" + devId)) { |
|
|
|
@@ -66,7 +68,7 @@ public class ApiRequestInterceptor implements HandlerInterceptor { |
|
|
|
RedisUtil.setVal("saas:source:device:" + devId, vo); |
|
|
|
}*/ |
|
|
|
|
|
|
|
DeviceTenantSourceMergeVo vo = mergeMapper.selectByDeviceId(devId);// 查询设备与租户、来源的关联关系 |
|
|
|
DeviceTenantSourceMergeVo vo = mergeMapper.selectByDeviceId(deviceId);// 查询设备与租户、来源的关联关系 |
|
|
|
SecurityContextHolder.setEnterpriseId(vo.getTenantId().toString());// 设置企业ID |
|
|
|
SecurityContextHolder.setSourceName(vo.getSourceSlave());// 设置数据源名称 |
|
|
|
SecurityContextHolder.set(SecurityConstants.FROM_SOURCE, SecurityConstants.INNER);// 设置数据来源 |
|
|
|
|