<?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.education.business.mapper.education.StuGoalInfoMapper">

    <!-- 学生导向目标答题记录列表 -->
    <select id="selectPageList" resultType="stuGoalInfoDto">
        select * from stu_goal_info
        <where>
            <if test="stuGoalInfo.studentId != null">
                and student_id = #{stuGoalInfo.studentId}
            </if>
            <if test="stuGoalInfo.homeworkInfoId != null">
                and homework_info_id = #{stuGoalInfo.homeworkInfoId}
            </if>
            <if test="stuGoalInfo.goalInfoId != null">
                and goal_info_id = #{stuGoalInfo.goalInfoId}
            </if>
            <if test="stuGoalInfo.correctStatus != null">
                and correct_status = #{stuGoalInfo.correctStatus}
            </if>
        </where>
        order by id desc
    </select>

    <!-- 根据 ID 查询学生导向目标答题记录 -->
    <select id="selectStuGoalInfoById" parameterType="int" resultType="com.education.model.entity.StuGoalInfo">
        SELECT * FROM stu_goal_info WHERE id = #{id}
    </select>

    <!-- 根据 ID 更新学生导向目标答题记录 -->
    <update id="updateStuGoalInfoById" parameterType="com.education.model.entity.StuGoalInfo">
        UPDATE stu_goal_info
        SET student_id = #{studentId},
            homework_info_id = #{homeworkInfoId},
            goal_info_id = #{goalInfoId},
            goal_mark = #{goalMark},
            correct_status = #{correctStatus},
            p_answer = #{pAnswer},
            p_score = #{pScore},
            s_answer = #{sAnswer},
            s_score = #{sScore},
            r_answer = #{rAnswer},
            r_score = #{rScore},
            e_answer = #{eAnswer},
            e_score = #{eScore},
            n_answer = #{nAnswer},
            n_score = #{nScore},
            comment = #{comment},
            create_date = #{createDate},
            update_date = #{updateDate}
        WHERE id = #{id}
    </update>

    <!-- 根据 ID 删除学生导向目标答题记录 -->
    <delete id="deleteStuGoalInfoById" parameterType="int">
        DELETE FROM stu_goal_info WHERE id = #{id}
    </delete>

</mapper>