<?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.SmartTemplateRuleMapper">

    <resultMap type="com.template.model.vo.TemplateRuleVo" id="templateRuleMap">
        <result property="gradeId" column="grade_id"/>
        <result property="termId" column="term_id"/>
        <result property="level" column="level"/>
        <result property="scoreRange" column="score_range"/>
        <result property="examType" column="exam_type"/>
    </resultMap>

    <select id="queryTemplateRuleByIds" resultType="com.template.model.vo.TemplateRuleVo" resultMap="templateRuleMap">
        select sst.grade_id,sst.term_id,str.`level`,str.score_range,sst.exam_type from smart_template_rule str
        inner join smart_subject_template sst on sst.grade_id in
        <foreach collection="gradeIds" item="gradeId" index="index" open="(" close=")" separator=",">
            ${gradeId}
        </foreach>
        and sst.term_id in
        <foreach collection="termIds" item="termId" index="index" open="(" close=")" separator=",">
            ${termId}
        </foreach>
        and sst.id = str.template_id and sst.deleted = 0
        where sst.deleted = 0
    </select>

</mapper>
