linwei
2024-01-26 04a0b7a7cae7bee8808bbc3587dddc4f955d204f
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -28,10 +28,12 @@
        <result column="has_children" property="hasChildren"/>
    </resultMap>
    <resultMap id="treeNodeResultMap" type="org.springblade.modules.system.vo.DeptVO">
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
        <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>
@@ -65,32 +67,31 @@
    </select>
    <select id="tree" resultMap="treeNodeResultMap">
        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
        <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>
    <select id="lazyTree" resultMap="treeNodeResultMap">
@@ -98,6 +99,8 @@
        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