<?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.zehong.system.mapper.ProcessCalibrationResultHistoryMapper">
    
    <resultMap type="ProcessCalibrationResultHistory" id="ProcessCalibrationResultHistoryResult">
        <result property="id"    column="f_id"    />
        <result property="createTime"    column="f_create_time"    />
        <result property="message"    column="f_message"    />
    </resultMap>

    <sql id="selectProcessCalibrationResultHistoryVo">
        select f_id, f_create_time, f_message from t_process_calibration_result_history
    </sql>

    <select id="selectProcessCalibrationResultHistoryList" parameterType="ProcessCalibrationResultHistory" resultMap="ProcessCalibrationResultHistoryResult">
        <include refid="selectProcessCalibrationResultHistoryVo"/>
        <where>
            <if test="message != null  and message != ''"> and f_message like concat ('%',  #{message}, '%')</if>
        </where>
        order by f_id desc
    </select>
    
    <select id="selectProcessCalibrationResultHistoryById" parameterType="Long" resultMap="ProcessCalibrationResultHistoryResult">
        <include refid="selectProcessCalibrationResultHistoryVo"/>
        where f_id = #{id}
    </select>
        
    <insert id="insertProcessCalibrationResultHistory" parameterType="ProcessCalibrationResultHistory" useGeneratedKeys="true" keyProperty="id">
        insert into t_process_calibration_result_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="createTime != null">f_create_time,</if>
            <if test="message != null">f_message,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createTime != null">#{createTime},</if>
            <if test="message != null">#{message},</if>
         </trim>
    </insert>

    <update id="updateProcessCalibrationResultHistory" parameterType="ProcessCalibrationResultHistory">
        update t_process_calibration_result_history
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">f_create_time = #{createTime},</if>
            <if test="message != null">f_message = #{message},</if>
        </trim>
        where f_id = #{id}
    </update>

    <delete id="deleteProcessCalibrationResultHistoryById" parameterType="Long">
        delete from t_process_calibration_result_history where f_id = #{id}
    </delete>

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