<?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.ssj.service.mapper.RecordQuestionMapper">
    <update id="updateQuestionNum">
        update tb_test_question
        set question_num = question_num - #{step}
        where type = #{openTestQuestion.type}
          and grade = #{openTestQuestion.grade}
          and subject = #{openTestQuestion.subject}
          and version = #{openTestQuestion.version}
          and unit = #{openTestQuestion.unit}
          and question_num > #{openTestQuestion.questionNum}
          and update_version > -1
    </update>

    <select id="findZtKnowledgeList" resultType="com.ssj.bean.mybatis.KnowledgeMBDto" parameterType="java.util.Map">
        select distinct (t1.alias) name,t1.two_module module
        from zyb_know_how_details_sort t1
        where t1.course_name = '语文'
        and exists(
            select 1 from zyb_know_how_details t2 where t1.how_id = t2.how_id and t2.is_zt = 1
        )
        and t1.stat=2
        and t1.grade = #{map.grade}
        and t1.semester = #{map.semester}
        and t1.type = 2
        order by t1.two_module,t1.alias
    </select>

    <select id="findKnowledgeList" resultType="com.ssj.bean.mybatis.KnowledgeMBDto" parameterType="java.util.Map">
        select distinct t.alias name
        from zyb_know_how_details_sort t
        where t.stat=2
        <if test="map.subject != null and map.subject != '' ">
            and t.course_name = #{map.subject}
        </if>
        <if test="map.version != null and map.version != '' ">
            and t.type = #{map.version}
        </if>
        <if test="map.semester != null and map.semester != '' ">
            and t.semester = #{map.semester}
        </if>
        <if test="map.howIds.size() > 0">
            and t.how_id in
            <foreach collection="map.howIds" index="i" item="howId" open="(" close=")" separator=",">
                #{howId}
            </foreach>
        </if>
        order by t.num
    </select>
</mapper>