<?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.reliability.mapper.TDeviceExperienceMapper">
    
    <resultMap type="TDeviceExperience" id="TDeviceExperienceResult">
        <result property="id"    column="id"    />
        <result property="remarks"    column="remarks"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="event"    column="event"    />
        <result property="handleProcess"    column="handle_process"    />
        <result property="handleResult"    column="handle_result"    />
        <result property="experience"    column="experience"    />
        <result property="accidentReportLink"    column="accident_report_link"    />
        <result property="expertEvaluation"    column="expert_evaluation"    />

    </resultMap>

    <sql id="selectTDeviceExperienceVo">
        select d.id, d.remarks, d.del_flag, d.event, d.handle_process, d.handle_result, d.experience, d.accident_report_link, d.expert_evaluation  from t_device_experience d

    </sql>

    <select id="selectTDeviceExperienceList" parameterType="TDeviceExperience" resultMap="TDeviceExperienceResult">
        <include refid="selectTDeviceExperienceVo"/>
        <where>  
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="event != null  and event != ''"> and event = #{event}</if>
            <if test="handleProcess != null  and handleProcess != ''"> and handle_process = #{handleProcess}</if>
            <if test="handleResult != null  and handleResult != ''"> and handle_result = #{handleResult}</if>
            <if test="experience != null  and experience != ''"> and experience = #{experience}</if>
            <if test="accidentReportLink != null  and accidentReportLink != ''"> and accident_report_link = #{accidentReportLink}</if>
            <if test="expertEvaluation != null  and expertEvaluation != ''"> and expert_evaluation = #{expertEvaluation}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTDeviceExperienceById" parameterType="Long" resultMap="TDeviceExperienceResult">
        <include refid="selectTDeviceExperienceVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTDeviceExperience" parameterType="TDeviceExperience">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_device_experience.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_device_experience
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="event != null">event,</if>
            <if test="handleProcess != null">handle_process,</if>
            <if test="handleResult != null">handle_result,</if>
            <if test="experience != null">experience,</if>
            <if test="accidentReportLink != null">accident_report_link,</if>
            <if test="expertEvaluation != null">expert_evaluation,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="event != null">#{event},</if>
            <if test="handleProcess != null">#{handleProcess},</if>
            <if test="handleResult != null">#{handleResult},</if>
            <if test="experience != null">#{experience},</if>
            <if test="accidentReportLink != null">#{accidentReportLink},</if>
            <if test="expertEvaluation != null">#{expertEvaluation},</if>
         </trim>
    </insert>

    <update id="updateTDeviceExperience" parameterType="TDeviceExperience">
        update t_device_experience
        <trim prefix="SET" suffixOverrides=",">
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="event != null">event = #{event},</if>
            <if test="handleProcess != null">handle_process = #{handleProcess},</if>
            <if test="handleResult != null">handle_result = #{handleResult},</if>
            <if test="experience != null">experience = #{experience},</if>
            <if test="accidentReportLink != null">accident_report_link = #{accidentReportLink},</if>
            <if test="expertEvaluation != null">expert_evaluation = #{expertEvaluation},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTDeviceExperienceById" parameterType="Long">
        update t_device_experience set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTDeviceExperienceByIds" parameterType="String">
        update t_device_experience set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>