<?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.ruoyi.postCheck.mapper.PostProgrammeTemplateMapper">
    
    <resultMap type="PostProgrammeTemplate" id="PostProgrammeTemplateResult">
        <result property="id"    column="id"    />
        <result property="planName"    column="plan_name"    />
        <result property="templateName"    column="template_name"    />
        <result property="diskPath"    column="disk_path"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createUserId"    column="create_user_id"    />
    </resultMap>

    <sql id="selectPostProgrammeTemplateVo">
        select id, plan_name, template_name, disk_path, status, remark, del_flag, create_time, create_by, update_time, update_by, create_user_id from post_programme_template
    </sql>

    <select id="selectPostProgrammeTemplateList" parameterType="PostProgrammeTemplate" resultMap="PostProgrammeTemplateResult">
        <include refid="selectPostProgrammeTemplateVo"/>
        <where>  
            <if test="planName != null  and planName != ''"> and plan_name like concat('%', #{planName}, '%')</if>
            <if test="templateName != null  and templateName != ''"> and template_name like concat('%', #{templateName}, '%')</if>
            <if test="diskPath != null  and diskPath != ''"> and disk_path = #{diskPath}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createUserId != null "> and create_user_id = #{createUserId}</if>
        </where>
    </select>
    
    <select id="selectPostProgrammeTemplateById" parameterType="Long" resultMap="PostProgrammeTemplateResult">
        <include refid="selectPostProgrammeTemplateVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPostProgrammeTemplate" parameterType="PostProgrammeTemplate">
        insert into post_programme_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="planName != null and planName != ''">plan_name,</if>
            <if test="templateName != null and templateName != ''">template_name,</if>
            <if test="diskPath != null and diskPath != ''">disk_path,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="createUserId != null">create_user_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="planName != null and planName != ''">#{planName},</if>
            <if test="templateName != null and templateName != ''">#{templateName},</if>
            <if test="diskPath != null and diskPath != ''">#{diskPath},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="createUserId != null">#{createUserId},</if>
         </trim>
    </insert>

    <update id="updatePostProgrammeTemplate" parameterType="PostProgrammeTemplate">
        update post_programme_template
        <trim prefix="SET" suffixOverrides=",">
            <if test="planName != null and planName != ''">plan_name = #{planName},</if>
            <if test="templateName != null and templateName != ''">template_name = #{templateName},</if>
            <if test="diskPath != null and diskPath != ''">disk_path = #{diskPath},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="createUserId != null">create_user_id = #{createUserId},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePostProgrammeTemplateById" parameterType="Long">
        delete from post_programme_template where id = #{id}
    </delete>

    <delete id="deletePostProgrammeTemplateByIds" parameterType="String">
        delete from post_programme_template where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>