<?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.cool.store.mapper.HyPartnerUserPlatformBindMapper">
  <resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerUserPlatformBindDO">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="platform_type" jdbcType="VARCHAR" property="platformType" />
    <result column="platform_user_id" jdbcType="VARCHAR" property="platformUserId" />
    <result column="bind_time" jdbcType="TIMESTAMP" property="bindTime" />
    <result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, platform_type, platform_user_id, bind_time, partner_id, create_time, update_time
  </sql>
  <insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
    insert into hy_partner_user_platform_bind
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="record.platformType != null">
        platform_type,
      </if>
      <if test="record.platformUserId != null">
        platform_user_id,
      </if>
      <if test="record.bindTime != null">
        bind_time,
      </if>
      <if test="record.partnerId != null">
        partner_id,
      </if>
      <if test="record.createTime != null">
        create_time,
      </if>
      <if test="record.updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="record.platformType != null">
        #{record.platformType},
      </if>
      <if test="record.platformUserId != null">
        #{record.platformUserId},
      </if>
      <if test="record.bindTime != null">
        #{record.bindTime},
      </if>
      <if test="record.partnerId != null">
        #{record.partnerId},
      </if>
      <if test="record.createTime != null">
        #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        #{record.updateTime},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective">
    update hy_partner_user_platform_bind
    <set>
      <if test="record.platformType != null">
        platform_type = #{record.platformType},
      </if>
      <if test="record.platformUserId != null">
        platform_user_id = #{record.platformUserId},
      </if>
      <if test="record.bindTime != null">
        bind_time = #{record.bindTime},
      </if>
      <if test="record.partnerId != null">
        partner_id = #{record.partnerId},
      </if>
      <if test="record.createTime != null">
        create_time = #{record.createTime},
      </if>
      <if test="record.updateTime != null">
        update_time = #{record.updateTime},
      </if>
    </set>
    where id = #{record.id}
  </update>

  <select id="getByPlatformTypeAndUserId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"></include>
    from
    hy_partner_user_platform_bind
    where platform_type = #{platformType} and platform_user_id = #{platformUserId}
  </select>

  <select id="getByPartnerId" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List"></include>
    from hy_partner_user_platform_bind
    where partner_id = #{partnerId}
  </select>

</mapper>