|
@@ -1,16 +1,17 @@
|
|
|
package com.fire.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fire.admin.dto.DeptDTO;
|
|
|
-
|
|
|
import com.fire.admin.mapper.SysDeptMapper;
|
|
|
import com.fire.admin.service.ISysDeptService;
|
|
|
import com.fire.admin.util.PreUtil;
|
|
|
import com.fire.admin.vo.DeptTreeVo;
|
|
|
import com.fire.dto.system.SysDept;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -28,46 +29,51 @@ import java.util.stream.Collectors;
|
|
|
* @create: 2020-08-26 15:45
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService {
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 查询部门信息
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:34
|
|
|
+ * @Description: TODO 查询部门信息
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:34
|
|
|
*/
|
|
|
@Override
|
|
|
public List<SysDept> selectDeptList() {
|
|
|
List<SysDept> depts = baseMapper.selectList(Wrappers.<SysDept>lambdaQuery().select(SysDept::getDeptId, SysDept::getName, SysDept::getParentId, SysDept::getSort, SysDept::getCreateTime));
|
|
|
- List<SysDept> sysDepts = depts.stream().filter(sysDept -> sysDept.getParentId() .equals(0L) || ObjectUtil.isNull(sysDept.getParentId())).peek(sysDept -> sysDept.setLevel(0)).collect(Collectors.toList());
|
|
|
+ depts.forEach(dep -> {
|
|
|
+ });
|
|
|
+ List<SysDept> sysDepts = depts.stream().filter(sysDept -> sysDept.getParentId().equals(4) || ObjectUtil.isNull(sysDept.getParentId())).peek(sysDept -> sysDept.setLevel(0)).collect(Collectors.toList());
|
|
|
PreUtil.findChildren(sysDepts, depts);
|
|
|
return sysDepts;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 更新部门
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:35
|
|
|
+ * @Description: TODO 更新部门
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:35
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean updateDeptById(DeptDTO entity) {
|
|
|
+ log.info("部门修改传递参数为:【{}】", entity.toString());
|
|
|
SysDept sysDept = new SysDept();
|
|
|
- BeanUtils.copyProperties(entity, sysDept);
|
|
|
+ BeanUtil.copyProperties(entity, sysDept);
|
|
|
sysDept.setUpdateTime(LocalDateTime.now());
|
|
|
+ log.info("部门修改信息为:【{}】", sysDept.toString());
|
|
|
return this.updateById(sysDept);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 删除部门
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:35
|
|
|
+ * @Description: TODO 删除部门
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:35
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@@ -76,15 +82,16 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
List<Long> idList = this.list(Wrappers.<SysDept>query().lambda().eq(SysDept::getParentId, id)).stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
|
|
// 删除自己
|
|
|
idList.add((Long) id);
|
|
|
+ log.info("删除部门编号为:【{}】", JSONUtil.parseArray(idList));
|
|
|
return super.removeByIds(idList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 根据部门id查询部门名称
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:35
|
|
|
+ * @Description: TODO 根据部门id查询部门名称
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:35
|
|
|
*/
|
|
|
@Override
|
|
|
public String selectDeptNameByDeptId(Long deptId) {
|
|
@@ -92,11 +99,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 根据部门名称查询
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:35
|
|
|
+ * @Description: TODO 根据部门名称查询
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:35
|
|
|
*/
|
|
|
@Override
|
|
|
public List<SysDept> selectDeptListBydeptName(String deptName) {
|
|
@@ -104,11 +111,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 通过此部门id查询于此相关的部门ids
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:35
|
|
|
+ * @Description: TODO 通过此部门id查询于此相关的部门ids
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:35
|
|
|
*/
|
|
|
@Override
|
|
|
public List<Long> selectDeptIds(Long deptId) {
|
|
@@ -122,35 +129,33 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 获取部门树
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:35
|
|
|
+ * @Description: TODO 获取部门树
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:35
|
|
|
*/
|
|
|
@Override
|
|
|
public List<DeptTreeVo> getDeptTree() {
|
|
|
List<SysDept> depts = baseMapper.selectList(Wrappers.<SysDept>query().select("dept_id", "name", "parent_id", "sort", "create_time"));
|
|
|
- List<DeptTreeVo> collect = depts.stream().filter(sysDept -> sysDept.getParentId() .equals(0L) || ObjectUtil.isNull(sysDept.getParentId())).map(sysDept -> {
|
|
|
+ List<DeptTreeVo> collect = depts.stream().filter(sysDept -> sysDept.getParentId().equals(4) || ObjectUtil.isNull(sysDept.getParentId())).map(sysDept -> {
|
|
|
DeptTreeVo deptTreeVo = new DeptTreeVo();
|
|
|
deptTreeVo.setId(sysDept.getDeptId());
|
|
|
deptTreeVo.setLabel(sysDept.getName());
|
|
|
return deptTreeVo;
|
|
|
-
|
|
|
}).collect(Collectors.toList());
|
|
|
-
|
|
|
PreUtil.findChildren1(collect, depts);
|
|
|
return collect;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- *@Description: TODO 根据部门ID获取该部门及其下属部门树
|
|
|
- *@Param:
|
|
|
- *@return:
|
|
|
- *@Author: liu liu
|
|
|
- *@date: 2020/8/31 15:37
|
|
|
- */
|
|
|
+ * @Description: TODO 根据部门ID获取该部门及其下属部门树
|
|
|
+ * @Param:
|
|
|
+ * @return:
|
|
|
+ * @Author: liu liu
|
|
|
+ * @date: 2020/8/31 15:37
|
|
|
+ */
|
|
|
private SysDept getDepartment(Long deptId) {
|
|
|
List<SysDept> departments = baseMapper.selectList(Wrappers.<SysDept>query().select("dept_id", "name", "parent_id", "sort", "create_time"));
|
|
|
Map<Long, SysDept> map = departments.stream().collect(Collectors.toMap(SysDept::getDeptId, department -> department));
|