<?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.applet.mapper.AppletTrackMapper">
  <resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletTrack">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="wechat_user_id" jdbcType="BIGINT" property="wechatUserId" />
    <result column="official_accounts_id" jdbcType="BIGINT" property="officialAccountsId" />
    <result column="page" jdbcType="VARCHAR" property="page" />
    <result column="track_type" jdbcType="VARCHAR" property="trackType" />
    <result column="element_name" jdbcType="VARCHAR" property="elementName" />
    <result column="ext_json" jdbcType="VARCHAR" property="extJson" />
    <result column="version" jdbcType="VARCHAR" property="version" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, wechat_user_id, official_accounts_id, page, track_type, element_name, ext_json, 
    version, remark, create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from applet_track
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from applet_track
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletTrack" useGeneratedKeys="true">
    insert into applet_track (wechat_user_id, official_accounts_id, page, 
      track_type, element_name, ext_json, 
      version, remark, create_time
      )
    values (#{wechatUserId,jdbcType=BIGINT}, #{officialAccountsId,jdbcType=BIGINT}, #{page,jdbcType=VARCHAR}, 
      #{trackType,jdbcType=VARCHAR}, #{elementName,jdbcType=VARCHAR}, #{extJson,jdbcType=VARCHAR}, 
      #{version,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, NOW()
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.pcloud.book.applet.entity.AppletTrack" useGeneratedKeys="true">
    insert into applet_track
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="wechatUserId != null">
        wechat_user_id,
      </if>
      <if test="officialAccountsId != null">
        official_accounts_id,
      </if>
      <if test="page != null">
        page,
      </if>
      <if test="trackType != null">
        track_type,
      </if>
      <if test="elementName != null">
        element_name,
      </if>
      <if test="extJson != null">
        ext_json,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="remark != null">
        remark,
      </if>
        create_time,
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="wechatUserId != null">
        #{wechatUserId,jdbcType=BIGINT},
      </if>
      <if test="officialAccountsId != null">
        #{officialAccountsId,jdbcType=BIGINT},
      </if>
      <if test="page != null">
        #{page,jdbcType=VARCHAR},
      </if>
      <if test="trackType != null">
        #{trackType,jdbcType=VARCHAR},
      </if>
      <if test="elementName != null">
        #{elementName,jdbcType=VARCHAR},
      </if>
      <if test="extJson != null">
        #{extJson,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        #{version,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
        NOW()
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.pcloud.book.applet.entity.AppletTrack">
    update applet_track
    <set>
      <if test="wechatUserId != null">
        wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
      </if>
      <if test="officialAccountsId != null">
        official_accounts_id = #{officialAccountsId,jdbcType=BIGINT},
      </if>
      <if test="page != null">
        page = #{page,jdbcType=VARCHAR},
      </if>
      <if test="trackType != null">
        track_type = #{trackType,jdbcType=VARCHAR},
      </if>
      <if test="elementName != null">
        element_name = #{elementName,jdbcType=VARCHAR},
      </if>
      <if test="extJson != null">
        ext_json = #{extJson,jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        version = #{version,jdbcType=VARCHAR},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pcloud.book.applet.entity.AppletTrack">
    update applet_track
    set wechat_user_id = #{wechatUserId,jdbcType=BIGINT},
      official_accounts_id = #{officialAccountsId,jdbcType=BIGINT},
      page = #{page,jdbcType=VARCHAR},
      track_type = #{trackType,jdbcType=VARCHAR},
      element_name = #{elementName,jdbcType=VARCHAR},
      ext_json = #{extJson,jdbcType=VARCHAR},
      version = #{version,jdbcType=VARCHAR},
      remark = #{remark,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>