<?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.common.mapper.SysDepartMapper">

    <select id="getDepartByParams" resultType="org.jeecg.common.system.entity.SysDepart">
        select
               *
        from
        `jeecg-boot`.sys_depart
        where
              1=1
              <if test="orgType!=null">
                  and org_type=#{orgType}
              </if>
        and
              leader_id = #{userId}
        order by id desc limit 1
    </select>

    <select id="getAllUserIdsByDepId" resultType="String">
        SELECT user_id FROM `jeecg-boot`.sys_user_depart WHERE dep_id IN (
            select id
            from `jeecg-boot`.sys_depart
            where del_flag = '0'
              and org_code like concat((select org_code from `jeecg-boot`.sys_depart where id = #{departId}), '%')
        )
    </select>
</mapper>
