<?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="org.linlinjava.jz.db.dao.JzCalllogMapper">
  <resultMap id="BaseResultMap" type="org.linlinjava.jz.db.domain.JzCalllog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="customer_id" jdbcType="INTEGER" property="customerId" />
    <result column="campaign_id" jdbcType="INTEGER" property="campaignId" />
    <result column="built_id" jdbcType="INTEGER" property="builtId" />
    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
    <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
    <result column="call_type" jdbcType="VARCHAR" property="callType" />
    <result column="call_result" jdbcType="SMALLINT" property="callResult" />
    <result column="call_reject_reason" jdbcType="VARCHAR" property="callRejectReason" />
    <result column="callback_time" jdbcType="TIMESTAMP" property="callbackTime" />
    <result column="callback_remark" jdbcType="VARCHAR" property="callbackRemark" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="create_user" jdbcType="INTEGER" property="createUser" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="reject_reason" jdbcType="INTEGER" property="rejectReason" />
    <association property="user" column="create_user" javaType="org.linlinjava.jz.db.domain.SysUser" select="getCreateUser"/>
    <association property="customer" column="customer_id" javaType="org.linlinjava.jz.db.domain.CustomerClient" select="getCustomer"/>

    <collection property="records" javaType="java.util.ArrayList" column="id" ofType="org.linlinjava.jz.db.domain.JzCalllogRecord" select="getRecords">
      <result column="call_id" jdbcType="INTEGER" property="callId" />
      <result column="customer_id" jdbcType="INTEGER" property="customerId" />
      <result column="ringingtime" jdbcType="INTEGER" property="ringingtime" />
      <result column="talktime" jdbcType="INTEGER" property="talktime" />
      <result column="connected" jdbcType="BIT" property="connected" />
      <result column="call_type" jdbcType="VARCHAR" property="callType" />
      <result column="call_source" jdbcType="VARCHAR" property="callSource" />
      <result column="record_id" jdbcType="VARCHAR" property="recordId" />
      <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    </collection>
  </resultMap>

  <select id="getCreateUser" resultMap="BaseUserMap">
    select id,user_name from sys_user where  id = #{create_user,jdbcType=INTEGER}
  </select>
  <resultMap id="BaseUserMap" type="org.linlinjava.jz.db.domain.SysUser">
    <result column="user_name" jdbcType="VARCHAR" property="userName" />
  </resultMap>

  <select id="getCustomer" resultMap="BaseCustomerMap">
    select id,customer_name,tel from customer_client where  id = #{customer_id,jdbcType=INTEGER}
  </select>
  <resultMap id="BaseCustomerMap" type="org.linlinjava.jz.db.domain.CustomerClient">
    <result column="tel" jdbcType="VARCHAR" property="tel" />
    <result column="customer_name" jdbcType="VARCHAR" property="customerName" />
  </resultMap>

  <select id="getRecords" resultMap="BaseResultMap">
    select ringingtime,talktime,connected,call_type,call_source,record_id,mobile from jz_calllog_record where  call_id = #{id,jdbcType=INTEGER}
  </select>


  <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, customer_id, campaign_id, built_id, mobile, start_time, end_time, call_type, 
    call_result, call_reject_reason, callback_time, callback_remark, remark, create_user, 
    create_time, reject_reason
  </sql>
  <select id="selectByExample" parameterType="org.linlinjava.jz.db.domain.JzCalllogExample" 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 jz_calllog
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByExampleSelective" parameterType="map" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <if test="example != null and example.distinct">
      distinct
    </if>
    <choose>
      <when test="selective != null and selective.length &gt; 0">
        <foreach collection="selective" item="column" separator=",">
          ${column.aliasedEscapedColumnName}
        </foreach>
      </when>
      <otherwise>
        <include refid="Base_Column_List" />
      </otherwise>
    </choose>
    from jz_calllog
    <if test="example != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
    <if test="example != null and example.orderByClause != null">
      order by ${example.orderByClause}
    </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 jz_calllog
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectByPrimaryKeySelective" parameterType="map" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <choose>
      <when test="selective != null and selective.length &gt; 0">
        <foreach collection="selective" item="column" separator=",">
          ${column.aliasedEscapedColumnName}
        </foreach>
      </when>
      <otherwise>
        <include refid="Base_Column_List" />
      </otherwise>
    </choose>
    from jz_calllog
    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 jz_calllog
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="org.linlinjava.jz.db.domain.JzCalllogExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from jz_calllog
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="org.linlinjava.jz.db.domain.JzCalllog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into jz_calllog (customer_id, campaign_id, built_id, 
      mobile, start_time, end_time, 
      call_type, call_result, call_reject_reason, 
      callback_time, callback_remark, remark, 
      create_user, create_time, reject_reason
      )
    values (#{customerId,jdbcType=INTEGER}, #{campaignId,jdbcType=INTEGER}, #{builtId,jdbcType=INTEGER}, 
      #{mobile,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, 
      #{callType,jdbcType=VARCHAR}, #{callResult,jdbcType=SMALLINT}, #{callRejectReason,jdbcType=VARCHAR}, 
      #{callbackTime,jdbcType=TIMESTAMP}, #{callbackRemark,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, 
      #{createUser,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{rejectReason,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="org.linlinjava.jz.db.domain.JzCalllog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into jz_calllog
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        customer_id,
      </if>
      <if test="campaignId != null">
        campaign_id,
      </if>
      <if test="builtId != null">
        built_id,
      </if>
      <if test="mobile != null">
        mobile,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="callType != null">
        call_type,
      </if>
      <if test="callResult != null">
        call_result,
      </if>
      <if test="callRejectReason != null">
        call_reject_reason,
      </if>
      <if test="callbackTime != null">
        callback_time,
      </if>
      <if test="callbackRemark != null">
        callback_remark,
      </if>
      <if test="remark != null">
        remark,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="rejectReason != null">
        reject_reason,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="customerId != null">
        #{customerId,jdbcType=INTEGER},
      </if>
      <if test="campaignId != null">
        #{campaignId,jdbcType=INTEGER},
      </if>
      <if test="builtId != null">
        #{builtId,jdbcType=INTEGER},
      </if>
      <if test="mobile != null">
        #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="callType != null">
        #{callType,jdbcType=VARCHAR},
      </if>
      <if test="callResult != null">
        #{callResult,jdbcType=SMALLINT},
      </if>
      <if test="callRejectReason != null">
        #{callRejectReason,jdbcType=VARCHAR},
      </if>
      <if test="callbackTime != null">
        #{callbackTime,jdbcType=TIMESTAMP},
      </if>
      <if test="callbackRemark != null">
        #{callbackRemark,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="rejectReason != null">
        #{rejectReason,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="org.linlinjava.jz.db.domain.JzCalllogExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from jz_calllog
    <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 jz_calllog
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.customerId != null">
        customer_id = #{record.customerId,jdbcType=INTEGER},
      </if>
      <if test="record.campaignId != null">
        campaign_id = #{record.campaignId,jdbcType=INTEGER},
      </if>
      <if test="record.builtId != null">
        built_id = #{record.builtId,jdbcType=INTEGER},
      </if>
      <if test="record.mobile != null">
        mobile = #{record.mobile,jdbcType=VARCHAR},
      </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.callType != null">
        call_type = #{record.callType,jdbcType=VARCHAR},
      </if>
      <if test="record.callResult != null">
        call_result = #{record.callResult,jdbcType=SMALLINT},
      </if>
      <if test="record.callRejectReason != null">
        call_reject_reason = #{record.callRejectReason,jdbcType=VARCHAR},
      </if>
      <if test="record.callbackTime != null">
        callback_time = #{record.callbackTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.callbackRemark != null">
        callback_remark = #{record.callbackRemark,jdbcType=VARCHAR},
      </if>
      <if test="record.remark != null">
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.createUser != null">
        create_user = #{record.createUser,jdbcType=INTEGER},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.rejectReason != null">
        reject_reason = #{record.rejectReason,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 jz_calllog
    set id = #{record.id,jdbcType=INTEGER},
      customer_id = #{record.customerId,jdbcType=INTEGER},
      campaign_id = #{record.campaignId,jdbcType=INTEGER},
      built_id = #{record.builtId,jdbcType=INTEGER},
      mobile = #{record.mobile,jdbcType=VARCHAR},
      start_time = #{record.startTime,jdbcType=TIMESTAMP},
      end_time = #{record.endTime,jdbcType=TIMESTAMP},
      call_type = #{record.callType,jdbcType=VARCHAR},
      call_result = #{record.callResult,jdbcType=SMALLINT},
      call_reject_reason = #{record.callRejectReason,jdbcType=VARCHAR},
      callback_time = #{record.callbackTime,jdbcType=TIMESTAMP},
      callback_remark = #{record.callbackRemark,jdbcType=VARCHAR},
      remark = #{record.remark,jdbcType=VARCHAR},
      create_user = #{record.createUser,jdbcType=INTEGER},
      create_time = #{record.createTime,jdbcType=TIMESTAMP},
      reject_reason = #{record.rejectReason,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="org.linlinjava.jz.db.domain.JzCalllog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update jz_calllog
    <set>
      <if test="customerId != null">
        customer_id = #{customerId,jdbcType=INTEGER},
      </if>
      <if test="campaignId != null">
        campaign_id = #{campaignId,jdbcType=INTEGER},
      </if>
      <if test="builtId != null">
        built_id = #{builtId,jdbcType=INTEGER},
      </if>
      <if test="mobile != null">
        mobile = #{mobile,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=TIMESTAMP},
      </if>
      <if test="endTime != null">
        end_time = #{endTime,jdbcType=TIMESTAMP},
      </if>
      <if test="callType != null">
        call_type = #{callType,jdbcType=VARCHAR},
      </if>
      <if test="callResult != null">
        call_result = #{callResult,jdbcType=SMALLINT},
      </if>
      <if test="callRejectReason != null">
        call_reject_reason = #{callRejectReason,jdbcType=VARCHAR},
      </if>
      <if test="callbackTime != null">
        callback_time = #{callbackTime,jdbcType=TIMESTAMP},
      </if>
      <if test="callbackRemark != null">
        callback_remark = #{callbackRemark,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null">
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="rejectReason != null">
        reject_reason = #{rejectReason,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="org.linlinjava.jz.db.domain.JzCalllog">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update jz_calllog
    set customer_id = #{customerId,jdbcType=INTEGER},
      campaign_id = #{campaignId,jdbcType=INTEGER},
      built_id = #{builtId,jdbcType=INTEGER},
      mobile = #{mobile,jdbcType=VARCHAR},
      start_time = #{startTime,jdbcType=TIMESTAMP},
      end_time = #{endTime,jdbcType=TIMESTAMP},
      call_type = #{callType,jdbcType=VARCHAR},
      call_result = #{callResult,jdbcType=SMALLINT},
      call_reject_reason = #{callRejectReason,jdbcType=VARCHAR},
      callback_time = #{callbackTime,jdbcType=TIMESTAMP},
      callback_remark = #{callbackRemark,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      create_user = #{createUser,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      reject_reason = #{rejectReason,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectOneByExample" parameterType="org.linlinjava.jz.db.domain.JzCalllogExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <include refid="Base_Column_List" />
    from jz_calllog
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    limit 1
  </select>
  <select id="selectOneByExampleSelective" parameterType="map" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <choose>
      <when test="selective != null and selective.length &gt; 0">
        <foreach collection="selective" item="column" separator=",">
          ${column.aliasedEscapedColumnName}
        </foreach>
      </when>
      <otherwise>
        <include refid="Base_Column_List" />
      </otherwise>
    </choose>
    from jz_calllog
    <if test="example != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
    <if test="example != null and example.orderByClause != null">
      order by ${example.orderByClause}
    </if>
    limit 1
  </select>
</mapper>