<?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="jnpf.cultivate.mapper.FtbCultivateLearnTaskPracticeMapper">

    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO ftb_cultivate_learn_task_practice (
        F_Id,F_TaskId, F_BusinessId, F_Num, F_PhaseId,
        F_CreatorTime, F_CreatorUserId, F_LastModifyTime, F_LastModifyUserId
        )
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.id}, #{item.taskId}, #{item.businessId}, #{item.num}, #{item.phaseId},
            #{item.creatorTime}, #{item.creatorUserId}, #{item.lastModifyTime}, #{item.lastModifyUserId}
            )
        </foreach>
    </insert>

    <!-- 根据任务 ID 查询练习列表（关联技能表，过滤未删除） -->
    <select id="listByTaskId" resultType="jnpf.model.cultivate.v2.task.vo.FtbCultivateLearnTaskPracticeVo">
        SELECT
            a.F_Id AS id,
            a.F_TaskId AS taskId,
            a.F_BusinessId AS businessId,
            a.F_Num AS num,
            a.F_PhaseId AS phaseId,
            s.F_Name AS businessName
        FROM ftb_cultivate_learn_task_practice a
        INNER JOIN ftb_cultivate_teaching_skill s ON a.F_BusinessId = s.F_Id
        WHERE
            a.F_TaskId = #{taskId}
            AND a.F_EnableMark = 0
            AND s.F_DeleteMark = 0
    </select>

    <!-- 根据任务ID和阶段ID查询练习列表（关联技能表，过滤未删除） -->
    <select id="listByTaskIdAndPhaseId" resultType="jnpf.model.cultivate.v2.task.vo.FtbCultivateLearnTaskPracticeVo">
        SELECT
            a.F_Id AS id,
            a.F_TaskId AS taskId,
            a.F_BusinessId AS businessId,
            a.F_Num AS num,
            a.F_PhaseId AS phaseId,
            s.F_Name AS businessName
        FROM ftb_cultivate_learn_task_practice a
        INNER JOIN ftb_cultivate_teaching_skill s ON a.F_BusinessId = s.F_Id
        WHERE
            a.F_TaskId = #{taskId}
            AND a.F_PhaseId = #{phaseId}
            AND a.F_EnableMark = 0
            AND s.F_DeleteMark = 0
    </select>

</mapper>