<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.ctop.toutiao.modules.batch.mapper.BytedanceAreaInfoMapper">

    <select id="getListByParams" resultType="cn.com.ctop.toutiao.modules.batch.vo.BytedanceAreaInfoVO">
        select
            a.id,
            a.name,
            a.code,
            a.parent_code,
            a.level,
            (
                select
                    count(1) from ctop_bytedance_area_info b
                where
                    b.parent_code = a.code
                <if test="level!=null">
                    and b.level &lt;= #{level}
                </if>
            ) as 'hasChild'
        from ctop_bytedance_area_info a
        where 1=1
        <if test="parentCode!=null">
           and a.parent_code = #{parentCode}
        </if>
    </select>
</mapper>
