From 9f19d3a24f8474bf6f9eb9401888c44b34b381e6 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 十一月 2024 14:29:50 +0800
Subject: [PATCH] 第一次改动(检验任务与样品关联,附件与样品关联,报告与样品关联)

---
 cnas-server/src/main/resources/mapper/DepartmentMapper.xml |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/cnas-server/src/main/resources/mapper/DepartmentMapper.xml b/cnas-server/src/main/resources/mapper/DepartmentMapper.xml
index 87ba206..463e3ba 100644
--- a/cnas-server/src/main/resources/mapper/DepartmentMapper.xml
+++ b/cnas-server/src/main/resources/mapper/DepartmentMapper.xml
@@ -1,19 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.yuanchu.mom.mapper.DepartmentMapper">
-    <select id="selectDepartment" resultType="com.yuanchu.mom.pojo.Department">
-        WITH RECURSIVE DepartmentHierarchy AS (
-            SELECT id, name, father_id
-            FROM department
-            WHERE father_id IS NULL
-
-            UNION ALL
-
-            SELECT d.id, d.name, d.father_id
-            FROM department d
-                     JOIN DepartmentHierarchy dh ON d.father_id = dh.id
-        )
+    <select id="selectDepartment" resultType="com.yuanchu.mom.dto.DepartmentDto">
         SELECT id, name, father_id
-        FROM DepartmentHierarchy;
+        FROM department
+    </select>
+
+    <select id="selectSonById" resultType="java.lang.Integer">
+        SELECT au.id
+        FROM (SELECT * FROM department WHERE father_id IS NOT NULL) au,
+             (SELECT @father_id := #{id}) pd
+        WHERE FIND_IN_SET(father_id, @father_id) > 0
+                  AND @father_id := concat(@father_id, ',', id)
+        UNION
+        SELECT id
+        FROM department
+        WHERE id = #{id}
+        ORDER BY id
+    </select>
+    <select id="selectCustomList" resultType="com.yuanchu.mom.dto.DepartmentDto">
+        select id, name, category fatherId from role;
     </select>
 </mapper>

--
Gitblit v1.9.3