<?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.project.mapper.TrsResultsLogMapper">
    
    <resultMap type="TrsResultsLog" id="TrsResultsLogResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="status"    column="status"    />
        <result property="errortype"    column="errortype"    />
        <result property="time"    column="time"    />
    </resultMap>

    <sql id="selectTrsResultsLogVo">
        select id, title, content, status, errortype, time from trs_results_log
    </sql>

    <select id="selectTrsResultsLogList" parameterType="TrsResultsLog" resultMap="TrsResultsLogResult">
        <include refid="selectTrsResultsLogVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="errortype != null  and errortype != ''"> and errortype = #{errortype}</if>
            <if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
        </where>
        order by id desc
    </select>
    
    <select id="selectTrsResultsLogById" parameterType="Long" resultMap="TrsResultsLogResult">
        <include refid="selectTrsResultsLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertTrsResultsLog" parameterType="TrsResultsLog" useGeneratedKeys="true" keyProperty="id">
        insert into trs_results_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
            <if test="status != null">status,</if>
            <if test="errortype != null">errortype,</if>
            <if test="time != null">time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="status != null">#{status},</if>
            <if test="errortype != null">#{errortype},</if>
            <if test="time != null">#{time},</if>
         </trim>
    </insert>

    <update id="updateTrsResultsLog" parameterType="TrsResultsLog">
        update trs_results_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="status != null">status = #{status},</if>
            <if test="errortype != null">errortype = #{errortype},</if>
            <if test="time != null">time = #{time},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTrsResultsLogById" parameterType="Long">
        delete from trs_results_log where id = #{id}
    </delete>

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

</mapper>