<?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="org.springblade.modules.baseinfo.region.mapper.OrgRegionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="orgRegionResultMap" type="org.springblade.modules.baseinfo.region.entity.OrgRegionInfoEntity">

        <result column="dept_id" property="deptId"/>
        <result column="adcd" property="adcd"/>
        <result column="adnm" property="adnm"/>
        <result column="parent_code" property="parentCode"/>
        <result column="ancestors" property="ancestors"/>
        <result column="add_type" property="addType"/>
        <result column="rtu_count" property="rtuCount"/>
        <result column="region_active" property="regionActive"/>

    </resultMap>

    <select id="selectList" resultMap="orgRegionResultMap">
        SELECT
        n.*
        FROM
        base_dept_region_cache n
        WHERE
        n.is_deleted = 0
        <if test="dto.deptId != null">
            and n.dept_id = #{dto.deptId}
        </if>
        <if test="dto.adcd != null">
            and n.adcd = #{dto.adcd}
        </if>
        <if test="dto.parentCode != null">
            and n.parent_code =#{dto.parentCode}
        </if>
    </select>
</mapper>
