<?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="com.boman.web.core.mapper.AdministrativeInfoMapper">

    <resultMap type="AdministrativeInfo" id="AdministrativeInfoResult">
        <result property="id"    column="id"    />
        <result property="parentId"    column="parent_id"    />
        <result property="administrativeName"    column="administrative_name"    />
        <result property="status"    column="status"    />
        <result property="orderNum"    column="order_num"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="ancestors"    column="ancestors"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectAdministrativeInfoVo">
        select d.id,d.parent_id, d.dept_name as administrative_name,d.ancestors as ancestors , d.status, d.create_by, d.create_time, d.update_by, d.update_time from sys_dept d
    </sql>

    <select id="selectAdministrativeInfoList" parameterType="com.boman.web.core.domain.AdministrativeInfo" resultMap="AdministrativeInfoResult">
        <include refid="selectAdministrativeInfoVo"/>
        <where>
            d.del_flag = '0'
        <if test="parentId != null and parentId != 0">
            AND d.parent_id = #{parentId}
        </if>
        <if test="administrativeName != null and administrativeName != ''">
            AND d.dept_name like concat('%', #{administrativeName}, '%')
        </if>
        <if test="status != null and status != ''">
            AND d.status = #{status}
        </if>
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
        order by d.parent_id, d.order_num
    </select>
</mapper>