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

    <!-- 环节模板列表 -->
    <select id="selectPageList"  resultType="com.education.model.entity.StepModel">
        select * from step_model
        <where>
            <if test="stepModel.name != null and stepModel.name != ''">
                <bind name="name" value="'%' + stepModel.name + '%'"/>
                and name like #{name}
            </if>
            <if test="stepModel.agentId != null">
                and agentid = #{stepModel.agentId}
            </if>
        </where>
        order by id desc
    </select>

    <!-- 根据 ID 查询环节模板 -->
    <select id="selectStepModelById" parameterType="int" resultType="com.education.model.entity.StepModel">
        SELECT * FROM step_model WHERE id = #{id}
    </select>


    <!-- 根据 ID 更新环节模板 -->
    <update id="updateStepModelById" parameterType="com.education.model.entity.StepModel">
        UPDATE step_model
        SET name = #{name},
            prompt = #{prompt},
            agentid = #{agentid},
            reserve = #{reserve},
            create_date = #{createDate},
            update_date = #{updateDate}
        WHERE id = #{id}
    </update>

    <!-- 根据 ID 删除环节模板 -->
    <delete id="deleteStepModelById" parameterType="int">
        DELETE FROM step_model WHERE id = #{id}
    </delete>

</mapper>