<?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.template.mapper.SmartTeachingMapper">
    <resultMap type="com.template.model.vo.UserSubjectVo" id="smartTeachingMap">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="cardNo" column="card_no"/>
        <result property="subjectId" column="subject_id"/>
        <result property="subjectName" column="subject_name"/>
        <result property="gradeId" column="grade_id"/>
        <result property="gradeName" column="grade_name"/>
        <result property="classId" column="class_id"/>
        <result property="className" column="class_name"/>
    </resultMap>
    <select id="querySmartTeachings" resultType="com.template.model.vo.UserSubjectVo" resultMap="smartTeachingMap">
        select
        st.id,st.user_id,su.card_no,su.name as user_name,
        st.subject_id,ss.name as subject_name,
        st.grade_id,sg.name as grade_name,
        st.class_id,sc.name as class_name
        from smart_teaching st
        left join smart_grade sg on sg.deleted = 0 and sg.id = st.grade_id
        left join smart_subject ss on ss.deleted = 0 and ss.id = st.subject_id
        left join smart_class sc on sc.deleted = 0 and sc.id = st.class_id
        left join smart_user su on su.deleted = 0 and su.id = st.user_id
        where st.deleted = 0
        <if test="userIds != null and userIds.size() > 0">
            and st.user_id in
            <foreach collection="userIds" item="userId" index="index" open="(" close=")" separator=",">
                ${userId}
            </foreach>
        </if>
    </select>
</mapper>
