<?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.TpActivitySignupMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpActivitySignup" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="activity_id" property="activityId" jdbcType="INTEGER" />
    <result column="ta_user_id" property="taUserId" jdbcType="INTEGER" />
    <result column="sign_up_time" property="signUpTime" jdbcType="TIMESTAMP" />
    <result column="address" property="address" jdbcType="VARCHAR" />
    <result column="user_role" property="userRole" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, activity_id, ta_user_id, sign_up_time, remark, address, user_role
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from tp_activity_sign_up
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_activity_sign_up
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpActivitySignup" >
    insert into tp_activity_sign_up (id, community_id, activity_id, 
      ta_user_id, sign_up_time, remark, address, user_role
      )
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, 
      #{taUserId,jdbcType=INTEGER}, #{signUpTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR},
      #{address,jdbcType=VARCHAR}, #{userRole,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpActivitySignup" >
    insert into tp_activity_sign_up
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="activityId != null" >
        activity_id,
      </if>
      <if test="taUserId != null" >
        ta_user_id,
      </if>
      <if test="signUpTime != null" >
        sign_up_time,
      </if>
      <if test="remark != null" >
        remark,
      </if>
      <if test="address != null">
        address,
      </if>
      <if test="userRole">
        user_role,
      </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="activityId != null" >
        #{activityId,jdbcType=INTEGER},
      </if>
      <if test="taUserId != null" >
        #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="signUpTime != null" >
        #{signUpTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        #{address,jdbcType=VARCHAR},
      </if>
      <if test="userRole != null">
        #{userRole,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpActivitySignup" >
    update tp_activity_sign_up
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="activityId != null" >
        activity_id = #{activityId,jdbcType=INTEGER},
      </if>
      <if test="taUserId != null" >
        ta_user_id = #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="signUpTime != null" >
        sign_up_time = #{signUpTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null" >
        remark = #{remark,jdbcType=VARCHAR},
      </if>
      <if test="address != null">
        address = #{address,jdbcType=VARCHAR},
      </if>
      <if test="userRole">
        user_role = #{userRole,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpActivitySignup" >
    update tp_activity_sign_up
    set community_id = #{communityId,jdbcType=INTEGER},
      activity_id = #{activityId,jdbcType=INTEGER},
      ta_user_id = #{taUserId,jdbcType=INTEGER},
      sign_up_time = #{signUpTime,jdbcType=TIMESTAMP},
      remark = #{remark,jdbcType=VARCHAR},
      address = #{address,jdbcType=VARCHAR},
      user_role = #{userRole,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="sumActivitySignUpNum" resultType="java.lang.Integer">
    select
    count(*)
    from tp_activity_sign_up
    where activity_id = #{id,jdbcType=INTEGER} and community_id = #{communityId}
  </select>

  <select id="findTpActivetitySignByUserId" resultType="java.lang.Integer">
    select
    count(*)
    from tp_activity_sign_up
    where activity_id = #{activityId} and community_id = #{communityId} and ta_user_id = #{userId}
  </select>


  <select id="selectSignNum" resultType="java.lang.Integer">
    select
    count(*)
    from tp_activity_sign_up
    where activity_id = #{activityId} and community_id = #{communityId}
  </select>

  <delete id="deleteSignUp" parameterType="com.community.huiju.model.TpActivitySignup" >
    delete from tp_activity_sign_up
    where activity_id = #{activityId} and community_id = #{communityId} and ta_user_id = #{taUserId}
  </delete>

  <select id="selectTpActivetitySignByUserId" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from tp_activity_sign_up
    where activity_id = #{activityId} and community_id = #{communityId} and ta_user_id = #{userId}
  </select>
</mapper>