<?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.DmsKnowledgeLubeMapper">
    
    <resultMap type="DmsKnowledgeLube" id="DmsKnowledgeLubeResult">
        <result property="knowledgeLubeId"    column="knowledge_lube_id"    />
        <result property="experienceCode"    column="experience_code"    />
        <result property="deviceTypeId"    column="device_type_id"    />
        <result property="lubeStationId"    column="lube_station_id"    />
        <result property="protocolCode"    column="protocol_code"    />
        <result property="operationsDescription"    column="operations_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="selectDmsKnowledgeLubeVo">
        select knowledge_lube_id, experience_code, device_type_id, lube_station_id, protocol_code, operations_description, is_flag, remark, create_by, create_time, update_by, update_time from dms_knowledge_lube
    </sql>

    <select id="selectDmsKnowledgeLubeList" parameterType="DmsKnowledgeLube" resultMap="DmsKnowledgeLubeResult">
        <include refid="selectDmsKnowledgeLubeVo"/>
        <where>  
            <if test="experienceCode != null  and experienceCode != ''"> and experience_code = #{experienceCode}</if>
            <if test="deviceTypeId != null "> and device_type_id = #{deviceTypeId}</if>
            <if test="lubeStationId != null "> and lube_station_id = #{lubeStationId}</if>
            <if test="protocolCode != null  and protocolCode != ''"> and protocol_code = #{protocolCode}</if>
            <if test="operationsDescription != null  and operationsDescription != ''"> and operations_description = #{operationsDescription}</if>
            <if test="isFlag != null  and isFlag != ''"> and is_flag = #{isFlag}</if>
        </where>
    </select>
    
    <select id="selectDmsKnowledgeLubeByKnowledgeLubeId" parameterType="Long" resultMap="DmsKnowledgeLubeResult">
        <include refid="selectDmsKnowledgeLubeVo"/>
        where knowledge_lube_id = #{knowledgeLubeId}
    </select>
        
    <insert id="insertDmsKnowledgeLube" parameterType="DmsKnowledgeLube" useGeneratedKeys="true" keyProperty="knowledgeLubeId">
        insert into dms_knowledge_lube
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="experienceCode != null">experience_code,</if>
            <if test="deviceTypeId != null">device_type_id,</if>
            <if test="lubeStationId != null">lube_station_id,</if>
            <if test="protocolCode != null">protocol_code,</if>
            <if test="operationsDescription != null">operations_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="experienceCode != null">#{experienceCode},</if>
            <if test="deviceTypeId != null">#{deviceTypeId},</if>
            <if test="lubeStationId != null">#{lubeStationId},</if>
            <if test="protocolCode != null">#{protocolCode},</if>
            <if test="operationsDescription != null">#{operationsDescription},</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="updateDmsKnowledgeLube" parameterType="DmsKnowledgeLube">
        update dms_knowledge_lube
        <trim prefix="SET" suffixOverrides=",">
            <if test="experienceCode != null">experience_code = #{experienceCode},</if>
            <if test="deviceTypeId != null">device_type_id = #{deviceTypeId},</if>
            <if test="lubeStationId != null">lube_station_id = #{lubeStationId},</if>
            <if test="protocolCode != null">protocol_code = #{protocolCode},</if>
            <if test="operationsDescription != null">operations_description = #{operationsDescription},</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 knowledge_lube_id = #{knowledgeLubeId}
    </update>

    <delete id="deleteDmsKnowledgeLubeByKnowledgeLubeId" parameterType="Long">
        delete from dms_knowledge_lube where knowledge_lube_id = #{knowledgeLubeId}
    </delete>

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