<?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.xluobo.business.sys.admin.repo.mapper.ISysDeptMapper">

    <select id="selectUserCampusList" resultType="com.ruoyi.common.core.domain.entity.SysDept">
        select a.* from sys_dept a
        where a.dept_type=#{deptType} and a.delete_flag='0' and a.in_use='1'
          and exists(select 1 from sys_user_dept b where b.user_id=#{userId} and (a.dept_id=b.dept_id or b.dept_id=-1) )
    </select>

    <select id="selectUserDeptInUse" resultType="com.ruoyi.common.core.domain.entity.SysDept">
        select * from sys_dept a, sys_user_dept b
        where a.dept_id=#{deptId} and a.dept_type='2' and a.in_use='1' and a.delete_flag='0'
          and b.user_id=#{userId} and a.dept_id=b.dept_id
    </select>
</mapper>
