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

    <!-- 作业与导向目标关联列表 -->
    <select id="selectPageList" resultType="homeworkGoalInfoDto">
        select * from homework_goal_info
        <where>
            <if test="homeworkGoalInfo.goalInfoId != null">
                and goal_info_id = #{homeworkGoalInfo.goalInfoId}
            </if>
            <if test="homeworkGoalInfo.homeworkInfoId != null">
                and homework_info_id = #{homeworkGoalInfo.homeworkInfoId}
            </if>
        </where>
        order by id desc
    </select>

    <!-- 根据 ID 查询作业与导向目标关联信息 -->
    <select id="selectHomeworkGoalInfoById" parameterType="int" resultType="com.education.model.entity.HomeworkGoalInfo">
        SELECT * FROM homework_goal_info WHERE id = #{id}
    </select>

    <!-- 根据 ID 更新作业与导向目标关联信息 -->
    <update id="updateHomeworkGoalInfoById" parameterType="com.education.model.entity.HomeworkGoalInfo">
        UPDATE homework_goal_info
        SET goal_info_id = #{goalInfoId},
            homework_info_id = #{homeworkInfoId},
            mark = #{mark},
            sort = #{sort},
            create_date = #{createDate},
            update_date = #{updateDate}
        WHERE id = #{id}
    </update>

    <!-- 根据 ID 删除作业与导向目标关联信息 -->
    <delete id="deleteHomeworkGoalInfoById" parameterType="int">
        DELETE FROM homework_goal_info WHERE id = #{id}
    </delete>

</mapper>