From 50fb58286ed3b718c39a97e0987ee7561a295651 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期五, 04 七月 2025 17:56:41 +0800
Subject: [PATCH] git ch

---
 server/service/src/main/java/com/doumee/biz/system/impl/SystemMenuBizImpl.java |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/biz/system/impl/SystemMenuBizImpl.java b/server/service/src/main/java/com/doumee/biz/system/impl/SystemMenuBizImpl.java
index 0d96c2f..1f9e5ef 100644
--- a/server/service/src/main/java/com/doumee/biz/system/impl/SystemMenuBizImpl.java
+++ b/server/service/src/main/java/com/doumee/biz/system/impl/SystemMenuBizImpl.java
@@ -3,11 +3,19 @@
 import com.doumee.biz.system.SystemMenuBiz;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
+import com.doumee.core.model.LoginUserInfo;
+import com.doumee.core.utils.Constants;
+import com.doumee.dao.business.CompanyMapper;
+import com.doumee.dao.business.model.Company;
 import com.doumee.dao.system.dto.UpdateSystemMenuSortDTO;
 import com.doumee.dao.system.model.SystemMenu;
+import com.doumee.dao.system.model.SystemUser;
 import com.doumee.dao.system.vo.SystemMenuListVO;
 import com.doumee.dao.system.vo.SystemMenuNodeVO;
+import com.doumee.service.business.CompanyService;
 import com.doumee.service.system.SystemMenuService;
+import com.doumee.service.system.SystemUserService;
+import org.apache.shiro.SecurityUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -16,12 +24,20 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 @Service
 public class SystemMenuBizImpl implements SystemMenuBiz {
 
     @Autowired
     private SystemMenuService systemMenuService;
+
+    @Autowired
+    private CompanyService companyService;
+
+    @Autowired
+    private SystemUserService systemUserService;
 
     @Override
     public Integer create(SystemMenu systemMenu) {
@@ -56,6 +72,8 @@
         List<SystemMenu> menuPool;
         if (currentMenu.getParentId() == null) {
             menuPool = systemMenuService.findRootList();
+            //2024骞�11鏈�16鏃�13:51:53 杩囨护鍚岀被鍨嬫暟鎹�
+            menuPool = menuPool.stream().filter(i->Constants.equalsInteger(i.getType(),currentMenu.getType())).collect(Collectors.toList());
         } else {
             SystemMenu queryDto = new SystemMenu();
             queryDto.setParentId(currentMenu.getParentId());
@@ -95,8 +113,12 @@
     public List<SystemMenuListVO> findTreeByType(Integer type) {
         List<SystemMenuListVO> menus = systemMenuService.findList(type);
         List<SystemMenuListVO> rootMenus = new ArrayList<>();
+        if(type.equals(Constants.ONE)){
+            menus = menus.stream().filter(m->!m.getDisabled()).collect(Collectors.toList());
+        }
         // 娣诲姞鏍硅彍鍗�
         for (SystemMenu menu : menus) {
+
             if (menu.getParentId() == null) {
                 SystemMenuListVO rootMenu = new SystemMenuListVO();
                 BeanUtils.copyProperties(menu, rootMenu, "children");
@@ -115,8 +137,30 @@
     public List<SystemMenuNodeVO> findTree (Integer userId,Integer type) {
         SystemMenu queryDto = new SystemMenu();
         queryDto.setDeleted(Boolean.FALSE);
-        List<SystemMenu> menus = systemMenuService.findByUserId(userId,type);
+        List<SystemMenu> menus = new ArrayList<SystemMenu>();
         List<SystemMenuNodeVO> rootNodes = new ArrayList<>();
+        menus = systemMenuService.findByUserId(userId,type);
+        if(type.equals(Constants.ONE) || type.equals(Constants.TWO)){
+            LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+            Company company = companyService.findById(loginUserInfo.getCompanyId());
+            if(Objects.isNull(company)){
+                return rootNodes;
+            }
+            SystemUser dbUser = new SystemUser();
+            dbUser.setId(loginUserInfo.getId());
+            SystemUser systemUser = systemUserService.findOne(dbUser);
+            if(Objects.isNull(systemUser)){
+                return rootNodes;
+            }
+            if(company.getUsername().equals(systemUser.getUsername())
+            || (Constants.equalsInteger(type,Constants.ONE) && !Constants.equalsInteger(systemUser.getCompanyId(),company.getId()))){
+                SystemMenu systemMenu = new SystemMenu();
+                systemMenu.setType(type);
+                systemMenu.setDeleted(Boolean.FALSE);
+                systemMenu.setDisabled(Boolean.FALSE);
+                menus = systemMenuService.findList(systemMenu);
+            }
+        }
         // 娣诲姞鏍硅彍鍗�
         for (SystemMenu menu : menus) {
             if (menu.getParentId() == null) {

--
Gitblit v1.9.3