linwei
2024-01-24 c0e32b4907e8ac9cae56b77e4f83fefdc8cc5ad3
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -28,12 +28,10 @@
        <result column="has_children" property="hasChildren"/>
    </resultMap>
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
    <resultMap id="treeNodeResultMap" type="org.springblade.modules.system.vo.DeptVO">
        <id column="id" property="id"/>
        <result column="parent_id" property="parentId"/>
        <result column="title" property="title"/>
        <result column="value" property="value"/>
        <result column="key" property="key"/>
        <result column="has_children" property="hasChildren"/>
    </resultMap>
@@ -67,31 +65,32 @@
    </select>
    <select id="tree" resultMap="treeNodeResultMap">
        <if test="param2!=null">
            SELECT
            id,
            dept_name AS title,
            id AS "value",
            id AS "key",
            parent_id
            FROM
            ( SELECT * FROM blade_dept WHERE is_deleted = 0 AND tenant_id = #{param1} ORDER BY parent_id, id )
            org_query,
            ( SELECT @id := #{param2} ) initialisation
            WHERE
            (FIND_IN_SET( parent_id, @id ) > 0 or FIND_IN_SET( id, @id ) > 0)
            AND @id := CONCAT(@id,',',id) ORDER BY sort
        </if>
        <if test="param2==null">
            select id, parent_id, dept_name as title, id as "value", id as "key" from blade_dept where is_deleted = 0
            <if test="param1!=null and param1!=''">
                and tenant_id = #{param1}
            </if>
            ORDER BY sort
        </if>
        SELECT
        a.id,
        a.dept_name AS title,
        a.parent_id,
        b.id,
        IF
        ( b.id > 0, FALSE, TRUE ) disabled
        FROM
        blade_dept a
        LEFT JOIN (
        SELECT
        id,
        dept_name AS title,
        parent_id
        FROM
        ( SELECT * FROM blade_dept WHERE is_deleted = 0 AND tenant_id = #{param1} ORDER BY parent_id, id ) org_query,
        ( SELECT @id := #{param2} ) initialisation
        WHERE
        ( FIND_IN_SET( parent_id, @id ) > 0 OR FIND_IN_SET( id, @id ) > 0 )
        AND @id := CONCAT( @id, ',', id )
        ORDER BY
        sort
        ) b ON a.id = b.id
        WHERE
        is_deleted = 0
        AND tenant_id = #{param1}  ORDER BY a.sort
    </select>
    <select id="lazyTree" resultMap="treeNodeResultMap">
@@ -99,8 +98,6 @@
        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