com.ruoyi.system.domain.SysDept Java Examples
The following examples show how to use
com.ruoyi.system.domain.SysDept.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 根据角色ID查询部门(数据权限) * * @param role 角色对象 * @return 部门列表(数据权限) */ @Override public List<Ztree> roleDeptTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Ztree> ztrees = new ArrayList<Ztree>(); List<SysDept> deptList = selectDeptList(new SysDept()); if (StringUtils.isNotNull(roleId)) { List<String> roleDeptList = deptMapper.selectRoleDeptTree(roleId); ztrees = initZtree(deptList, roleDeptList); } else { ztrees = initZtree(deptList); } return ztrees; }
Example #2
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 对象转部门树 * * @param deptList 部门列表 * @param roleDeptList 角色已存在菜单列表 * @return 树结构列表 */ public List<Ztree> initZtree(List<SysDept> deptList, List<String> roleDeptList) { List<Ztree> ztrees = new ArrayList<Ztree>(); boolean isCheck = StringUtils.isNotNull(roleDeptList); for (SysDept dept : deptList) { if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { Ztree ztree = new Ztree(); ztree.setId(dept.getDeptId()); ztree.setpId(dept.getParentId()); ztree.setName(dept.getDeptName()); ztree.setTitle(dept.getDeptName()); if (isCheck) { ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); } ztrees.add(ztree); } } return ztrees; }
Example #3
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 修改保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = selectDeptById(dept.getDeptId()); if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } int result = deptMapper.updateDept(dept); if(UserConstants.DEPT_NORMAL.equals(dept.getStatus())){ //如果该部门是启用状态,这启用该部门的所有上级部门 updateParentDeptStatus(dept); } return result; }
Example #4
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 修改保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override @Transactional public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = selectDeptById(dept.getDeptId()); if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } int result = deptMapper.updateDept(dept); if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatus(dept); } return result; }
Example #5
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 根据角色ID查询部门(数据权限) * * @param role 角色对象 * @return 部门列表(数据权限) */ @Override public List<Map<String, Object>> roleDeptTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<SysDept> deptList = selectDeptList(new SysDept()); if (StringUtils.isNotNull(roleId)) { List<String> roleDeptList = deptMapper.selectRoleDeptTree(roleId); trees = getTrees(deptList, true, roleDeptList); } else { trees = getTrees(deptList, false, null); } return trees; }
Example #6
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 对象转部门树 * * @param deptList 部门列表 * @param roleDeptList 角色已存在菜单列表 * @return 部门树 */ private List<Ztree> initZtree(List<SysDept> deptList, List<String> roleDeptList) { List<Ztree> ztrees = new ArrayList<>(); boolean isCheck = CollectionUtil.isNotEmpty(roleDeptList); if(CollectionUtil.isNotEmpty(deptList)){ deptList.stream() .filter(dept-> UserConstants.DEPT_NORMAL.equals(dept.getStatus())) .forEach(dept->{ Ztree ztree = new Ztree(); ztree.setId(dept.getDeptId()); ztree.setPId(dept.getParentId()); ztree.setName(dept.getDeptName()); ztree.setTitle(dept.getDeptName()); if (isCheck){ ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); } ztrees.add(ztree); }); } return ztrees; }
Example #7
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 新增保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int insertDept(SysDept dept) { if(dept.getParentId()==0){ dept.setAncestors("0"); return deptMapper.insertDept(dept); }else { SysDept info = deptMapper.selectDeptById(dept.getParentId()); // 如果父节点不为"正常"状态,则不允许新增子节点 if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { throw new BusinessException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); } }
Example #8
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 校验部门名称是否唯一 * * @param dept 部门信息 * @return 结果 */ @Override public String checkDeptNameUnique(SysDept dept) { SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); if (ObjectUtil.isNotNull(info) && !info.getDeptId().equals(dept.getDeptId())) { return UserConstants.DEPT_NAME_NOT_UNIQUE; } return UserConstants.DEPT_NAME_UNIQUE; }
Example #9
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 修改子元素关系 * * @param deptId 部门ID * @param ancestors 元素列表 */ public void updateDeptChildren(Long deptId, String ancestors) { SysDept dept = new SysDept(); dept.setParentId(deptId); List<SysDept> childrens = deptMapper.selectDeptList(dept); for (SysDept children : childrens) { children.setAncestors(ancestors + "," + dept.getParentId()); } if (childrens.size() > 0) { deptMapper.updateDeptChildren(childrens); } }
Example #10
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 修改子元素关系 * * @param deptId 部门 * @param newAncestors 新的父ID集合 * @param oldAncestors 旧的父ID集合 */ private void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) { List<SysDept> children = deptMapper.selectChildrenDeptById(deptId); for (SysDept child : children){ child.setAncestors(child.getAncestors().replace(oldAncestors,newAncestors)); } if (CollectionUtil.isNotEmpty(children)){ deptMapper.updateDeptChildren(children); } }
Example #11
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 修改该部门的父级部门状态 * @param dept 当前部门 */ private void updateParentDeptStatus(SysDept dept) { String updateBy = dept.getUpdateBy(); dept = deptMapper.selectDeptById(dept.getDeptId()); dept.setUpdateBy(updateBy); deptMapper.updateDeptStatus(dept); }
Example #12
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 新增保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int insertDept(SysDept dept) { SysDept info = deptMapper.selectDeptById(dept.getParentId()); //如果父节点不为"正常"状态,则不允许新增子节点 if(!UserConstants.DEPT_NORMAL.equals(info.getStatus())){ throw new BusinessException("上级部门不为正常状态,新增失败!"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); }
Example #13
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 查询部门人数 * * @param parentId 部门ID * @return 结果 */ @Override public int selectDeptCount(Long parentId) { SysDept dept = new SysDept(); dept.setParentId(parentId); return deptMapper.selectDeptCount(dept); }
Example #14
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 根据角色ID查询部门(数据权限) * * @param role 角色对象 * @return 部门列表(数据权限) */ @Override public List<Ztree> roleDeptTreeData(SysRole role) { Long roleId = role.getRoleId(); List<Ztree> ztrees; List<SysDept> deptList = selectDeptList(new SysDept()); if (ObjectUtil.isNotNull(roleId)) { List<String> roleDeptList = deptMapper.selectRoleDeptTree(roleId); ztrees = initZtree(deptList, roleDeptList); } else { ztrees = initZtree(deptList); } return ztrees; }
Example #15
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 查询部门管理树 * * @param dept 部门信息 * @return 所有部门信息 */ @Override @DataScope(deptAlias = "d") public List<Ztree> selectDeptTree(SysDept dept) { List<SysDept> deptList = deptMapper.selectDeptList(dept); List<Ztree> ztrees = initZtree(deptList); return ztrees; }
Example #16
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
/** * 新增部门 */ @GetMapping("/add/{parentId}") public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) { if(parentId == null || parentId == 0){ SysDept dept = new SysDept(); dept.setDeptId(0L); dept.setDeptName("主部门"); mmap.put("dept", dept); }else { mmap.put("dept", deptService.selectDeptById(parentId)); } return prefix + "/add"; }
Example #17
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
/** * 新增保存部门 */ @Log(title = "部门管理", businessType = BusinessType.INSERT) @RequiresPermissions("system:dept:add") @PostMapping("/add") @ResponseBody public AjaxResult addSave(SysDept dept) { dept.setCreateBy(ShiroUtils.getLoginName()); return toAjax(deptService.insertDept(dept)); }
Example #18
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
@RequiresPermissions("system:dept:list") @GetMapping("/listTreeGridData") @ResponseBody public Map listTreeGridData(SysDept dept) { Map retMap = new HashMap(); List<SysDept> deptList = deptService.selectDeptList(dept); retMap.put("msg",""); retMap.put("code",0); retMap.put("data",deptList); retMap.put("count",deptList!=null?deptList.size():0); retMap.put("is",true); retMap.put("tip","操作成功"); return retMap; }
Example #19
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
/** * 校验部门名称 */ @PostMapping("/checkDeptNameUnique") @ResponseBody public String checkDeptNameUnique(SysDept dept) { return deptService.checkDeptNameUnique(dept); }
Example #20
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
@GetMapping("/treeData2") @ResponseBody public Map treeData2() { Map retMap = new HashMap(); List<Map<String, Object>> tree = deptService.selectDeptTree(new SysDept()); tree = EleTreeWrapper.getInstance().getTree(tree,"pId","id"); retMap.put("code",0); retMap.put("data",tree); return retMap; }
Example #21
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
@RequiresPermissions("system:dept:list") @GetMapping("/list") @ResponseBody public List<SysDept> list(SysDept dept) { List<SysDept> deptList = deptService.selectDeptList(dept); return deptList; }
Example #22
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验部门名称是否唯一 * * @param dept 部门信息 * @return 结果 */ @Override public String checkDeptNameUnique(SysDept dept) { Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { return UserConstants.DEPT_NAME_NOT_UNIQUE; } return UserConstants.DEPT_NAME_UNIQUE; }
Example #23
Source File: SysDeptController.java From ruoyiplus with MIT License | 5 votes |
/** * 修改 */ @GetMapping("/edit/{deptId}") public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) { SysDept dept = deptService.selectDeptById(deptId); if (StringUtils.isNotNull(dept) && 100L == deptId) { dept.setParentName("无"); } mmap.put("dept", dept); return prefix + "/edit"; }
Example #24
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 修改该部门的父级部门状态 * * @param dept 当前部门 */ private void updateParentDeptStatus(SysDept dept) { String updateBy = dept.getUpdateBy(); dept = deptMapper.selectDeptById(dept.getDeptId()); dept.setUpdateBy(updateBy); deptMapper.updateDeptStatus(dept); }
Example #25
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 查询部门人数 * * @param parentId 部门ID * @return 结果 */ @Override public int selectDeptCount(Long parentId) { SysDept dept = new SysDept(); dept.setParentId(parentId); return deptMapper.selectDeptCount(dept); }
Example #26
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 对象转部门树 * * @param deptList 部门列表 * @param isCheck 是否需要选中 * @param roleDeptList 角色已存在菜单列表 * @return */ public List<Map<String, Object>> getTrees(List<SysDept> deptList, boolean isCheck, List<String> roleDeptList) { List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); for (SysDept dept : deptList) { if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { Map<String, Object> deptMap = new HashMap<String, Object>(); deptMap.put("id", dept.getDeptId()); 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; }
Example #27
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 查询部门管理树 * * @param dept 部门信息 * @return 所有部门信息 */ @Override @DataScope(tableAlias = "d") public List<Map<String, Object>> selectDeptTree(SysDept dept) { List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<SysDept> deptList = deptMapper.selectDeptList(dept); trees = getTrees(deptList, false, null); return trees; }
Example #28
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 查询部门管理数据 * * @param dept 部门信息 * @return 部门信息集合 */ @Override @DataScope(tableAlias = "d") public List<SysDept> selectDeptList(SysDept dept) { return deptMapper.selectDeptList(dept); }
Example #29
Source File: SysDeptController.java From supplierShop with MIT License | 5 votes |
/** * 加载部门列表树 */ @GetMapping("/treeData") @ResponseBody public List<Ztree> treeData() { List<Ztree> ztrees = deptService.selectDeptTree(new SysDept()); return ztrees; }
Example #30
Source File: SysDeptController.java From supplierShop with MIT License | 5 votes |
/** * 校验部门名称 */ @PostMapping("/checkDeptNameUnique") @ResponseBody public String checkDeptNameUnique(SysDept dept) { return deptService.checkDeptNameUnique(dept); }