<?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.cf.ucenter.dao.mapper.CfUserFriendAddLogMapper" >
  <resultMap id="BaseResultMap" type="com.cf.ucenter.domain.CfUserFriendAddLog" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="from_uid" property="fromUid" jdbcType="VARCHAR" />
    <result column="to_uid" property="toUid" jdbcType="VARCHAR" />
    <result column="group_id" property="groupId" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="BIGINT" />
    <result column="status" property="status" jdbcType="BIT" />
    <result column="remark" property="remark" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="BIT" />
  </resultMap>
    <resultMap id="FullResultMap" type="com.cf.ucenter.domain.CfUserFriendAddLog">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="from_uid" property="fromUid" jdbcType="VARCHAR"/>
        <result column="to_uid" property="toUid" jdbcType="VARCHAR"/>
        <result column="group_id" property="groupId" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="BIGINT"/>
        <result column="status" property="status" jdbcType="BIT"/>
        <result column="remark" property="remark" jdbcType="VARCHAR"/>
        <result column="type" property="type" jdbcType="BIT"/>
        <result column="nick_name" property="nickName" jdbcType="VARCHAR"/>
        <result column="avatar" property="avatar" jdbcType="VARCHAR"/>
    </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    id, from_uid, to_uid, group_id, create_time, status, remark, type
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.cf.ucenter.domain.CfUserFriendAddLogExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from cf_user_friend_add_log
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from cf_user_friend_add_log
    where id = #{id,jdbcType=VARCHAR}
  </select>
    <select id="getFriendRequestsByUid" resultMap="FullResultMap">
    select fl.*,u.nick_name,u.avatar from cf_user_friend_add_log fl left join cf_user u on(fl.from_uid=u.id)
    where fl.to_uid=#{uid,jdbcType=VARCHAR} order by fl.create_time desc limit #{page,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
  </select>
  <select id="getFriendRequestsByFidAndTidAndStatus" resultMap="BaseResultMap">
    select * from cf_user_friend_add_log where from_uid=#{fromUid,jdbcType=VARCHAR} and to_uid=#{toUid,jdbcType=VARCHAR} and
    status = #{status,jdbcType=TINYINT} limit #{page,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
  </select>
  <select id="getFriendRequestsByFidAndGidAndStatus" resultMap="BaseResultMap">
    select * from cf_user_friend_add_log where from_uid=#{fromUid,jdbcType=VARCHAR} and group_id=#{groupId,jdbcType=VARCHAR} and
    status = #{status,jdbcType=TINYINT} order by create_time desc limit #{page,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from cf_user_friend_add_log
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <delete id="deleteByExample" parameterType="com.cf.ucenter.domain.CfUserFriendAddLogExample" >
    delete from cf_user_friend_add_log
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.cf.ucenter.domain.CfUserFriendAddLog" >
    insert into cf_user_friend_add_log (id, from_uid, to_uid, 
      group_id, create_time, status, 
      remark, type)
    values (#{id,jdbcType=VARCHAR}, #{fromUid,jdbcType=VARCHAR}, #{toUid,jdbcType=VARCHAR}, 
      #{groupId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{status,jdbcType=BIT}, 
      #{remark,jdbcType=VARCHAR}, #{type,jdbcType=BIT})
  </insert>
  <insert id="insertSelective" parameterType="com.cf.ucenter.domain.CfUserFriendAddLog" >
    insert into cf_user_friend_add_log
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="fromUid != null" >
        from_uid,
      </if>
      <if test="toUid != null" >
        to_uid,
      </if>
      <if test="groupId != null" >
        group_id,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="status != null" >
        status,
      </if>
      <if test="remark != null" >
        remark,
      </if>
      <if test="type != null" >
        type,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="fromUid != null" >
        #{fromUid,jdbcType=VARCHAR},
      </if>
      <if test="toUid != null" >
        #{toUid,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null" >
        #{groupId,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=BIGINT},
      </if>
      <if test="status != null" >
        #{status,jdbcType=BIT},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        #{type,jdbcType=BIT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.cf.ucenter.domain.CfUserFriendAddLogExample" resultType="java.lang.Integer" >
    select count(*) from cf_user_friend_add_log
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update cf_user_friend_add_log
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.fromUid != null" >
        from_uid = #{record.fromUid,jdbcType=VARCHAR},
      </if>
      <if test="record.toUid != null" >
        to_uid = #{record.toUid,jdbcType=VARCHAR},
      </if>
      <if test="record.groupId != null" >
        group_id = #{record.groupId,jdbcType=VARCHAR},
      </if>
      <if test="record.createTime != null" >
        create_time = #{record.createTime,jdbcType=BIGINT},
      </if>
      <if test="record.status != null" >
        status = #{record.status,jdbcType=BIT},
      </if>
      <if test="record.remark != null" >
        remark = #{record.remark,jdbcType=VARCHAR},
      </if>
      <if test="record.type != null" >
        type = #{record.type,jdbcType=BIT},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update cf_user_friend_add_log
    set id = #{record.id,jdbcType=VARCHAR},
      from_uid = #{record.fromUid,jdbcType=VARCHAR},
      to_uid = #{record.toUid,jdbcType=VARCHAR},
      group_id = #{record.groupId,jdbcType=VARCHAR},
      create_time = #{record.createTime,jdbcType=BIGINT},
      status = #{record.status,jdbcType=BIT},
      remark = #{record.remark,jdbcType=VARCHAR},
      type = #{record.type,jdbcType=BIT}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.cf.ucenter.domain.CfUserFriendAddLog" >
    update cf_user_friend_add_log
    <set >
      <if test="fromUid != null" >
        from_uid = #{fromUid,jdbcType=VARCHAR},
      </if>
      <if test="toUid != null" >
        to_uid = #{toUid,jdbcType=VARCHAR},
      </if>
      <if test="groupId != null" >
        group_id = #{groupId,jdbcType=VARCHAR},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=BIGINT},
      </if>
      <if test="status != null" >
        status = #{status,jdbcType=BIT},
      </if>
      <if test="remark != null" >
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=BIT},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cf.ucenter.domain.CfUserFriendAddLog" >
    update cf_user_friend_add_log
    set from_uid = #{fromUid,jdbcType=VARCHAR},
      to_uid = #{toUid,jdbcType=VARCHAR},
      group_id = #{groupId,jdbcType=VARCHAR},
      create_time = #{createTime,jdbcType=BIGINT},
      status = #{status,jdbcType=BIT},
      remark = #{remark,jdbcType=VARCHAR},
      type = #{type,jdbcType=BIT}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateStatus" >
    update cf_user_friend_add_log
    set status = #{status,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateCreateTime" >
    update cf_user_friend_add_log
    set create_time = #{createTime,jdbcType=BIGINT}
    where id = #{id,jdbcType=VARCHAR}
  </update>
</mapper>