<?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.ruoyi.learn.mapper.LearnPlanStudyMapper">
    
    <resultMap type="LearnPlanStudy" id="LearnPlanStudyResult">
        <result property="id"    column="id"    />
        <result property="studentId"    column="student_id"    />
        <result property="planId"    column="plan_id"    />
        <result property="monthSeq"    column="month_seq"    />
        <result property="weekSeq"    column="week_seq"    />
        <result property="reportDate"    column="report_date"    />
        <result property="questionCount"    column="question_count"    />
        <result property="videoTime"    column="video_time"    />
        <result property="questionPlan"    column="question_plan"    />
        <result property="videoPlan"    column="video_plan"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectLearnPlanStudyVo">
        select id, student_id, plan_id, month_seq, week_seq, report_date, question_count, video_time, question_plan, video_plan, update_time from learn_plan_study
    </sql>

    <select id="selectLearnPlanStudyList" parameterType="LearnPlanStudy" resultMap="LearnPlanStudyResult">
        <include refid="selectLearnPlanStudyVo"/>
        <where>  
            <if test="studentId != null "> and student_id = #{studentId}</if>
            <if test="planId != null "> and plan_id = #{planId}</if>
            <if test="monthSeq != null "> and month_seq = #{monthSeq}</if>
            <if test="weekSeq != null "> and week_seq = #{weekSeq}</if>
            <if test="reportDate != null "> and report_date = #{reportDate}</if>
            <if test="questionCount != null "> and question_count = #{questionCount}</if>
            <if test="videoTime != null "> and video_time = #{videoTime}</if>
            <if test="questionPlan != null "> and question_plan = #{questionPlan}</if>
            <if test="videoPlan != null "> and video_plan = #{videoPlan}</if>
        </where>
    </select>
    
    <select id="selectLearnPlanStudyById" parameterType="String" resultMap="LearnPlanStudyResult">
        <include refid="selectLearnPlanStudyVo"/>
        where id = #{id}
    </select>

    <insert id="insertLearnPlanStudy" parameterType="LearnPlanStudy" useGeneratedKeys="true" keyProperty="id">
        insert into learn_plan_study
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="studentId != null">student_id,</if>
            <if test="planId != null">plan_id,</if>
            <if test="monthSeq != null">month_seq,</if>
            <if test="weekSeq != null">week_seq,</if>
            <if test="reportDate != null">report_date,</if>
            <if test="questionCount != null">question_count,</if>
            <if test="videoTime != null">video_time,</if>
            <if test="questionPlan != null">question_plan,</if>
            <if test="videoPlan != null">video_plan,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="studentId != null">#{studentId},</if>
            <if test="planId != null">#{planId},</if>
            <if test="monthSeq != null">#{monthSeq},</if>
            <if test="weekSeq != null">#{weekSeq},</if>
            <if test="reportDate != null">#{reportDate},</if>
            <if test="questionCount != null">#{questionCount},</if>
            <if test="videoTime != null">#{videoTime},</if>
            <if test="questionPlan != null">#{questionPlan},</if>
            <if test="videoPlan != null">#{videoPlan},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateLearnPlanStudy" parameterType="LearnPlanStudy">
        update learn_plan_study
        <trim prefix="SET" suffixOverrides=",">
            <if test="studentId != null">student_id = #{studentId},</if>
            <if test="planId != null">plan_id = #{planId},</if>
            <if test="monthSeq != null">month_seq = #{monthSeq},</if>
            <if test="weekSeq != null">week_seq = #{weekSeq},</if>
            <if test="reportDate != null">report_date = #{reportDate},</if>
            <if test="questionCount != null">question_count = #{questionCount},</if>
            <if test="videoTime != null">video_time = #{videoTime},</if>
            <if test="questionPlan != null">question_plan = #{questionPlan},</if>
            <if test="videoPlan != null">video_plan = #{videoPlan},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLearnPlanStudyById" parameterType="String">
        delete from learn_plan_study where id = #{id}
    </delete>

    <delete id="deleteLearnPlanStudyByIds" parameterType="String">
        delete from learn_plan_study where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>