<?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.goomood.phm.mapper.FaultSettingMapper">
    
    <resultMap type="FaultSetting" id="FaultSettingResult">
        <result property="id"    column="id"    />
        <result property="highFaultPlanes"    column="high_fault_planes"    />
        <result property="monthPlaneFaults"    column="month_plane_faults"    />
        <result property="monthSysFaults"    column="month_sys_faults"    />
        <result property="monthPartFaults"    column="month_part_faults"    />
        <result property="threeMonthOpen"    column="three_month_open"    />
        <result property="lastSysErrors"    column="last_sys_errors"    />
        <result property="lastPartErrors"    column="last_part_errors"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="column9"    column="Column_9"    />
    </resultMap>

    <sql id="selectFaultSettingVo">
        select id, high_fault_planes, month_plane_faults, month_sys_faults, month_part_faults, three_month_open, last_sys_errors, last_part_errors, create_by, create_time, update_by, update_time, remark, Column_9 from fault_setting
    </sql>

    <select id="selectFaultSettingList" parameterType="FaultSetting" resultMap="FaultSettingResult">
        <include refid="selectFaultSettingVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectFaultSettingById" parameterType="Long" resultMap="FaultSettingResult">
        <include refid="selectFaultSettingVo"/>
        where id = #{id}
    </select>

    <insert id="insertFaultSetting" parameterType="FaultSetting" useGeneratedKeys="true" keyProperty="id">
        insert into fault_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="highFaultPlanes != null">high_fault_planes,</if>
            <if test="monthPlaneFaults != null">month_plane_faults,</if>
            <if test="monthSysFaults != null">month_sys_faults,</if>
            <if test="monthPartFaults != null">month_part_faults,</if>
            <if test="threeMonthOpen != null">three_month_open,</if>
            <if test="lastSysErrors != null">last_sys_errors,</if>
            <if test="lastPartErrors != null">last_part_errors,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="column9 != null">Column_9,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="highFaultPlanes != null">#{highFaultPlanes},</if>
            <if test="monthPlaneFaults != null">#{monthPlaneFaults},</if>
            <if test="monthSysFaults != null">#{monthSysFaults},</if>
            <if test="monthPartFaults != null">#{monthPartFaults},</if>
            <if test="threeMonthOpen != null">#{threeMonthOpen},</if>
            <if test="lastSysErrors != null">#{lastSysErrors},</if>
            <if test="lastPartErrors != null">#{lastPartErrors},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="column9 != null">#{column9},</if>
         </trim>
    </insert>

    <update id="updateFaultSetting" parameterType="FaultSetting">
        update fault_setting
        <trim prefix="SET" suffixOverrides=",">
            <if test="highFaultPlanes != null">high_fault_planes = #{highFaultPlanes},</if>
            <if test="monthPlaneFaults != null">month_plane_faults = #{monthPlaneFaults},</if>
            <if test="monthSysFaults != null">month_sys_faults = #{monthSysFaults},</if>
            <if test="monthPartFaults != null">month_part_faults = #{monthPartFaults},</if>
            <if test="threeMonthOpen != null">three_month_open = #{threeMonthOpen},</if>
            <if test="lastSysErrors != null">last_sys_errors = #{lastSysErrors},</if>
            <if test="lastPartErrors != null">last_part_errors = #{lastPartErrors},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="column9 != null">Column_9 = #{column9},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFaultSettingById" parameterType="Long">
        delete from fault_setting where id = #{id}
    </delete>

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