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

    <!-- 学生作业信息列表 -->
    <select id="selectPageList" resultType="stuHomeworkInfoDto">
        select * from stu_homework_info
        <where>
            <if test="stuHomeworkInfo.studentId != null">
                and student_id = #{stuHomeworkInfo.studentId}
            </if>
            <if test="stuHomeworkInfo.homeworkInfoId != null">
                and homework_info_id = #{stuHomeworkInfo.homeworkInfoId}
            </if>
            <if test="stuHomeworkInfo.correctFlag != null">
                and correct_flag = #{stuHomeworkInfo.correctFlag}
            </if>
        </where>
        order by id desc
    </select>

    <!-- 根据 ID 查询学生作业信息 -->
    <select id="selectStuHomeworkInfoById" parameterType="int" resultType="com.education.model.entity.StuHomeworkInfo">
        SELECT * FROM stu_homework_info WHERE id = #{id}
    </select>

    <!-- 根据 ID 更新学生作业信息 -->
    <update id="updateStuHomeworkInfoById" parameterType="com.education.model.entity.StuHomeworkInfo">
        UPDATE stu_homework_info
        SET student_id = #{studentId},
            homework_info_id = #{homeworkInfoId},
            correct_flag = #{correctFlag},
            mark = #{mark},
            submit_time = #{submitTime},
            teacher_id = #{teacherId},
            create_date = #{createDate},
            update_date = #{updateDate}
        WHERE id = #{id}
    </update>

    <!-- 根据 ID 删除学生作业信息 -->
    <delete id="deleteStuHomeworkInfoById" parameterType="int">
        DELETE FROM stu_homework_info WHERE id = #{id}
    </delete>

</mapper>