<?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.zcloud.basic.info.persistence.mapper.DepartmentMapper">

     <select id="listAllTree" resultType="com.zcloud.basic.info.persistence.dataobject.DepartmentDO">
         select d.*
         from department d
                  left join corp_info c on d.corpinfo_id = c.id
         where d.delete_enum = 'FALSE'
         order by c.corp_order, c.create_time desc, d.dep_order, d.create_time desc
    </select>
    <select id="selectDeptPage" resultType="com.zcloud.basic.info.persistence.dataobject.DepartmentDO">
        SELECT *
        FROM department
                 ${ew.customSqlSegment}
    </select>
    <select id="listAllTreeByCorpType" resultType="com.zcloud.basic.info.persistence.dataobject.DepartmentDO">
        select d.*
        from department d
        left join corp_info c on d.corpinfo_id = c.id
        where d.delete_enum = 'FALSE'
        and c.delete_enum = 'FALSE'
        <if test="inType != null and inType.size() > 0">
            and c.type in
            <foreach collection="inType" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        order by c.corp_order, c.create_time desc,d.dep_order, d.create_time desc
    </select>
</mapper>

