<?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.hw.dms.mapper.DmsBaseLubeStandardMapper">
    
    <resultMap type="DmsBaseLubeStandard" id="DmsBaseLubeStandardResult">
        <result property="lubeStandardId"    column="lube_standard_id"    />
        <result property="lubeStandardCode"    column="lube_standard_code"    />
        <result property="deviceTypeId"    column="device_type_id"    />
        <result property="lubeProtocol"    column="lube_protocol"    />
        <result property="operationDescription"    column="operation_description"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectDmsBaseLubeStandardVo">
        select lube_standard_id, lube_standard_code, device_type_id, lube_protocol, operation_description, is_flag, remark, create_by, create_time, update_by, update_time from dms_base_lube_standard
    </sql>

    <select id="selectDmsBaseLubeStandardList" parameterType="DmsBaseLubeStandard" resultMap="DmsBaseLubeStandardResult">
        <include refid="selectDmsBaseLubeStandardVo"/>
        <where>  
            <if test="lubeStandardCode != null  and lubeStandardCode != ''"> and lube_standard_code = #{lubeStandardCode}</if>
            <if test="deviceTypeId != null "> and device_type_id = #{deviceTypeId}</if>
            <if test="lubeProtocol != null  and lubeProtocol != ''"> and lube_protocol = #{lubeProtocol}</if>
            <if test="operationDescription != null  and operationDescription != ''"> and operation_description = #{operationDescription}</if>
            <if test="isFlag != null  and isFlag != ''"> and is_flag = #{isFlag}</if>
        </where>
    </select>
    
    <select id="selectDmsBaseLubeStandardByLubeStandardId" parameterType="Long" resultMap="DmsBaseLubeStandardResult">
        <include refid="selectDmsBaseLubeStandardVo"/>
        where lube_standard_id = #{lubeStandardId}
    </select>
        
    <insert id="insertDmsBaseLubeStandard" parameterType="DmsBaseLubeStandard" useGeneratedKeys="true" keyProperty="lubeStandardId">
        insert into dms_base_lube_standard
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="lubeStandardCode != null and lubeStandardCode != ''">lube_standard_code,</if>
            <if test="deviceTypeId != null">device_type_id,</if>
            <if test="lubeProtocol != null and lubeProtocol != ''">lube_protocol,</if>
            <if test="operationDescription != null">operation_description,</if>
            <if test="isFlag != null and isFlag != ''">is_flag,</if>
            <if test="remark != null">remark,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="lubeStandardCode != null and lubeStandardCode != ''">#{lubeStandardCode},</if>
            <if test="deviceTypeId != null">#{deviceTypeId},</if>
            <if test="lubeProtocol != null and lubeProtocol != ''">#{lubeProtocol},</if>
            <if test="operationDescription != null">#{operationDescription},</if>
            <if test="isFlag != null and isFlag != ''">#{isFlag},</if>
            <if test="remark != null">#{remark},</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>
         </trim>
    </insert>

    <update id="updateDmsBaseLubeStandard" parameterType="DmsBaseLubeStandard">
        update dms_base_lube_standard
        <trim prefix="SET" suffixOverrides=",">
            <if test="lubeStandardCode != null and lubeStandardCode != ''">lube_standard_code = #{lubeStandardCode},</if>
            <if test="deviceTypeId != null">device_type_id = #{deviceTypeId},</if>
            <if test="lubeProtocol != null and lubeProtocol != ''">lube_protocol = #{lubeProtocol},</if>
            <if test="operationDescription != null">operation_description = #{operationDescription},</if>
            <if test="isFlag != null and isFlag != ''">is_flag = #{isFlag},</if>
            <if test="remark != null">remark = #{remark},</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>
        </trim>
        where lube_standard_id = #{lubeStandardId}
    </update>

    <delete id="deleteDmsBaseLubeStandardByLubeStandardId" parameterType="Long">
        delete from dms_base_lube_standard where lube_standard_id = #{lubeStandardId}
    </delete>

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