<?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.pcloud.book.advertising.dao.impl.AdvertisingCpaPaySyncRecordDaoImpl">

    <resultMap id="BaseResultMap" type="com.pcloud.book.advertising.entity.AdvertisingCpaPaySyncRecord">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="order_num" property="orderNum" jdbcType="VARCHAR"/>
        <result column="api_url" property="apiUrl" jdbcType="VARCHAR"/>
        <result column="api_body" property="apiBody" jdbcType="VARCHAR"/>
        <result column="api_result" property="apiResult" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="action_code" property="actionCode" jdbcType="VARCHAR"/>
        <result column="msg" property="msg" jdbcType="VARCHAR"/>
    </resultMap>
    
    <sql id="Base_Column_List">
        id, order_num, api_url, api_body, api_result, create_time, update_time, action_code, msg        
    </sql>

    <select id="getById" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM advertising_cpa_pay_sync_record
        WHERE id = #{id}
    </select>
    
    <select id="getList" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM advertising_cpa_pay_sync_record
    </select>

    <insert id="insert" keyProperty="id" useGeneratedKeys="true">
        INSERT INTO advertising_cpa_pay_sync_record(
            order_num, 
            api_url, 
            api_body, 
            api_result, 
            create_time, 
            update_time, 
            action_code, 
            msg
        ) VALUES (
            #{orderNum, jdbcType=VARCHAR}, 
            #{apiUrl, jdbcType=VARCHAR}, 
            #{apiBody, jdbcType=VARCHAR}, 
            #{apiResult, jdbcType=VARCHAR}, 
            #{createTime, jdbcType=TIMESTAMP}, 
            #{updateTime, jdbcType=TIMESTAMP}, 
            #{actionCode, jdbcType=VARCHAR}, 
            #{msg, jdbcType=VARCHAR}
        )
    </insert>
    
    <insert id="batchInsert">
        INSERT INTO advertising_cpa_pay_sync_record (
            order_num, 
            api_url, 
            api_body, 
            api_result, 
            create_time, 
            update_time, 
            action_code, 
            msg
        ) VALUES 
        <foreach collection="list" item="item" separator=",">
        (
            #{item.orderNum, jdbcType=VARCHAR}, 
            #{item.apiUrl, jdbcType=VARCHAR}, 
            #{item.apiBody, jdbcType=VARCHAR}, 
            #{item.apiResult, jdbcType=VARCHAR}, 
            #{item.createTime, jdbcType=TIMESTAMP}, 
            #{item.updateTime, jdbcType=TIMESTAMP}, 
            #{item.actionCode, jdbcType=VARCHAR}, 
            #{item.msg, jdbcType=VARCHAR}
        )
        </foreach>
    </insert>

    <!--通过主键修改数据-->
    <update id="update">
        UPDATE advertising_cpa_pay_sync_record
        <set>
            <if test="orderNum != null">
                order_num = #{orderNum},
            </if>
            <if test="apiUrl != null">
                api_url = #{apiUrl},
            </if>
            <if test="apiBody != null">
                api_body = #{apiBody},
            </if>
            <if test="apiResult != null">
                api_result = #{apiResult},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime},
            </if>
            <if test="actionCode != null">
                action_code = #{actionCode},
            </if>
            <if test="msg != null">
                msg = #{msg},
            </if>
        </set>
        WHERE id = #{id}
    </update>

    <!--通过主键删除-->
    <delete id="deleteById">
        DELETE FROM advertising_cpa_pay_sync_record where id = #{id}
    </delete>

</mapper>
