refactor(tenant): 移除部门ID回退逻辑中的用户信息解析功能

- 删除了从登录用户info中解析部门ID的复杂逻辑
- 移除了对LoginUser.INFO_KEY_DEPT_IDS和相关公司信息的存储
- 简化了部门ID的获取流程,只保留请求头、请求属性和登录缓存的回退顺序
- 减少了不必要的JSON解析操作,提高性能
- 清理了相关的异常处理代码
This commit is contained in:
wuzongyong
2026-01-28 11:44:53 +08:00
parent 2227271d08
commit 1f00961c1b
2 changed files with 0 additions and 22 deletions

View File

@@ -47,31 +47,12 @@ public class CompanyVisitContextInterceptor implements HandlerInterceptor {
}
Long deptId = WebFrameworkUtils.getDeptId(request);
// 部门信息同样遵循"请求头 -> 请求属性 -> 登录缓存"的回退顺序
if (deptId == null || deptId <= 0L) {
Long attrDeptId = resolveLong(request.getAttribute(WebFrameworkUtils.HEADER_VISIT_DEPT_ID));
if (attrDeptId != null && attrDeptId > 0L) {
deptId = attrDeptId;
} else if (loginUser != null && loginUser.getVisitDeptId() != null && loginUser.getVisitDeptId() > 0L) {
deptId = loginUser.getVisitDeptId();
} else if (loginUser != null) {
// 如果以上都没有尝试从用户info中获取第一个部门作为默认值
Map<String, String> info = loginUser.getInfo();
if (info != null) {
String deptIdsStr = info.get(LoginUser.INFO_KEY_DEPT_IDS);
if (deptIdsStr != null && !deptIdsStr.isEmpty() && !"[]".equals(deptIdsStr)) {
try {
// 解析JSON数组取第一个部门ID
deptIdsStr = deptIdsStr.trim();
if (deptIdsStr.startsWith("[") && deptIdsStr.length() > 2) {
String firstId = deptIdsStr.substring(1, deptIdsStr.indexOf(']')).split(",")[0].trim();
deptId = Long.parseLong(firstId);
}
} catch (Exception e) {
log.warn("[CompanyVisitContextInterceptor][解析用户默认部门失败: {}]", deptIdsStr, e);
}
}
}
}
}