<?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.cab.dao.CabThirdPartyMapper" >
  <resultMap id="BaseResultMap" type="com.cab.model.CabThirdParty" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="cab_user_id" property="cabUserId" jdbcType="INTEGER" />
    <result column="cku_user_id" property="ckuUserId" jdbcType="VARCHAR" />
    <result column="wx" property="wx" jdbcType="VARCHAR" />
    <result column="qq" property="qq" jdbcType="VARCHAR" />
    <result column="sina" property="sina" jdbcType="VARCHAR" />
    <result column="tcb" property="tcb" jdbcType="VARCHAR" />
    <result column="info" property="info" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
    <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
    <result column="deleteFlag" property="deleteflag" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, cab_user_id, cku_user_id, wx, qq, sina, tcb, info, create_time, update_time, 
    deleteFlag
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from cab_third_party
    where cku_user_id = #{id,jdbcType=VARCHAR}
  </select>
  <!-- 根据wechat openId 查询第三方登录用户 -->
  <select id="selectByOpenId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from cab_third_party
    <if test="type=='cku'">
    	where cku_user_id = #{openId,jdbcType=VARCHAR}
    </if>
    <if test="type=='wx'">
    	where wx = #{openId,jdbcType=VARCHAR}
    </if>
    <if test="type=='qq'">
    	where qq = #{openId,jdbcType=VARCHAR}
    </if>
    <if test="type=='sina'">
    	where sina = #{openId,jdbcType=VARCHAR}
    </if>
  </select>
  <!-- 根据cab用户id查询第三方绑定信息  zhuoHeng -->
  <select id="selectByUserId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from cab_third_party
    where cab_user_id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from cab_third_party
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cab.model.CabThirdParty" >
    insert into cab_third_party (id, cab_user_id, cku_user_id, 
      wx, qq, sina, tcb, 
      info, create_time, update_time, 
      deleteFlag)
    values (#{id,jdbcType=INTEGER}, #{cabUserId,jdbcType=INTEGER}, #{ckuUserId,jdbcType=VARCHAR}, 
      #{wx,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{sina,jdbcType=VARCHAR}, #{tcb,jdbcType=VARCHAR}, 
      #{info,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
      #{deleteflag,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.cab.model.CabThirdParty">
    insert into cab_third_party
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="cabUserId != null" >
        cab_user_id,
      </if>
      <if test="ckuUserId != null" >
        cku_user_id,
      </if>
      <if test="wx != null" >
        wx,
      </if>
      <if test="qq != null" >
        qq,
      </if>
      <if test="sina != null" >
        sina,
      </if>
      <if test="tcb != null" >
        tcb,
      </if>
      <if test="info != null" >
        info,
      </if>
        create_time,
        update_time,
      <if test="deleteflag != null" >
        deleteFlag,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="cabUserId != null" >
        #{cabUserId,jdbcType=INTEGER},
      </if>
      <if test="ckuUserId != null" >
        #{ckuUserId,jdbcType=VARCHAR},
      </if>
      <if test="wx != null" >
        #{wx,jdbcType=VARCHAR},
      </if>
      <if test="qq != null" >
        #{qq,jdbcType=VARCHAR},
      </if>
      <if test="sina != null" >
        #{sina,jdbcType=VARCHAR},
      </if>
      <if test="tcb != null" >
        #{tcb,jdbcType=VARCHAR},
      </if>
      <if test="info != null" >
        #{info,jdbcType=VARCHAR},
      </if>
        sysdate(),
        sysdate(),
      <if test="deleteflag != null" >
        #{deleteflag,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="insertThirdParty" parameterType="java.lang.Integer" >
    update cab_third_party
    <set >
      <if test="ckuUserId != null" >
        cku_user_id = #{ckuUserId,jdbcType=VARCHAR},
      </if>
      <if test="wx != null" >
        wx = #{wx,jdbcType=VARCHAR},
      </if>
      <if test="qq != null" >
        qq = #{qq,jdbcType=VARCHAR},
      </if>
      <if test="sina != null" >
        sina = #{sina,jdbcType=VARCHAR},
      </if>
      <if test="tcb != null" >
        tcb = #{tcb,jdbcType=VARCHAR},
      </if>
      <if test="info != null" >
        info = #{info,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleteflag != null" >
        deleteFlag = #{deleteflag,jdbcType=INTEGER},
      </if>
    </set>
    where cab_user_id = #{cabUserId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.cab.model.CabThirdParty" >
    update cab_third_party
    <set >
      <if test="cabUserId != null" >
        cab_user_id = #{cabUserId,jdbcType=INTEGER},
      </if>
      <if test="ckuUserId != null" >
        cku_user_id = #{ckuUserId,jdbcType=VARCHAR},
      </if>
      <if test="wx != null" >
        wx = #{wx,jdbcType=VARCHAR},
      </if>
      <if test="qq != null" >
        qq = #{qq,jdbcType=VARCHAR},
      </if>
      <if test="sina != null" >
        sina = #{sina,jdbcType=VARCHAR},
      </if>
      <if test="tcb != null" >
        tcb = #{tcb,jdbcType=VARCHAR},
      </if>
      <if test="info != null" >
        info = #{info,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleteflag != null" >
        deleteFlag = #{deleteflag,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cab.model.CabThirdParty" >
    update cab_third_party
    set cab_user_id = #{cabUserId,jdbcType=INTEGER},
      cku_user_id = #{ckuUserId,jdbcType=VARCHAR},
      wx = #{wx,jdbcType=VARCHAR},
      qq = #{qq,jdbcType=VARCHAR},
      sina = #{sina,jdbcType=VARCHAR},
      tcb = #{tcb,jdbcType=VARCHAR},
      info = #{info,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP},
      deleteFlag = #{deleteflag,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>