<?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.community.huiju.dao.TpTransactionLikeMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpTransactionLike" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="ta_user_id" property="taUserId" jdbcType="INTEGER" />
    <result column="transaction_id" property="transactionId" jdbcType="INTEGER" />
    <result column="like_status" property="likeStatus" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, ta_user_id, transaction_id, like_status, create_date, update_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from tp_transaction_like
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_transaction_like
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpTransactionLike" >
    insert into tp_transaction_like (id, community_id, ta_user_id, 
      transaction_id, like_status, create_date, 
      update_date)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{taUserId,jdbcType=INTEGER}, 
      #{transactionId,jdbcType=INTEGER}, #{likeStatus,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpTransactionLike" >
    insert into tp_transaction_like
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="taUserId != null" >
        ta_user_id,
      </if>
      <if test="transactionId != null" >
        transaction_id,
      </if>
      <if test="likeStatus != null" >
        like_status,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateDate != null" >
        update_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="communityId != null" >
        #{communityId,jdbcType=INTEGER},
      </if>
      <if test="taUserId != null" >
        #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="transactionId != null" >
        #{transactionId,jdbcType=INTEGER},
      </if>
      <if test="likeStatus != null" >
        #{likeStatus,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpTransactionLike" >
    update tp_transaction_like
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="taUserId != null" >
        ta_user_id = #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="transactionId != null" >
        transaction_id = #{transactionId,jdbcType=INTEGER},
      </if>
      <if test="likeStatus != null" >
        like_status = #{likeStatus,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpTransactionLike" >
    update tp_transaction_like
    set community_id = #{communityId,jdbcType=INTEGER},
      ta_user_id = #{taUserId,jdbcType=INTEGER},
      transaction_id = #{transactionId,jdbcType=INTEGER},
      like_status = #{likeStatus,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_date = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="likeCount" resultType="int">
    SELECT COUNT(transaction_id) FROM
    tp_transaction_like
    WHERE like_status = 1
    and   community_id = #{communityId,jdbcType=INTEGER}
    and   transaction_id = #{invitationId,jdbcType=INTEGER}
  </select>

  <select id="nolikeCount"  resultType="int">
    SELECT COUNT(transaction_id) FROM
    tp_transaction_like
    WHERE like_status = 2
    and   community_id = #{communityId,jdbcType=INTEGER}
    and   transaction_id = #{invitationId,jdbcType=INTEGER}
  </select>

  <select id="getinvitationId" resultMap="BaseResultMap">
    SELECT * FROM
    tp_transaction_like
    WHERE community_id = #{communityId,jdbcType=INTEGER}
    and   ta_user_verify_id = #{userId,jdbcType=INTEGER}
    and   transaction_id = #{invitationId,jdbcType=INTEGER}
  </select>
</mapper>