zhongrj
2023-12-28 daef9edffb73d542ff1eba4beb215ffc7b306254
src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
@@ -102,4 +102,42 @@
        SELECT * FROM blade_region ${ew.customSqlSegment}
    </select>
    <!--根据父编号查询所有的下级-->
    <select id="getTreeList" resultType="org.springblade.common.node.TreeStringNode">
        SELECT
        code as id,
        parent_code as parentId,
        name
        FROM blade_region where district_code = '361102'
        <if test="parentCode!=null">
            and parent_code = #{parentCode}
        </if>
        <if test="regionCode!=null and regionCode!=''">
            and code like concat('%',#{regionCode},'%')
        </if>
    </select>
    <!--根据当前编号查询-->
    <select id="getTownTree" resultType="org.springblade.common.node.TreeStringNode">
        SELECT
        code as id,
        parent_code as parentId,
        name
        FROM blade_region where district_code = '361102'
        and region_level = 4
        <if test="regionCode!=null  and regionCode!=''">
            and code = #{regionCode}
        </if>
        union
        SELECT
        code as id,
        parent_code as parentId,
        name
        FROM blade_region where district_code = '361102'
        and region_level = 4
        <if test="regionCode!=null  and regionCode!=''">
            and parent_code = #{regionCode}
        </if>
    </select>
</mapper>