zhanghl
2025-04-22 d2d8db6a6f66f3b646e395a7a2a4822ce68d5b47
aps-modules/aps-system/src/main/java/com/aps/system/service/impl/SysRoleServiceImpl.java
@@ -1,10 +1,9 @@
package com.aps.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import com.aps.system.api.domain.SysDept;
import com.aps.system.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -19,10 +18,6 @@
import com.aps.system.domain.SysRoleDept;
import com.aps.system.domain.SysRoleMenu;
import com.aps.system.domain.SysUserRole;
import com.aps.system.mapper.SysRoleDeptMapper;
import com.aps.system.mapper.SysRoleMapper;
import com.aps.system.mapper.SysRoleMenuMapper;
import com.aps.system.mapper.SysUserRoleMapper;
import com.aps.system.service.ISysRoleService;
/**
@@ -45,6 +40,8 @@
    @Autowired
    private SysRoleDeptMapper roleDeptMapper;
    @Autowired
    private SysDeptMapper deptMapper;
    /**
     * 根据条件分页查询角色数据
     * 
@@ -320,12 +317,21 @@
        int rows = 1;
        // 新增角色与部门(数据权限)管理
        List<SysRoleDept> list = new ArrayList<SysRoleDept>();
        for (Long deptId : role.getDeptIds())
        Long[] deptIds = role.getDeptIds();
        List<SysDept> sysDepts = deptMapper.selectDeptListByIdList(Arrays.asList(deptIds));
        for (Long deptId : deptIds)
        {
            SysRoleDept rd = new SysRoleDept();
            rd.setRoleId(role.getRoleId());
            rd.setDeptId(deptId);
            list.add(rd);
            Optional<SysDept> first = sysDepts.stream().filter(sysDept -> sysDept.getDeptId().equals(deptId)).findFirst();
            if(first.isPresent()){
                SysDept sysDept = first.get();
                SysRoleDept rd = new SysRoleDept();
                rd.setRoleId(role.getRoleId());
                rd.setDeptId(deptId);
                rd.setDeptOrgCode(sysDept.getOrgCode());
                list.add(rd);
            }
        }
        if (list.size() > 0)
        {