From 138b66240b4d4b2b9208fa8a083bb316d67c546b Mon Sep 17 00:00:00 2001 From: 21819 Date: Mon, 4 Mar 2024 09:49:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=9C=BA=E6=9E=84=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=A0=91=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/biutag/lan/DeptTreeTreeBuild.java | 29 +++++++++---------- .../java/com/biutag/lan/entity/TmpDept.java | 1 - .../com/biutag/lan/mapper/TmpDeptMapper.java | 2 ++ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mailbox-lan/src/test/java/com/biutag/lan/DeptTreeTreeBuild.java b/mailbox-lan/src/test/java/com/biutag/lan/DeptTreeTreeBuild.java index 5659e2e..804226f 100644 --- a/mailbox-lan/src/test/java/com/biutag/lan/DeptTreeTreeBuild.java +++ b/mailbox-lan/src/test/java/com/biutag/lan/DeptTreeTreeBuild.java @@ -4,51 +4,50 @@ package com.biutag.lan; import com.alibaba.excel.EasyExcel; import com.biutag.lan.entity.DeptTree; import com.biutag.lan.entity.DeptNode; -import com.biutag.lan.mapper.DeptTreeMapper; +import com.biutag.lan.entity.TmpDept; +import com.biutag.lan.mapper.TmpDeptMapper; import jakarta.annotation.Resource; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; @SpringBootTest public class DeptTreeTreeBuild { @Resource - private DeptTreeMapper deptTreeMapper; + private TmpDeptMapper tmpDeptMapper; private List processedNodes = new ArrayList<>(); public List tree() { - List list = deptTreeMapper.selectList(null); + List list = tmpDeptMapper.selectList(null); return buildTree(list); } - private List buildTree(List list) { + private List buildTree(List list) { List threeNode = list.stream() .filter(item -> item.getLevel() == 3) .map(item -> new DeptNode() - .setCategory(item.getCategory()) + .setCategory(item.getDeptType()) .setLevel(3) .setId(item.getId()) .setPid(item.getPid()) - .setName(item.getName()) - .setFullName(item.getFullName()) + .setName(item.getThird()) + .setFullName(item.getDeptFullName()) ) .collect(Collectors.toList()); // 二级 List secondNode = list.stream() .filter(item -> item.getLevel() == 2) .map(item -> new DeptNode() - .setCategory(item.getCategory()) + .setCategory(item.getDeptType()) .setLevel(2) .setId(item.getId()) .setPid(item.getPid()) - .setName(item.getName()) - .setFullName(item.getFullName()) + .setName(item.getSecond()) + .setFullName(item.getDeptFullName()) .setChildren(threeNode.stream().filter(node -> item.getId().equals(node.getPid())).collect(Collectors.toList())) ) .collect(Collectors.toList()); @@ -56,12 +55,12 @@ public class DeptTreeTreeBuild { return list.stream() .filter(item -> item.getLevel() == 1) .map(item -> new DeptNode() - .setCategory(item.getCategory()) + .setCategory(item.getDeptType()) .setLevel(1) .setId(item.getId()) .setPid(item.getPid()) - .setName(item.getName()) - .setFullName(item.getFullName()) + .setName(item.getFirst()) + .setFullName(item.getDeptFullName()) .setChildren(secondNode.stream().filter(node -> item.getId().equals(node.getPid())).collect(Collectors.toList())) ) .collect(Collectors.toList()); diff --git a/mailbox-lan/src/test/java/com/biutag/lan/entity/TmpDept.java b/mailbox-lan/src/test/java/com/biutag/lan/entity/TmpDept.java index 58b7032..dbda913 100644 --- a/mailbox-lan/src/test/java/com/biutag/lan/entity/TmpDept.java +++ b/mailbox-lan/src/test/java/com/biutag/lan/entity/TmpDept.java @@ -9,7 +9,6 @@ public class TmpDept { private Integer id; private Integer pid; private Integer level; - private String name; private String deptFullName; private String deptType; private String first; diff --git a/mailbox-lan/src/test/java/com/biutag/lan/mapper/TmpDeptMapper.java b/mailbox-lan/src/test/java/com/biutag/lan/mapper/TmpDeptMapper.java index 3cb9cd4..ad28fd3 100644 --- a/mailbox-lan/src/test/java/com/biutag/lan/mapper/TmpDeptMapper.java +++ b/mailbox-lan/src/test/java/com/biutag/lan/mapper/TmpDeptMapper.java @@ -2,6 +2,8 @@ package com.biutag.lan.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biutag.lan.entity.TmpDept; +import org.apache.ibatis.annotations.Mapper; +@Mapper public interface TmpDeptMapper extends BaseMapper { }