feat(特色专区与项目管理代码合并): 解决合并冲突

修复用户身份判定异常的问题:当前系统微服务中存在两套用户身份判断的方式(通过Url携带的currentDeptId字段或者header中携带的Dept-Id字段),针对于特色专区获取组织下角色时该接口携带了currentDeptId导致身份识别失败,所以将header的优先级调高
This commit is contained in:
OTTO 2024-09-03 14:37:59 +08:00
parent 8de39f00cb
commit d7b6d5aae6
1 changed files with 8 additions and 6 deletions

View File

@ -3,6 +3,7 @@ package com.microservices.system.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.microservices.common.core.constant.SecurityConstants;
import com.microservices.common.core.utils.ServletUtils;
import com.microservices.common.core.utils.StringUtils;
import com.microservices.common.security.service.IRequestCustomService;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@ -18,12 +19,13 @@ import javax.servlet.http.HttpServletRequest;
public class SystemRequestCustomServiceImpl implements IRequestCustomService {
@Override
public String processRequestDeptId(HttpServletRequest request) {
Object attributeObj = request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
JSONObject jsonObject = JSONObject.from(attributeObj);
Long deptId = jsonObject.getLong("currentDeptId");
if (deptId == null) {
return ServletUtils.getHeader(request, SecurityConstants.DEPT_ID);
String deptId = ServletUtils.getHeader(request, SecurityConstants.DEPT_ID);
if (StringUtils.isNotEmpty(deptId)) {
return deptId;
} else {
Object attributeObj = request.getAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE);
JSONObject jsonObject = JSONObject.from(attributeObj);
return jsonObject.getString("currentDeptId");
}
return deptId.toString();
}
}