From 3721eea476d9dad0a5838b3aa89a30a8b4640f7d Mon Sep 17 00:00:00 2001
From: xusd <hugeinfo123>
Date: Mon, 14 Oct 2024 17:40:33 +0800
Subject: [PATCH] 网格登录对接

---
 dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/dao/mapper/xml/CtUnitMapper.xml |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/dao/mapper/xml/CtUnitMapper.xml b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/dao/mapper/xml/CtUnitMapper.xml
index 00e5dba..bba5a73 100644
--- a/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/dao/mapper/xml/CtUnitMapper.xml
+++ b/dyh-service/dyh-cust/src/main/java/cn/huge/module/ctuser/dao/mapper/xml/CtUnitMapper.xml
@@ -351,4 +351,45 @@
         set target_unit_name = #{unitName}
         where target_unit_id = #{unitId}
     </update>
+
+    <!-- 查询某一单位下下一级所有管辖单位-->
+    <select id="listAllChild" resultMap="dataResult">
+        WITH RECURSIVE unit_hierarchy(id, parent_id, name) AS (
+        -- 锚成员 (起始点)
+        SELECT
+        id ,
+        parent_id,
+        unit_name
+        FROM
+        dyh_ct_unit
+        WHERE
+        id = #{unitId}
+
+        UNION ALL
+
+        -- 递归成员
+        SELECT
+        u.id,
+        u.parent_id,
+        u.unit_name
+        FROM
+        dyh_ct_unit u
+        JOIN
+        unit_hierarchy h ON u.parent_id = h.id where u.delete_status = 0
+        )
+        SELECT
+        id AS id,
+        parent_id AS parent_id,
+        name AS unit_name
+        FROM
+        unit_hierarchy;
+    </select>
+
+    <!--  根据条件分页查询  -->
+    <select id="selectUnitByGridId" resultMap="dataResult">
+        SELECT
+            t1.*
+        FROM dyh_ct_unit t1 left join dyh_ct_unit_grid t2 on t1.id = t2.dyh_unit_id
+        where t2.third_unit_id = #{gridUnitId} limit 1
+    </select>
 </mapper> 
\ No newline at end of file

--
Gitblit v1.8.0