<?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.bailuntec.mapper.JobAmazonAdLogMapper">
    <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="account_id" jdbcType="INTEGER" property="accountId"/>
        <result column="report_id" jdbcType="VARCHAR" property="reportId"/>
        <result column="report_date" jdbcType="DATE" property="reportDate"/>
        <result column="status" jdbcType="BIT" property="status"/>
        <result column="bj_create" jdbcType="TIMESTAMP" property="bjCreate"/>
        <result column="bj_modified" jdbcType="TIMESTAMP" property="bjModified"/>
        <result column="site_en" jdbcType="VARCHAR" property="siteEn"/>
        <result column="company_id" jdbcType="INTEGER" property="companyId"/>
        <result column="type" jdbcType="INTEGER" property="type"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        id, account_id, report_id, report_date, status, bj_create, bj_modified, site_en,
        company_id, type
    </sql>
    <select id="selectByExample" parameterType="com.bailuntec.domain.example.JobAmazonAdLogExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from job_amazon_ad_log
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        <if test="rows != null">
            <if test="offset != null">
                limit ${offset}, ${rows}
            </if>
            <if test="offset == null">
                limit ${rows}
            </if>
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select
        <include refid="Base_Column_List"/>
        from job_amazon_ad_log
        where id = #{id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from job_amazon_ad_log
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.JobAmazonAdLogExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from job_amazon_ad_log
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into job_amazon_ad_log (id, account_id, report_id,
        report_date, status, bj_create,
        bj_modified, site_en, company_id,
        type)
        values (#{id,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER}, #{reportId,jdbcType=VARCHAR},
        #{reportDate,jdbcType=DATE}, #{status,jdbcType=BIT}, #{bjCreate,jdbcType=TIMESTAMP},
        #{bjModified,jdbcType=TIMESTAMP}, #{siteEn,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER},
        #{type,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into job_amazon_ad_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="reportId != null">
                report_id,
            </if>
            <if test="reportDate != null">
                report_date,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="siteEn != null">
                site_en,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="type != null">
                type,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="reportId != null">
                #{reportId,jdbcType=VARCHAR},
            </if>
            <if test="reportDate != null">
                #{reportDate,jdbcType=DATE},
            </if>
            <if test="status != null">
                #{status,jdbcType=BIT},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="siteEn != null">
                #{siteEn,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.bailuntec.domain.example.JobAmazonAdLogExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from job_amazon_ad_log
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update job_amazon_ad_log
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.accountId != null">
                account_id = #{record.accountId,jdbcType=INTEGER},
            </if>
            <if test="record.reportId != null">
                report_id = #{record.reportId,jdbcType=VARCHAR},
            </if>
            <if test="record.reportDate != null">
                report_date = #{record.reportDate,jdbcType=DATE},
            </if>
            <if test="record.status != null">
                status = #{record.status,jdbcType=BIT},
            </if>
            <if test="record.bjCreate != null">
                bj_create = #{record.bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="record.bjModified != null">
                bj_modified = #{record.bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="record.siteEn != null">
                site_en = #{record.siteEn,jdbcType=VARCHAR},
            </if>
            <if test="record.companyId != null">
                company_id = #{record.companyId,jdbcType=INTEGER},
            </if>
            <if test="record.type != null">
                type = #{record.type,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update job_amazon_ad_log
        set id = #{record.id,jdbcType=INTEGER},
        account_id = #{record.accountId,jdbcType=INTEGER},
        report_id = #{record.reportId,jdbcType=VARCHAR},
        report_date = #{record.reportDate,jdbcType=DATE},
        status = #{record.status,jdbcType=BIT},
        bj_create = #{record.bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{record.bjModified,jdbcType=TIMESTAMP},
        site_en = #{record.siteEn,jdbcType=VARCHAR},
        company_id = #{record.companyId,jdbcType=INTEGER},
        type = #{record.type,jdbcType=INTEGER}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update job_amazon_ad_log
        <set>
            <if test="accountId != null">
                account_id = #{accountId,jdbcType=INTEGER},
            </if>
            <if test="reportId != null">
                report_id = #{reportId,jdbcType=VARCHAR},
            </if>
            <if test="reportDate != null">
                report_date = #{reportDate,jdbcType=DATE},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=BIT},
            </if>
            <if test="bjCreate != null">
                bj_create = #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                bj_modified = #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="siteEn != null">
                site_en = #{siteEn,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=INTEGER},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update job_amazon_ad_log
        set account_id = #{accountId,jdbcType=INTEGER},
        report_id = #{reportId,jdbcType=VARCHAR},
        report_date = #{reportDate,jdbcType=DATE},
        status = #{status,jdbcType=BIT},
        bj_create = #{bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{bjModified,jdbcType=TIMESTAMP},
        site_en = #{siteEn,jdbcType=VARCHAR},
        company_id = #{companyId,jdbcType=INTEGER},
        type = #{type,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into job_amazon_ad_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="reportId != null">
                report_id,
            </if>
            <if test="reportDate != null">
                report_date,
            </if>
            <if test="status != null">
                status,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="siteEn != null">
                site_en,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="type != null">
                type,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="reportId != null">
                #{reportId,jdbcType=VARCHAR},
            </if>
            <if test="reportDate != null">
                #{reportDate,jdbcType=DATE},
            </if>
            <if test="status != null">
                #{status,jdbcType=BIT},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="siteEn != null">
                #{siteEn,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=INTEGER},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                account_id = #{accountId,jdbcType=INTEGER},
            </if>
            <if test="reportId != null">
                report_id = #{reportId,jdbcType=VARCHAR},
            </if>
            <if test="reportDate != null">
                report_date = #{reportDate,jdbcType=DATE},
            </if>
            <if test="status != null">
                status = #{status,jdbcType=BIT},
            </if>
            <if test="bjCreate != null">
                bj_create = #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                bj_modified = #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="siteEn != null">
                site_en = #{siteEn,jdbcType=VARCHAR},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <insert id="upsert" parameterType="com.bailuntec.domain.entity.JobAmazonAdLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        insert into job_amazon_ad_log
        (id, account_id, report_id, report_date, status, bj_create, bj_modified, site_en,
        company_id, type)
        values
        (#{id,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER}, #{reportId,jdbcType=VARCHAR},
        #{reportDate,jdbcType=DATE}, #{status,jdbcType=BIT}, #{bjCreate,jdbcType=TIMESTAMP},
        #{bjModified,jdbcType=TIMESTAMP}, #{siteEn,jdbcType=VARCHAR}, #{companyId,jdbcType=INTEGER},
        #{type,jdbcType=INTEGER})
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        account_id = #{accountId,jdbcType=INTEGER},
        report_id = #{reportId,jdbcType=VARCHAR},
        report_date = #{reportDate,jdbcType=DATE},
        status = #{status,jdbcType=BIT},
        bj_create = #{bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{bjModified,jdbcType=TIMESTAMP},
        site_en = #{siteEn,jdbcType=VARCHAR},
        company_id = #{companyId,jdbcType=INTEGER},
        type = #{type,jdbcType=INTEGER}
    </insert>
    <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.JobAmazonAdLogExample"
            resultMap="BaseResultMap">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
          @project https://github.com/itfsw/mybatis-generator-plugin
        -->
        select
        <include refid="Base_Column_List"/>
        from job_amazon_ad_log
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>

    <!--亚马逊接口限制1小时只能下载60-->
    <select id="selectUnDownload" resultType="com.bailuntec.domain.entity.JobAmazonAdLog">
        select *
        from job_amazon_ad_log
        where status = 0
          and bj_create &lt; #{localDateTime}
          and id % #{shardingContext.shardingTotalCount} = #{shardingContext.shardingItem}
        order by report_date
    </select>
</mapper>
