<?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.ruoyi.excel.wecom.mapper.CorpDepartmentMapper">

    <resultMap id="CorpDepartmentResult" type="com.ruoyi.excel.wecom.domain.CorpDepartment">
        <id property="id" column="id"/>
        <result property="corpId" column="corp_id"/>
        <result property="parentid" column="parentid"/>
        <result property="orderNo" column="order_no"/>
        <result property="name" column="name"/>
    </resultMap>

    <select id="selectCorpDepartmentList" parameterType="com.ruoyi.excel.wecom.dto.CorpDepartmentDTO" resultMap="CorpDepartmentResult">
        SELECT id, corp_id, parentid, order_no, name
        FROM corp_department
        <where>
            <if test="dto.corpId != null and dto.corpId != ''">
                AND corp_id = #{dto.corpId}
            </if>
            <if test="dto.name != null and dto.name != ''">
                AND name LIKE CONCAT('%', #{dto.name}, '%')
            </if>
        </where>
        ORDER BY order_no ASC, id ASC
    </select>

</mapper>
