<?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.DmsKnowledgeMaintMapper">
    
    <resultMap type="DmsKnowledgeMaint" id="DmsKnowledgeMaintResult">
        <result property="knowledgeMaintId"    column="knowledge_maint_id"    />
        <result property="experienceCode"    column="experience_code"    />
        <result property="deviceTypeId"    column="device_type_id"    />
        <result property="maintStationId"    column="maint_station_id"    />
        <result property="maintProtocol"    column="maint_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="selectDmsKnowledgeMaintVo">
        select knowledge_maint_id, experience_code, device_type_id, maint_station_id, maint_protocol, operation_description, is_flag, remark, create_by, create_time, update_by, update_time from dms_knowledge_maint
    </sql>

    <select id="selectDmsKnowledgeMaintList" parameterType="DmsKnowledgeMaint" resultMap="DmsKnowledgeMaintResult">
        <include refid="selectDmsKnowledgeMaintVo"/>
        <where>  
            <if test="experienceCode != null  and experienceCode != ''"> and experience_code = #{experienceCode}</if>
            <if test="deviceTypeId != null "> and device_type_id = #{deviceTypeId}</if>
            <if test="maintStationId != null "> and maint_station_id = #{maintStationId}</if>
            <if test="maintProtocol != null  and maintProtocol != ''"> and maint_protocol = #{maintProtocol}</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="selectDmsKnowledgeMaintByKnowledgeMaintId" parameterType="Long" resultMap="DmsKnowledgeMaintResult">
        <include refid="selectDmsKnowledgeMaintVo"/>
        where knowledge_maint_id = #{knowledgeMaintId}
    </select>
        
    <insert id="insertDmsKnowledgeMaint" parameterType="DmsKnowledgeMaint" useGeneratedKeys="true" keyProperty="knowledgeMaintId">
        insert into dms_knowledge_maint
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="experienceCode != null">experience_code,</if>
            <if test="deviceTypeId != null">device_type_id,</if>
            <if test="maintStationId != null">maint_station_id,</if>
            <if test="maintProtocol != null">maint_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="experienceCode != null">#{experienceCode},</if>
            <if test="deviceTypeId != null">#{deviceTypeId},</if>
            <if test="maintStationId != null">#{maintStationId},</if>
            <if test="maintProtocol != null">#{maintProtocol},</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="updateDmsKnowledgeMaint" parameterType="DmsKnowledgeMaint">
        update dms_knowledge_maint
        <trim prefix="SET" suffixOverrides=",">
            <if test="experienceCode != null">experience_code = #{experienceCode},</if>
            <if test="deviceTypeId != null">device_type_id = #{deviceTypeId},</if>
            <if test="maintStationId != null">maint_station_id = #{maintStationId},</if>
            <if test="maintProtocol != null">maint_protocol = #{maintProtocol},</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 knowledge_maint_id = #{knowledgeMaintId}
    </update>

    <delete id="deleteDmsKnowledgeMaintByKnowledgeMaintId" parameterType="Long">
        delete from dms_knowledge_maint where knowledge_maint_id = #{knowledgeMaintId}
    </delete>

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