From fec8d68b40ed8d13af6e2bdfa4aabaa580c8cde0 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Tue, 13 Jul 2021 10:56:58 +0800
Subject: [PATCH] 新增 保安报名培训 curd 接口

---
 src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml |   87 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 86 insertions(+), 1 deletions(-)

diff --git a/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml b/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
index b002fc8..e56bb32 100644
--- a/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -92,12 +92,69 @@
         FROM
             blade_dept dept
         WHERE
-            dept.parent_id = #{param2} AND dept.is_deleted = 0
+            dept.is_deleted = 0
+        <if test="param2!=null and param2!=0">
+            and dept.parent_id = #{param2}
+        </if>
         <if test="param1!=null and param1!=''">
             and dept.tenant_id = #{param1}
         </if>
         ORDER BY dept.sort
     </select>
+
+    <select id="securityLazyTree" resultMap="treeNodeResultMap" >
+        SELECT
+        dept.id,
+        dept.parent_id,
+        dept.dept_name AS title,
+        dept.id AS "value",
+        dept.id AS "key",
+        (
+        SELECT
+        CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
+        FROM
+        blade_dept
+        WHERE
+        parent_id = dept.id and is_deleted = 0
+        ) AS "has_children"
+        FROM
+        blade_dept dept
+        WHERE
+        dept.parent_id = #{param2} AND dept.is_deleted = 0
+        and dept_category = 1
+        <if test="param1!=null and param1!=''">
+            and dept.tenant_id = #{param1}
+        </if>
+        ORDER BY dept.sort
+    </select>
+
+
+
+    <select id="lazyTrees" resultMap="treeNodeResultMap" >
+    SELECT
+        dept.id,
+        dept.parent_id,
+        dept.dept_name AS title,
+        dept.id AS "value",
+        dept.id AS "key",
+        (
+            SELECT
+                CASE WHEN count(1) > 0 THEN 0 ELSE 1 END
+            FROM
+                blade_dept
+            WHERE
+                parent_id = dept.id and is_deleted = 0
+        ) AS "has_children"
+    FROM
+        blade_dept dept WHERE (
+                                  SELECT
+                                      CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
+                                  FROM
+                                      blade_dept
+                                  WHERE
+                                      parent_id = dept.id and is_deleted = 0
+                              ) =1
+</select>
 
     <select id="getDeptNames" resultType="java.lang.String">
         SELECT
@@ -112,4 +169,32 @@
         and is_deleted = 0
     </select>
 
+    <select id="selectIn" resultType="java.util.HashMap">
+        SELECT
+            id,
+            dept_name
+        FROM
+            blade_dept
+    </select>
+
+    <!--统计单位类型数量-->
+    <select id="selectCount" resultType="java.util.HashMap">
+        SELECT dept.id as jurisdiction,dept.dept_name AS title FROM blade_dept dept WHERE  dept.dept_name  like concat(concat('%', #{name}),'%')
+    </select>
+
+    <select id="selectHold" resultType="java.util.HashMap">
+        SELECT
+            ISNULL(B.cz,0) as cz,
+            ISNULL(C.wcz,0) as wcz
+        FROM (SELECT jurisdiction FROM blade_user ) A
+            LEFT JOIN (SELECT COUNT(hold) as cz,jurisdiction FROM blade_user WHERE hold=0 GROUP BY jurisdiction ) B ON A.jurisdiction=B.jurisdiction
+            LEFT JOIN (SELECT COUNT(hold) as wcz,jurisdiction FROM blade_user WHERE hold=1 GROUP BY jurisdiction ) C ON A.jurisdiction=C.jurisdiction
+        WHERE A.jurisdiction=#{deptid} GROUP BY cz,wcz
+    </select>
+
+    <!--查询部门下面的所有单位-->
+    <select id="selectId" resultType="java.util.HashMap">
+        SELECT id FROM blade_dept WHERE parent_id =#{id} and is_deleted = 0
+    </select>
+
 </mapper>

--
Gitblit v1.9.3