<?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.CuRelationMapper">
  <resultMap id="BaseResultMap" type="com.cab.model.CuRelationKey">
    <id column="user_id" jdbcType="BIGINT" property="userId" />
    <id column="content_id" jdbcType="BIGINT" property="contentId" />
    <id column="cu_type" jdbcType="INTEGER" property="cuType" />
  </resultMap>
  <select id="selectByUserAndContent" parameterType="com.cab.model.CuRelationKey" resultMap="BaseResultMap">
  	select user_id, content_id, cu_type from cab_cu_relation 
  	where user_id = #{userId,jdbcType=BIGINT}
      and content_id = #{contentId,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="com.cab.model.CuRelationKey">
    delete from cab_cu_relation
    where user_id = #{userId,jdbcType=BIGINT}
      and content_id = #{contentId,jdbcType=BIGINT}
      and cu_type = #{cuType,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cab.model.CuRelationKey">
    insert into cab_cu_relation (user_id, content_id, cu_type
      )
    values (#{userId,jdbcType=BIGINT}, #{contentId,jdbcType=BIGINT}, #{cuType,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.cab.model.CuRelationKey">
    insert into cab_cu_relation
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        user_id,
      </if>
      <if test="contentId != null">
        content_id,
      </if>
      <if test="cuType != null">
        cu_type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="userId != null">
        #{userId,jdbcType=BIGINT},
      </if>
      <if test="contentId != null">
        #{contentId,jdbcType=BIGINT},
      </if>
      <if test="cuType != null">
        #{cuType,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
</mapper>