<?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.cool.store.mapper.HyPartnerTaskInfoLogMapper">
    <resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerTaskInfoLogDO">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="partner_line_id" jdbcType="BIGINT" property="partnerLineId"/>
        <result column="operate_user_id" jdbcType="VARCHAR" property="operateUserId"/>
        <result column="operate_username" jdbcType="VARCHAR" property="operateUsername"/>
        <result column="operate_type" jdbcType="VARCHAR" property="operateType"/>
        <result column="workflow_stage" jdbcType="VARCHAR" property="workflowStage"/>
        <result column="workflow_status" jdbcType="VARCHAR" property="workflowStatus"/>
        <result column="message" jdbcType="VARCHAR" property="message"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="partner_id" jdbcType="VARCHAR" property="partnerId"/>
    </resultMap>
    <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.cool.store.entity.HyPartnerTaskInfoLogDO">
        <result column="field_copy" jdbcType="LONGVARCHAR" property="fieldCopy"/>
    </resultMap>
    <sql id="Base_Column_List">
        id, partner_line_id, operate_user_id, operate_username, workflow_stage, workflow_status,
        message, create_time, update_time, partner_id
    </sql>
    <sql id="Blob_Column_List">
        field_copy
    </sql>
    <insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
        insert into hy_partner_task_info_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="record.partnerLineId != null">
                partner_line_id,
            </if>
            <if test="record.operateUserId != null">
                operate_user_id,
            </if>
            <if test="record.operateUsername != null">
                operate_username,
            </if>
            <if test="record.operateType != null">
                operate_type,
            </if>
            <if test="record.workflowStage != null">
                workflow_stage,
            </if>
            <if test="record.workflowStatus != null">
                workflow_status,
            </if>
            <if test="record.message != null">
                message,
            </if>
            <if test="record.createTime != null">
                create_time,
            </if>
            <if test="record.updateTime != null">
                update_time,
            </if>
            <if test="record.partnerId != null">
                partner_id,
            </if>
            <if test="record.fieldCopy != null">
                field_copy,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="record.partnerLineId != null">
                #{record.partnerLineId},
            </if>
            <if test="record.operateUserId != null">
                #{record.operateUserId},
            </if>
            <if test="record.operateUsername != null">
                #{record.operateUsername},
            </if>
            <if test="record.operateType != null">
                #{record.operateType},
            </if>
            <if test="record.workflowStage != null">
                #{record.workflowStage},
            </if>
            <if test="record.workflowStatus != null">
                #{record.workflowStatus},
            </if>
            <if test="record.message != null">
                #{record.message},
            </if>
            <if test="record.createTime != null">
                #{record.createTime},
            </if>
            <if test="record.updateTime != null">
                #{record.updateTime},
            </if>
            <if test="record.partnerId != null">
                #{record.partnerId},
            </if>
            <if test="record.fieldCopy != null">
                #{record.fieldCopy},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective">
        update hy_partner_task_info_log
        <set>
            <if test="record.partnerLineId != null">
                partner_line_id = #{record.partnerLineId},
            </if>
            <if test="record.operateUserId != null">
                operate_user_id = #{record.operateUserId},
            </if>
            <if test="record.operateUsername != null">
                operate_username = #{record.operateUsername},
            </if>
            <if test="record.workflowStage != null">
                workflow_stage = #{record.workflowStage},
            </if>
            <if test="record.workflowStatus != null">
                workflow_status = #{record.workflowStatus},
            </if>
            <if test="record.message != null">
                message = #{record.message},
            </if>
            <if test="record.createTime != null">
                create_time = #{record.createTime},
            </if>
            <if test="record.updateTime != null">
                update_time = #{record.updateTime},
            </if>
            <if test="record.partnerId != null">
                partner_id = #{record.partnerId},
            </if>
            <if test="record.fieldCopy != null">
                field_copy = #{record.fieldCopy},
            </if>
        </set>
        where id = #{record.id}
    </update>
    <select id="selectByPartnerLineIdAndOperateType" resultMap="ResultMapWithBLOBs">
        select
        <include refid="Base_Column_List"/>,
        <include refid="Blob_Column_List"/>
        from hy_partner_task_info_log
        where partner_line_id = #{partnerLineId}
        and operate_type = #{operateType}
        order by create_time desc
    </select>

    <update id="updateLineId">
        update hy_partner_task_info_log
        set partner_line_id = #{newLineId}  , partner_id = #{newPartnerId}
        where partner_line_id = #{oldLineId}
    </update>

</mapper>