linwei
2024-01-08 ad2ec97fe0c60eee4bb7c8cdacff7c876f280ea7
src/main/java/org/springblade/modules/system/mapper/RegionMapper.xml
@@ -102,4 +102,63 @@
        SELECT * FROM blade_region ${ew.customSqlSegment}
    </select>
    <!--根据父编号查询所有的下级-->
    <select id="getTreeList" resultType="org.springblade.common.node.TreeStringNode">
        <if test="region.cityCode!=null and region.cityCode!=''">
            SELECT
            code as id,
            parent_code as parentId,
            name
            FROM blade_region
            where code = #{region.cityCode}
            union all
        </if>
        SELECT
        code as id,
        parent_code as parentId,
        name
        FROM blade_region
        where 1=1
        and district_code = '361102'
        <if test="region.parentCode!=null and region.parentCode!=''">
            and parent_code = #{region.parentCode}
        </if>
        <if test="region.regionCode!=null and region.regionCode!=''">
            and code like concat('%',#{region.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>
    <!--树列表(包含省市县三级)-->
    <select id="getBaseTree" resultType="org.springblade.common.node.TreeStringNode">
        SELECT
        code as id,
        parent_code as parentId,
        name
        FROM blade_region
        where region_level >0 and region_level &lt;4
    </select>
</mapper>