<?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.wisenergy.mapper.WorkUserDeptMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkUserDept">
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="dept_id" property="deptId" />
    </resultMap>

    <sql id="table">
        work_user_dept
    </sql>

    <sql id="cols_all">
        id, <include refid="cols_exclude_id"/>
    </sql>

    <sql id="cols_exclude_id">
        user_id, dept_id
    </sql>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, user_id, dept_id
    </sql>

    <select id="listByDeptIdAndStatus" resultType="integer" parameterType="integer">
        select user_id
        from work_user_dept ud join work_user u on ud.user_id = u.id
        where ud.dept_id = #{deptId} and u.`status` = 1
    </select>

</mapper>
