<?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.JobAccountLogMapper">
    <resultMap id="BaseResultMap" type="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="company_id" jdbcType="INTEGER" property="companyId"/>
        <result column="account_id" jdbcType="INTEGER" property="accountId"/>
        <result column="job_name" jdbcType="VARCHAR" property="jobName"/>
        <result column="page_index" jdbcType="INTEGER" property="pageIndex"/>
        <result column="page_size" jdbcType="INTEGER" property="pageSize"/>
        <result column="type" jdbcType="TINYINT" property="type"/>
        <result column="interval_time" jdbcType="TINYINT" property="intervalTime"/>
        <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
        <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
        <result column="bj_create" jdbcType="TIMESTAMP" property="bjCreate"/>
        <result column="bj_modified" jdbcType="TIMESTAMP" property="bjModified"/>
        <result column="message" jdbcType="VARCHAR" property="message"/>
        <result column="task_ids" jdbcType="VARCHAR" property="taskIds"/>
    </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, company_id, account_id, job_name, page_index, page_size, type, interval_time,
        start_time, end_time, bj_create, bj_modified, message, task_ids
    </sql>
    <select id="selectByExample" parameterType="com.bailuntec.domain.example.JobAccountLogExample"
            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_account_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_account_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_account_log
        where id = #{id,jdbcType=INTEGER}
    </delete>
    <delete id="deleteByExample" parameterType="com.bailuntec.domain.example.JobAccountLogExample">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        delete from job_account_log
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into job_account_log (id, company_id, account_id,
        job_name, page_index, page_size,
        type, interval_time, start_time,
        end_time, bj_create, bj_modified,
        message, task_ids)
        values (#{id,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER},
        #{jobName,jdbcType=VARCHAR}, #{pageIndex,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER},
        #{type,jdbcType=TINYINT}, #{intervalTime,jdbcType=TINYINT}, #{startTime,jdbcType=TIMESTAMP},
        #{endTime,jdbcType=TIMESTAMP}, #{bjCreate,jdbcType=TIMESTAMP}, #{bjModified,jdbcType=TIMESTAMP},
        #{message,jdbcType=VARCHAR}, #{taskIds,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        insert into job_account_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="jobName != null">
                job_name,
            </if>
            <if test="pageIndex != null">
                page_index,
            </if>
            <if test="pageSize != null">
                page_size,
            </if>
            <if test="type != null">
                type,
            </if>
            <if test="intervalTime != null">
                interval_time,
            </if>
            <if test="startTime != null">
                start_time,
            </if>
            <if test="endTime != null">
                end_time,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="message != null">
                message,
            </if>
            <if test="taskIds != null">
                task_ids,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="jobName != null">
                #{jobName,jdbcType=VARCHAR},
            </if>
            <if test="pageIndex != null">
                #{pageIndex,jdbcType=INTEGER},
            </if>
            <if test="pageSize != null">
                #{pageSize,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=TINYINT},
            </if>
            <if test="intervalTime != null">
                #{intervalTime,jdbcType=TINYINT},
            </if>
            <if test="startTime != null">
                #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="message != null">
                #{message,jdbcType=VARCHAR},
            </if>
            <if test="taskIds != null">
                #{taskIds,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.bailuntec.domain.example.JobAccountLogExample"
            resultType="java.lang.Long">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        select count(*) from job_account_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_account_log
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=INTEGER},
            </if>
            <if test="record.companyId != null">
                company_id = #{record.companyId,jdbcType=INTEGER},
            </if>
            <if test="record.accountId != null">
                account_id = #{record.accountId,jdbcType=INTEGER},
            </if>
            <if test="record.jobName != null">
                job_name = #{record.jobName,jdbcType=VARCHAR},
            </if>
            <if test="record.pageIndex != null">
                page_index = #{record.pageIndex,jdbcType=INTEGER},
            </if>
            <if test="record.pageSize != null">
                page_size = #{record.pageSize,jdbcType=INTEGER},
            </if>
            <if test="record.type != null">
                type = #{record.type,jdbcType=TINYINT},
            </if>
            <if test="record.intervalTime != null">
                interval_time = #{record.intervalTime,jdbcType=TINYINT},
            </if>
            <if test="record.startTime != null">
                start_time = #{record.startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.endTime != null">
                end_time = #{record.endTime,jdbcType=TIMESTAMP},
            </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.message != null">
                message = #{record.message,jdbcType=VARCHAR},
            </if>
            <if test="record.taskIds != null">
                task_ids = #{record.taskIds,jdbcType=VARCHAR},
            </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_account_log
        set id = #{record.id,jdbcType=INTEGER},
        company_id = #{record.companyId,jdbcType=INTEGER},
        account_id = #{record.accountId,jdbcType=INTEGER},
        job_name = #{record.jobName,jdbcType=VARCHAR},
        page_index = #{record.pageIndex,jdbcType=INTEGER},
        page_size = #{record.pageSize,jdbcType=INTEGER},
        type = #{record.type,jdbcType=TINYINT},
        interval_time = #{record.intervalTime,jdbcType=TINYINT},
        start_time = #{record.startTime,jdbcType=TIMESTAMP},
        end_time = #{record.endTime,jdbcType=TIMESTAMP},
        bj_create = #{record.bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{record.bjModified,jdbcType=TIMESTAMP},
        message = #{record.message,jdbcType=VARCHAR},
        task_ids = #{record.taskIds,jdbcType=VARCHAR}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update job_account_log
        <set>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                account_id = #{accountId,jdbcType=INTEGER},
            </if>
            <if test="jobName != null">
                job_name = #{jobName,jdbcType=VARCHAR},
            </if>
            <if test="pageIndex != null">
                page_index = #{pageIndex,jdbcType=INTEGER},
            </if>
            <if test="pageSize != null">
                page_size = #{pageSize,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=TINYINT},
            </if>
            <if test="intervalTime != null">
                interval_time = #{intervalTime,jdbcType=TINYINT},
            </if>
            <if test="startTime != null">
                start_time = #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                end_time = #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="bjCreate != null">
                bj_create = #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                bj_modified = #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="message != null">
                message = #{message,jdbcType=VARCHAR},
            </if>
            <if test="taskIds != null">
                task_ids = #{taskIds,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          WARNING - @mbg.generated
          This element is automatically generated by MyBatis Generator, do not modify.
        -->
        update job_account_log
        set company_id = #{companyId,jdbcType=INTEGER},
        account_id = #{accountId,jdbcType=INTEGER},
        job_name = #{jobName,jdbcType=VARCHAR},
        page_index = #{pageIndex,jdbcType=INTEGER},
        page_size = #{pageSize,jdbcType=INTEGER},
        type = #{type,jdbcType=TINYINT},
        interval_time = #{intervalTime,jdbcType=TINYINT},
        start_time = #{startTime,jdbcType=TIMESTAMP},
        end_time = #{endTime,jdbcType=TIMESTAMP},
        bj_create = #{bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{bjModified,jdbcType=TIMESTAMP},
        message = #{message,jdbcType=VARCHAR},
        task_ids = #{taskIds,jdbcType=VARCHAR}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <insert id="upsertSelective" parameterType="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          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_account_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="companyId != null">
                company_id,
            </if>
            <if test="accountId != null">
                account_id,
            </if>
            <if test="jobName != null">
                job_name,
            </if>
            <if test="pageIndex != null">
                page_index,
            </if>
            <if test="pageSize != null">
                page_size,
            </if>
            <if test="type != null">
                type,
            </if>
            <if test="intervalTime != null">
                interval_time,
            </if>
            <if test="startTime != null">
                start_time,
            </if>
            <if test="endTime != null">
                end_time,
            </if>
            <if test="bjCreate != null">
                bj_create,
            </if>
            <if test="bjModified != null">
                bj_modified,
            </if>
            <if test="message != null">
                message,
            </if>
            <if test="taskIds != null">
                task_ids,
            </if>
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="companyId != null">
                #{companyId,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                #{accountId,jdbcType=INTEGER},
            </if>
            <if test="jobName != null">
                #{jobName,jdbcType=VARCHAR},
            </if>
            <if test="pageIndex != null">
                #{pageIndex,jdbcType=INTEGER},
            </if>
            <if test="pageSize != null">
                #{pageSize,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                #{type,jdbcType=TINYINT},
            </if>
            <if test="intervalTime != null">
                #{intervalTime,jdbcType=TINYINT},
            </if>
            <if test="startTime != null">
                #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="bjCreate != null">
                #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="message != null">
                #{message,jdbcType=VARCHAR},
            </if>
            <if test="taskIds != null">
                #{taskIds,jdbcType=VARCHAR},
            </if>
        </trim>
        on duplicate key update
        <trim suffixOverrides=",">
            <if test="id != null">
                id = #{id,jdbcType=INTEGER},
            </if>
            <if test="companyId != null">
                company_id = #{companyId,jdbcType=INTEGER},
            </if>
            <if test="accountId != null">
                account_id = #{accountId,jdbcType=INTEGER},
            </if>
            <if test="jobName != null">
                job_name = #{jobName,jdbcType=VARCHAR},
            </if>
            <if test="pageIndex != null">
                page_index = #{pageIndex,jdbcType=INTEGER},
            </if>
            <if test="pageSize != null">
                page_size = #{pageSize,jdbcType=INTEGER},
            </if>
            <if test="type != null">
                type = #{type,jdbcType=TINYINT},
            </if>
            <if test="intervalTime != null">
                interval_time = #{intervalTime,jdbcType=TINYINT},
            </if>
            <if test="startTime != null">
                start_time = #{startTime,jdbcType=TIMESTAMP},
            </if>
            <if test="endTime != null">
                end_time = #{endTime,jdbcType=TIMESTAMP},
            </if>
            <if test="bjCreate != null">
                bj_create = #{bjCreate,jdbcType=TIMESTAMP},
            </if>
            <if test="bjModified != null">
                bj_modified = #{bjModified,jdbcType=TIMESTAMP},
            </if>
            <if test="message != null">
                message = #{message,jdbcType=VARCHAR},
            </if>
            <if test="taskIds != null">
                task_ids = #{taskIds,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <insert id="upsert" parameterType="com.bailuntec.domain.entity.JobAccountLog">
        <!--
          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_account_log
        (id, company_id, account_id, job_name, page_index, page_size, type, interval_time,
        start_time, end_time, bj_create, bj_modified, message, task_ids)
        values
        (#{id,jdbcType=INTEGER}, #{companyId,jdbcType=INTEGER}, #{accountId,jdbcType=INTEGER},
        #{jobName,jdbcType=VARCHAR}, #{pageIndex,jdbcType=INTEGER}, #{pageSize,jdbcType=INTEGER},
        #{type,jdbcType=TINYINT}, #{intervalTime,jdbcType=TINYINT}, #{startTime,jdbcType=TIMESTAMP},
        #{endTime,jdbcType=TIMESTAMP}, #{bjCreate,jdbcType=TIMESTAMP}, #{bjModified,jdbcType=TIMESTAMP},
        #{message,jdbcType=VARCHAR}, #{taskIds,jdbcType=VARCHAR})
        on duplicate key update
        id = #{id,jdbcType=INTEGER},
        company_id = #{companyId,jdbcType=INTEGER},
        account_id = #{accountId,jdbcType=INTEGER},
        job_name = #{jobName,jdbcType=VARCHAR},
        page_index = #{pageIndex,jdbcType=INTEGER},
        page_size = #{pageSize,jdbcType=INTEGER},
        type = #{type,jdbcType=TINYINT},
        interval_time = #{intervalTime,jdbcType=TINYINT},
        start_time = #{startTime,jdbcType=TIMESTAMP},
        end_time = #{endTime,jdbcType=TIMESTAMP},
        bj_create = #{bjCreate,jdbcType=TIMESTAMP},
        bj_modified = #{bjModified,jdbcType=TIMESTAMP},
        message = #{message,jdbcType=VARCHAR},
        task_ids = #{taskIds,jdbcType=VARCHAR}
    </insert>
    <select id="selectOneByExample" parameterType="com.bailuntec.domain.example.JobAccountLogExample"
            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_account_log
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
        limit 1
    </select>

    <select id="getListByPage" resultType="com.bailuntec.domain.entity.JobAccountLog">
        SELECT t2.id,t1.company_id, t1.account_id,
        t2.job_name,t2.page_index,t2.page_size,t2.type,t2.interval_time,t2.start_time,t2.end_time, t2.task_ids FROM
        (SELECT * FROM dc_base_company_account WHERE 1=1  <if test="platformId != null">and
        platform_id=#{platformId}</if>) t1 LEFT JOIN job_account_log t2 on t1.account_id = t2.account_id order by id
        limit #{pageIndex},#{pageSize}
    </select>

    <select id="getListByPageEbay" resultType="com.bailuntec.domain.entity.JobAccountLog">
        SELECT
            t2.id,
            t1.company_id,
            t1.account_id,
            t2.job_name,
            t2.page_index,
            t2.page_size,
            t2.type,
            t2.interval_time,
            t2.start_time,
            t2.end_time,
            t2.task_ids FROM
            (SELECT * FROM dc_base_company_account WHERE company_id = 1 and account_name not like '%test%'and platform_id= #{platformId} order by id) t1
                LEFT JOIN job_account_log t2 on t1.account_id = t2.account_id
        order by t1.id

    </select>

    <select id="getListByPageAmazon" resultType="com.bailuntec.domain.entity.JobAccountLog">
        SELECT
        t2.id,
        t1.company_id,
        t1.account_id,
        t2.job_name,
        t2.page_index,
        t2.page_size,
        t2.type,
        t2.interval_time,
        t2.start_time,
        t2.end_time,
        t2.task_ids
        FROM
        (SELECT * FROM dc_base_company_account WHERE true
        and amazon_ad_auth_json != ''
        <if test="platformId != null">
            and platform_id=#{platformId}
        </if>) t1
        LEFT JOIN job_account_log t2 on t1.account_id = t2.account_id
        order by id
        limit #{pageIndex},#{pageSize}
    </select>

</mapper>
