reset
This commit is contained in:
@@ -2,8 +2,6 @@ package com.ruoyi.project.system.dept.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -149,14 +147,4 @@ public class DeptController extends BaseController
|
||||
List<Map<String, Object>> tree = deptService.selectDeptTree();
|
||||
return tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载角色部门(数据权限)列表树
|
||||
*/
|
||||
@GetMapping("/roleDeptTreeData")
|
||||
@ResponseBody
|
||||
public List<Map<String, Object>> deptTreeData(Role role){
|
||||
List<Map<String, Object>> tree = deptService.roleDeptTreeData(role);
|
||||
return tree;
|
||||
}
|
||||
}
|
||||
|
@@ -80,12 +80,4 @@ public interface DeptMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public Dept checkDeptNameUnique(String deptName);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<String> selectRoleDeptTree(Long roleId);
|
||||
}
|
||||
|
@@ -4,8 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
@@ -57,42 +55,8 @@ public class DeptServiceImpl implements IDeptService
|
||||
{
|
||||
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
|
||||
List<Dept> deptList = deptMapper.selectDeptAll();
|
||||
trees=getTrees(deptList,false,null);
|
||||
return trees;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据角色ID查询部门(数据权限)
|
||||
*
|
||||
* @param role 角色对象
|
||||
* @return 部门列表(数据权限)
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> roleDeptTreeData(Role role) {
|
||||
Long roleId=role.getRoleId();
|
||||
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
|
||||
List<Dept> deptList=deptMapper.selectDeptAll();
|
||||
if(StringUtils.isNotNull(roleId)){
|
||||
List<String> roleDeptList=deptMapper.selectRoleDeptTree(roleId);
|
||||
trees=getTrees(deptList,true,roleDeptList);
|
||||
}else {
|
||||
trees=getTrees(deptList,false,null);
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
/**
|
||||
* 对象转菜单树
|
||||
*
|
||||
* @param menuList 菜单列表
|
||||
* @param isCheck 是否需要选中
|
||||
* @param roleDeptList 角色已存在菜单列表
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String, Object>> getTrees(List<Dept> menuList, boolean isCheck, List<String> roleDeptList){
|
||||
|
||||
List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>();
|
||||
for (Dept dept : menuList)
|
||||
for (Dept dept : deptList)
|
||||
{
|
||||
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()))
|
||||
{
|
||||
@@ -101,19 +65,12 @@ public class DeptServiceImpl implements IDeptService
|
||||
deptMap.put("pId", dept.getParentId());
|
||||
deptMap.put("name", dept.getDeptName());
|
||||
deptMap.put("title", dept.getDeptName());
|
||||
if (isCheck)
|
||||
{
|
||||
deptMap.put("checked", roleDeptList.contains(dept.getDeptId() + dept.getDeptName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
deptMap.put("checked", false);
|
||||
}
|
||||
trees.add(deptMap);
|
||||
}
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询部门人数
|
||||
*
|
||||
|
@@ -4,7 +4,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ruoyi.project.system.dept.domain.Dept;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
/**
|
||||
* 部门管理 服务层
|
||||
@@ -35,14 +34,6 @@ public interface IDeptService
|
||||
*/
|
||||
public List<Map<String, Object>> selectDeptTree();
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单
|
||||
*
|
||||
* @param role 角色对象
|
||||
* @return 菜单列表
|
||||
*/
|
||||
public List<Map<String, Object>> roleDeptTreeData(Role role);
|
||||
|
||||
/**
|
||||
* 查询部门人数
|
||||
*
|
||||
|
@@ -118,7 +118,8 @@ public class MenuServiceImpl implements IMenuService
|
||||
|
||||
/**
|
||||
* 查询所有菜单
|
||||
*
|
||||
*
|
||||
* @param role 角色对象
|
||||
* @return 菜单列表
|
||||
*/
|
||||
@Override
|
||||
|
@@ -1,5 +1,16 @@
|
||||
package com.ruoyi.project.system.role.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
|
||||
@@ -8,14 +19,6 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
import com.ruoyi.project.system.role.service.IRoleService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package com.ruoyi.project.system.role.domain;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
|
||||
import com.ruoyi.framework.web.domain.BaseEntity;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 角色对象 sys_role
|
||||
*
|
||||
@@ -38,8 +38,6 @@ public class Role extends BaseEntity
|
||||
private boolean flag = false;
|
||||
/** 菜单组 */
|
||||
private Long[] menuIds;
|
||||
/** 部门组(数据权限) */
|
||||
private Long[] deptIds;
|
||||
|
||||
public Long getRoleId()
|
||||
{
|
||||
@@ -111,19 +109,11 @@ public class Role extends BaseEntity
|
||||
this.menuIds = menuIds;
|
||||
}
|
||||
|
||||
public Long[] getDeptIds() {
|
||||
return deptIds;
|
||||
}
|
||||
|
||||
public void setDeptIds(Long[] deptIds) {
|
||||
this.deptIds = deptIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "Role [roleId=" + roleId + ", roleName=" + roleName + ", roleKey=" + roleKey + ", roleSort=" + roleSort
|
||||
+ ", status=" + status + ", flag=" + flag + ", menuIds=" + Arrays.toString(menuIds) + ", deptIds=" + Arrays.toString(deptIds)+ "]";
|
||||
+ ", status=" + status + ", flag=" + flag + ", menuIds=" + Arrays.toString(menuIds) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,32 +0,0 @@
|
||||
package com.ruoyi.project.system.role.domain;
|
||||
|
||||
/**
|
||||
* 角色和部门关联 sys_role_dept
|
||||
*/
|
||||
public class RoleDept {
|
||||
/** 角色ID */
|
||||
private Long roleId;
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
||||
public void setDeptId(Long deptId) {
|
||||
this.deptId = deptId;
|
||||
}
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "RoleDept [roleId=" + roleId + ", deptId=" + deptId + "]";
|
||||
}
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
package com.ruoyi.project.system.role.mapper;
|
||||
|
||||
import com.ruoyi.project.system.role.domain.RoleDept;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色与部门关联表(用于数据权限) 数据层
|
||||
*/
|
||||
public interface RoleDeptMapper {
|
||||
/**
|
||||
* 通过角色ID删除角色和部门关联
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleDeptByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色部门关联信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRoleDept(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询部门使用数量
|
||||
*
|
||||
* @param detpId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int selectCountRoleDeptByDetpId(Long detpId);
|
||||
|
||||
/**
|
||||
* 批量新增角色部门信息(数据权限)
|
||||
*
|
||||
* @param roleDeptList 角色菜单列表
|
||||
* @return 结果
|
||||
*/
|
||||
public int batchRoleDept(List<RoleDept> roleDeptList);
|
||||
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
package com.ruoyi.project.system.role.service;
|
||||
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import com.ruoyi.project.system.role.domain.Role;
|
||||
|
||||
/**
|
||||
* 角色业务层
|
||||
|
@@ -5,9 +5,6 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ruoyi.project.system.role.domain.RoleDept;
|
||||
import com.ruoyi.project.system.role.mapper.RoleDeptMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
@@ -38,9 +35,6 @@ public class RoleServiceImpl implements IRoleService
|
||||
@Autowired
|
||||
private UserRoleMapper userRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private RoleDeptMapper roleDeptMapper;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
@@ -168,14 +162,12 @@ public class RoleServiceImpl implements IRoleService
|
||||
// 新增角色信息
|
||||
roleMapper.insertRole(role);
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
//新增角色和部门信息(数据权限)
|
||||
insertRoleDept(role);
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
*
|
||||
*
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@@ -188,15 +180,13 @@ public class RoleServiceImpl implements IRoleService
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId());
|
||||
ShiroUtils.clearCachedAuthorizationInfo();
|
||||
//新增角色和部门信息(数据权限)
|
||||
insertRoleDept(role);
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色菜单信息
|
||||
*
|
||||
* @param role 角色对象
|
||||
* @param user 角色对象
|
||||
*/
|
||||
public int insertRoleMenu(Role role)
|
||||
{
|
||||
@@ -217,27 +207,6 @@ public class RoleServiceImpl implements IRoleService
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增角色部门信息(数据权限)
|
||||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
public void insertRoleDept(Role role)
|
||||
{
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<RoleDept> list = new ArrayList<RoleDept>();
|
||||
for (Long deptId : role.getDeptIds())
|
||||
{
|
||||
RoleDept rd = new RoleDept();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0)
|
||||
{
|
||||
roleDeptMapper.batchRoleDept(list);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 校验角色名称是否唯一
|
||||
*
|
||||
|
Reference in New Issue
Block a user