瀏覽代碼

feat: 组织架构查询以及模糊搜索功能

zhaomuran 7 月之前
父節點
當前提交
5a9e735e95

+ 3 - 3
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/manager/FrameworkServiceImpl.java

@@ -57,7 +57,7 @@ public class FrameworkServiceImpl implements IFrameworkService {
             // 查询选中节点下的人员
             employeeDOS = pRepository.supportsFrameworkQuery(qry);
             // 查询此节点下面的所有子节点,然后利用所有子节点的id去查询所有子节点下的人员
-            List<DepartmentDTO> departmentDTOS = departmentDTOS = dRepository.supportsDepartmentQueryByParentId(qry.getParentId());
+            List<DepartmentDTO> departmentDTOS = departmentDTOS = dRepository.supportsDepartmentQuery(qry);
             // 使用 Stream 提取部门 id 到新的 List<Long> 集合(根据 id 实际类型调整泛型)
             List<Long> departmentIds = departmentDTOS.stream()
                     .map(DepartmentDTO::getDepartmentId)
@@ -107,7 +107,7 @@ public class FrameworkServiceImpl implements IFrameworkService {
         // 返回true
         if (qry.getInclude()){
             // 查询此节点下面的所有子节点
-            departmentDTOS = dRepository.supportsDepartmentQueryByParentId(qry.getParentId());
+            departmentDTOS = dRepository.supportsDepartmentQuery(qry);
             // 使用 Stream 提取部门 id 到新的 List<Long> 集合(根据 id 实际类型调整泛型)
             List<Long> departmentIds = departmentDTOS.stream()
                     .map(DepartmentDTO::getDepartmentId)
@@ -116,7 +116,7 @@ public class FrameworkServiceImpl implements IFrameworkService {
             departmentDTOS.addAll(departmentDTOSChild);
         }else {
             // 返回false,直接查询选中节点下的人员/组织/岗位/群组
-            departmentDTOS = dRepository.supportsDepartmentQueryByParentId(qry.getParentId());
+            departmentDTOS = dRepository.supportsDepartmentQuery(qry);
         }
         // 检测数据是否存在
         if (!Objects.nonNull(departmentDTOS) || departmentDTOS.isEmpty()){

+ 3 - 10
bound-link-api/blink-backend/src/main/java/com/wx/blink/backend/repository/DepartmentRepository.java

@@ -3,6 +3,7 @@ package com.wx.blink.backend.repository;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.wx.blink.backend.domain.dataobject.DepartmentDO;
 import com.wx.blink.backend.domain.dto.DepartmentDTO;
+import com.wx.blink.backend.domain.qry.FrameworkQry;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -12,21 +13,13 @@ import java.util.Set;
 @Mapper
 public interface DepartmentRepository extends BaseMapper<DepartmentDO> {
 
-    /**
-     * 查询部门(根据departmentId)
-     *
-     * @param departmentId
-     * @return
-     */
-    DepartmentDTO supportsDepartmentQueryByDepartmentId(@Param("departmentId") Long departmentId);
-
     /**
      * 查询部门(根据parentId)
      *
-     * @param parentId
+     * @param qry
      * @return
      */
-    List<DepartmentDTO> supportsDepartmentQueryByParentId(@Param("parentId") Long parentId);
+    List<DepartmentDTO> supportsDepartmentQuery(@Param("query") FrameworkQry qry);
 
     /**
      * 查询部门(根据departmentIds)

+ 9 - 16
bound-link-api/blink-backend/src/main/resources/mapper/DepartmentRepositoryMapper.xml

@@ -2,27 +2,20 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.wx.blink.backend.repository.DepartmentRepository">
 
-    <!--    查询部门(根据departmentId)-->
-    <select id="supportsDepartmentQueryByDepartmentId" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
+    <!--    查询部门-->
+    <select id="supportsDepartmentQuery" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
         select *
         from mate_department
-        where 1 = 1
-        <if test="departmentId != null and departmentId != ''">
-            AND department_id = #{departmentId}
+        where
+        <if test="query.parentId != null and query.parentId != ''">
+            parent_id = #{query.parentId}
         </if>
-    </select>
-
-    <!--    查询部门(根据parentId)-->
-    <select id="supportsDepartmentQueryByParentId" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
-        select *
-        from mate_department
-        where 1 = 1
-        <if test="parentId != null and parentId != ''">
-            AND parent_id = #{parentId}
+        <if test="query.keyword != null and query.keyword != ''">
+            name LIKE CONCAT('%', #{query.keyword}, '%')
         </if>
     </select>
 
-    <!--    查询部门(根据id)-->
+    <!--    查询部门(根据departmentIds)-->
     <select id="supportsDepartmentQueryByDepartmentIds" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
         select *
         from mate_department
@@ -32,7 +25,7 @@
         </foreach>
     </select>
 
-    <!--    查询部门(根据ids)-->
+    <!--    查询部门(根据parentIds)-->
     <select id="supportsDepartmentQueryByParentIds" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
         select *
         from mate_department

+ 0 - 20
bound-link-api/blink-backend/src/main/resources/mapper/PersonnelRepositoryMapper.xml

@@ -18,26 +18,6 @@
         order by create_time desc
     </select>
 
-<!--    查询部门(根据parentId)-->
-    <select id="supportsDepartmentQueryByParentId" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
-        select *
-        from mate_department
-        where 1 = 1
-        <if test="parentId != null and parentId != ''">
-            AND parent_id = #{parentId}
-        </if>
-    </select>
-
-    <!--    查询部门(根据id)-->
-    <select id="supportsDepartmentQueryByDepartmentIds" resultType="com.wx.blink.backend.domain.dto.DepartmentDTO">
-        select *
-        from mate_department
-        where department_id IN
-        <foreach collection="departmentIds" item="departmentId" open="(" separator="," close=")">
-            #{departmentId}
-        </foreach>
-    </select>
-
 <!--    查询人员(根据parentIds)-->
     <select id="supportsEmployeeQueryByDepartmentIds" resultType="com.wx.blink.backend.domain.dataobject.PersonnelDO">
         select *