<?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.engine.organization.mapper.jclimport.JclImportHistoryMapper">
    <resultMap id="BaseResultMap" type="com.engine.organization.entity.jclimport.po.JclImportHistoryPO">
        <result column="id" property="id"/>
        <result column="operator" property="operator"/>
        <result column="operate_time" property="operateTime"/>
        <result column="client_address" property="clientAddress"/>
        <result column="import_type" property="importType"/>
        <result column="source_from" property="sourceFrom"/>
        <result column="operate_type" property="operateType"/>
        <result column="status" property="status"/>
    </resultMap>

    <!-- 表字段 -->
    <sql id="baseColumns">
        t
        .
        id
        , t.operator
        , t.operate_time
        , t.client_address
        , t.import_type
        , t.source_from
        , t.operate_type
        , t.status
    </sql>
    <insert id="insertHistory" parameterType="com.engine.organization.entity.jclimport.po.JclImportHistoryPO"
            keyProperty="id"
            keyColumn="id" useGeneratedKeys="true">
        INSERT INTO jcl_import_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="operator != null">
                operator,
            </if>
            <if test="operateTime != null">
                operate_time,
            </if>
            <if test="clientAddress != null">
                client_address,
            </if>
            <if test="importType != null">
                import_type,
            </if>
            <if test="sourceFrom != null ">
                source_from,
            </if>
            <if test="operateType != null ">
                operate_type,
            </if>
            <if test="status != null ">
                status,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="operator != null">
                #{operator},
            </if>
            <if test="operateTime != null">
                #{operateTime},
            </if>
            <if test="clientAddress != null">
                #{clientAddress},
            </if>
            <if test="importType != null">
                #{importType},
            </if>
            <if test="sourceFrom != null ">
                #{sourceFrom},
            </if>
            <if test="operateType != null ">
                #{operateType},
            </if>
            <if test="status != null ">
                #{status},
            </if>

        </trim>
    </insert>

    <insert id="insertHistory" parameterType="com.engine.organization.entity.jclimport.po.JclImportHistoryPO" databaseId="oracle">
        <selectKey  keyProperty="id" resultType="long" order="AFTER">
            select JCL_IMPORT_HISTORY_ID.currval from dual
        </selectKey>
        INSERT INTO jcl_import_history
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="operator != null">
                operator,
            </if>
            <if test="operateTime != null">
                operate_time,
            </if>
            <if test="clientAddress != null">
                client_address,
            </if>
            <if test="importType != null">
                import_type,
            </if>
            <if test="sourceFrom != null ">
                source_from,
            </if>
            <if test="operateType != null ">
                operate_type,
            </if>
            <if test="status != null ">
                status,
            </if>
        </trim>
        <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
            <if test="operator != null">
                #{operator},
            </if>
            <if test="operateTime != null">
                #{operateTime},
            </if>
            <if test="clientAddress != null">
                #{clientAddress},
            </if>
            <if test="importType != null">
                #{importType},
            </if>
            <if test="sourceFrom != null ">
                #{sourceFrom},
            </if>
            <if test="operateType != null ">
                #{operateType},
            </if>
            <if test="status != null ">
                #{status},
            </if>

        </trim>
    </insert>

    <update id="updateHistoryStatus">
        update jcl_import_history
        set status = #{status}
        where id = #{pId}
    </update>
</mapper>