fix 修复 错误修改导致页面逻辑错误

This commit is contained in:
疯狂的狮子Li 2025-07-04 17:42:19 +08:00
parent c9098563ca
commit 7147f81b42

View File

@ -4,7 +4,6 @@ import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.stp.StpUtil; import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -40,7 +39,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 角色 业务层处理 * 角色 业务层处理
@ -357,18 +355,19 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
* @param role 角色对象 * @param role 角色对象
*/ */
private int insertRoleMenu(SysRoleBo role) { private int insertRoleMenu(SysRoleBo role) {
Long[] menuIds = role.getMenuIds(); int rows = 1;
if (ArrayUtil.isEmpty(menuIds)) { // 新增用户与角色管理
return 0; List<SysRoleMenu> list = new ArrayList<>();
for (Long menuId : role.getMenuIds()) {
SysRoleMenu rm = new SysRoleMenu();
rm.setRoleId(role.getRoleId());
rm.setMenuId(menuId);
list.add(rm);
} }
List<SysRoleMenu> roleMenuList = Arrays.stream(menuIds) if (CollUtil.isNotEmpty(list)) {
.map(menuId -> { rows = roleMenuMapper.insertBatch(list) ? list.size() : 0;
SysRoleMenu roleMenu = new SysRoleMenu(); }
roleMenu.setRoleId(role.getRoleId()); return rows;
roleMenu.setMenuId(menuId);
return roleMenu;
}).collect(Collectors.toList());
return roleMenuMapper.insertBatch(roleMenuList) ? roleMenuList.size() : 0;
} }
/** /**
@ -377,18 +376,19 @@ public class SysRoleServiceImpl implements ISysRoleService, RoleService {
* @param role 角色对象 * @param role 角色对象
*/ */
private int insertRoleDept(SysRoleBo role) { private int insertRoleDept(SysRoleBo role) {
Long[] deptIds = role.getDeptIds(); int rows = 1;
if (ArrayUtil.isEmpty(deptIds)) { // 新增角色与部门数据权限管理
return 0; List<SysRoleDept> list = new ArrayList<>();
for (Long deptId : role.getDeptIds()) {
SysRoleDept rd = new SysRoleDept();
rd.setRoleId(role.getRoleId());
rd.setDeptId(deptId);
list.add(rd);
} }
List<SysRoleDept> roleDeptList = Arrays.stream(deptIds) if (CollUtil.isNotEmpty(list)) {
.map(deptId -> { rows = roleDeptMapper.insertBatch(list) ? list.size() : 0;
SysRoleDept roleDept = new SysRoleDept(); }
roleDept.setRoleId(role.getRoleId()); return rows;
roleDept.setDeptId(deptId);
return roleDept;
}).collect(Collectors.toList());
return roleDeptMapper.insertBatch(roleDeptList) ? roleDeptList.size() : 0;
} }
/** /**