🔖 Releasing / Version tags. 2.7.0 配合前端修改
This commit is contained in:
1 parent
8579f22522
commit
98b851adc2
5 files changed
+13
-80
No files matched your search
-10
@@ -68,16 +68,6 @@ public class DeptController {
|
||||
return new R<>(sysDeptService.selectTree());
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回当前用户树形菜单集合
|
||||
*
|
||||
* @return 树形菜单
|
||||
*/
|
||||
@GetMapping(value = "/user-tree")
|
||||
public R getUserTree() {
|
||||
return new R<>(sysDeptService.getUserTree());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
|
||||
-8
@@ -22,8 +22,6 @@ package com.pig4cloud.pigx.admin.mapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysDept;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 部门管理 Mapper 接口
|
||||
@@ -34,10 +32,4 @@ import java.util.List;
|
||||
*/
|
||||
public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
* 关联dept——relation
|
||||
*
|
||||
* @return 数据列表
|
||||
*/
|
||||
List<SysDept> listDepts();
|
||||
}
|
||||
-7
@@ -42,13 +42,6 @@ public interface SysDeptService extends IService<SysDept> {
|
||||
*/
|
||||
List<DeptTree> selectTree();
|
||||
|
||||
/**
|
||||
* 查询用户部门树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DeptTree> getUserTree();
|
||||
|
||||
/**
|
||||
* 添加信息部门
|
||||
*
|
||||
|
||||
+13
-31
@@ -29,7 +29,6 @@ import com.pig4cloud.pigx.admin.api.vo.TreeUtil;
|
||||
import com.pig4cloud.pigx.admin.mapper.SysDeptMapper;
|
||||
import com.pig4cloud.pigx.admin.service.SysDeptRelationService;
|
||||
import com.pig4cloud.pigx.admin.service.SysDeptService;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -79,11 +78,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
public Boolean removeDeptById(Integer id) {
|
||||
//级联删除部门
|
||||
List<Integer> idList = sysDeptRelationService
|
||||
.list(Wrappers.<SysDeptRelation>query().lambda()
|
||||
.eq(SysDeptRelation::getAncestor, id))
|
||||
.stream()
|
||||
.map(SysDeptRelation::getDescendant)
|
||||
.collect(Collectors.toList());
|
||||
.list(Wrappers.<SysDeptRelation>query().lambda()
|
||||
.eq(SysDeptRelation::getAncestor, id))
|
||||
.stream()
|
||||
.map(SysDeptRelation::getDescendant)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(idList)) {
|
||||
this.removeByIds(idList);
|
||||
@@ -123,23 +122,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
return getDeptTree(this.list(Wrappers.emptyWrapper()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户部门树
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DeptTree> getUserTree() {
|
||||
Integer deptId = SecurityUtils.getUser().getDeptId();
|
||||
List<Integer> descendantIdList = sysDeptRelationService
|
||||
.list(Wrappers.<SysDeptRelation>query().lambda()
|
||||
.eq(SysDeptRelation::getAncestor, deptId))
|
||||
.stream().map(SysDeptRelation::getDescendant)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<SysDept> deptList = baseMapper.selectBatchIds(descendantIdList);
|
||||
return getDeptTree(deptList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建部门树
|
||||
@@ -149,14 +131,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
*/
|
||||
private List<DeptTree> getDeptTree(List<SysDept> depts) {
|
||||
List<DeptTree> treeList = depts.stream()
|
||||
.filter(dept -> !dept.getDeptId().equals(dept.getParentId()))
|
||||
.map(dept -> {
|
||||
DeptTree node = new DeptTree();
|
||||
node.setId(dept.getDeptId());
|
||||
node.setParentId(dept.getParentId());
|
||||
node.setName(dept.getName());
|
||||
return node;
|
||||
}).collect(Collectors.toList());
|
||||
.filter(dept -> !dept.getDeptId().equals(dept.getParentId()))
|
||||
.map(dept -> {
|
||||
DeptTree node = new DeptTree();
|
||||
node.setId(dept.getDeptId());
|
||||
node.setParentId(dept.getParentId());
|
||||
node.setName(dept.getName());
|
||||
return node;
|
||||
}).collect(Collectors.toList());
|
||||
return TreeUtil.build(treeList, 0);
|
||||
}
|
||||
}
|
||||
@@ -21,28 +21,4 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.pig4cloud.pigx.admin.mapper.SysDeptMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.pig4cloud.pigx.admin.api.entity.SysDept">
|
||||
<id column="dept_id" property="deptId"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="sort" property="sort"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="del_flag" property="delFlag"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
dept_id AS deptId, parent_id AS parentId, name, sort, create_time AS createTime, update_time AS updateTime, del_flag AS delFlag
|
||||
</sql>
|
||||
|
||||
<!--关联查询部门列表-->
|
||||
<select id="listDepts" resultType="com.pig4cloud.pigx.admin.api.entity.SysDept">
|
||||
SELECT
|
||||
t.*
|
||||
FROM
|
||||
sys_dept t
|
||||
LEFT JOIN sys_dept_relation dr ON t.dept_id = dr.descendant
|
||||
WHERE dr.ancestor = 0
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user