From 559b2e34c983f615b6d6747f52c801022c561803 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期一, 27 十月 2025 23:05:08 +0800
Subject: [PATCH] feat: 优化任务显示列表
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
index c0d4981..629f442 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java
@@ -9,6 +9,7 @@
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginBody;
@@ -17,6 +18,7 @@
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysMenuService;
/**
@@ -38,6 +40,9 @@
@Autowired
private TokenService tokenService;
+
+ @Autowired
+ private ISysDeptService deptService;
/**
* 鐧诲綍鏂规硶
@@ -75,10 +80,59 @@
loginUser.setPermissions(permissions);
tokenService.refreshToken(loginUser);
}
+
+ // 鑾峰彇鐢ㄦ埛鎵�鍦ㄧ殑鍒嗗叕鍙镐俊鎭�
+ Long branchCompanyId = null;
+ String branchCompanyName = null;
+ if (user.getDeptId() != null)
+ {
+ SysDept dept = deptService.selectDeptById(user.getDeptId());
+ if (dept != null)
+ {
+ // 鍒ゆ柇褰撳墠閮ㄩ棬鏄惁灏辨槸鍒嗗叕鍙革紙parent_id = 100锛�
+ if (dept.getParentId() != null && dept.getParentId() == 100)
+ {
+ branchCompanyId = dept.getDeptId();
+ branchCompanyName = dept.getDeptName();
+ }
+ else if (dept.getAncestors() != null && !dept.getAncestors().isEmpty())
+ {
+ // 浠� ancestors 瑙f瀽鍒嗗叕鍙窱D
+ // ancestors 鏍煎紡锛�"0,100,鍒嗗叕鍙窱D,瀛愰儴闂↖D"
+ String[] ancestorIds = dept.getAncestors().split(",");
+ // 鎵惧埌100鍚庨潰鐨勯偅涓狪D灏辨槸鍒嗗叕鍙窱D
+ for (int i = 0; i < ancestorIds.length; i++)
+ {
+ if ("100".equals(ancestorIds[i]) && i + 1 < ancestorIds.length)
+ {
+ try
+ {
+ Long companyId = Long.parseLong(ancestorIds[i + 1]);
+ SysDept branchCompany = deptService.selectDeptById(companyId);
+ if (branchCompany != null)
+ {
+ branchCompanyId = branchCompany.getDeptId();
+ branchCompanyName = branchCompany.getDeptName();
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ // 瑙f瀽澶辫触锛屽拷鐣�
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+
AjaxResult ajax = AjaxResult.success();
ajax.put("user", user);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
+ ajax.put("branchCompanyId", branchCompanyId);
+ ajax.put("branchCompanyName", branchCompanyName);
+ ajax.put("oaUserId", user.getOaUserId());
return ajax;
}
--
Gitblit v1.9.1