<?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.traceability.mapper.ProLogrecordMapper">
    
    <resultMap type="ProLogrecord" id="ProLogrecordResult">
        <result property="id"    column="id"    />
        <result property="resource"    column="resource"    />
        <result property="positionId"    column="position_id"    />
        <result property="message"    column="message"    />
        <result property="recordTime"    column="record_time"    />
    </resultMap>

    <sql id="selectProLogrecordVo">
        select id, resource, position_id, message, record_time from pro_logrecord
    </sql>

    <select id="selectProLogrecordList" parameterType="ProLogrecord" resultMap="ProLogrecordResult">
        <include refid="selectProLogrecordVo"/>
        <where>  
            <if test="resource != null  and resource != ''"> and resource = #{resource}</if>
            <if test="positionId != null "> and position_id = #{positionId}</if>
            <if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''"> and record_time between #{params.beginRecordTime} and #{params.endRecordTime}</if>
        </where>
    </select>
    
    <select id="selectProLogrecordById" parameterType="Long" resultMap="ProLogrecordResult">
        <include refid="selectProLogrecordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertProLogrecord" parameterType="ProLogrecord" useGeneratedKeys="true" keyProperty="id">
        insert into pro_logrecord
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="resource != null">resource,</if>
            <if test="positionId != null">position_id,</if>
            <if test="message != null">message,</if>
            <if test="recordTime != null">record_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="resource != null">#{resource},</if>
            <if test="positionId != null">#{positionId},</if>
            <if test="message != null">#{message},</if>
            <if test="recordTime != null">#{recordTime},</if>
         </trim>
    </insert>

    <update id="updateProLogrecord" parameterType="ProLogrecord">
        update pro_logrecord
        <trim prefix="SET" suffixOverrides=",">
            <if test="resource != null">resource = #{resource},</if>
            <if test="positionId != null">position_id = #{positionId},</if>
            <if test="message != null">message = #{message},</if>
            <if test="recordTime != null">record_time = #{recordTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteProLogrecordById" parameterType="Long">
        delete from pro_logrecord where id = #{id}
    </delete>

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

    <delete id="deleteProLogrecordByEndId" parameterType="Long">
        delete from pro_logrecord where id &lt; #{id}
    </delete>
</mapper>