linwei
2024-01-24 157b568be6abe0b759ab5cd3dd91ea829841cfa3
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -67,19 +67,31 @@
    </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>
        <if test="param2!=null and param2!=''">
            and parent_id = #{param2}
        </if>
        <if test="param3!=null and param3!=''">
            and id = #{param3}
        </if>
        ORDER BY sort
        </if>
    </select>
    <select id="lazyTree" resultMap="treeNodeResultMap" >