<?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.TaVisitorMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TaVisitor" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="visitor_name" property="visitorName" jdbcType="VARCHAR" />
    <result column="visitor_tel" property="visitorTel" jdbcType="VARCHAR" />
    <result column="visitor_num" property="visitorNum" jdbcType="VARCHAR" />
    <result column="visitor_start_time" property="visitorStartTime" jdbcType="TIMESTAMP" />
    <result column="visitor_end_time" property="visitorEndTime" jdbcType="TIMESTAMP" />
    <result column="driving_status" property="drivingStatus" jdbcType="CHAR" />
    <result column="pay_entity" property="payEntity" jdbcType="VARCHAR" />
    <result column="visitor_code" property="visitorCode" jdbcType="VARCHAR" />
    <result column="ta_user_id" property="taUserId" jdbcType="INTEGER" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
    <result column="update_darte" property="updateDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, visitor_name, visitor_tel, visitor_num, visitor_start_time, visitor_end_time,
    driving_status, pay_entity, visitor_code, ta_user_id, create_user, create_date, update_user, 
    update_darte
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from ta_visitor
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from ta_visitor
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TaVisitor" >
    insert into ta_visitor (id, community_id, visitor_name, 
      visitor_tel, visitor_num, visitor_start_time,
      visitor_end_time, driving_status, pay_entity, 
      visitor_code, ta_user_id, create_user, 
      create_date, update_user, update_darte
      )
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{visitorName,jdbcType=VARCHAR}, 
      #{visitorTel,jdbcType=VARCHAR}, #{visitorNum,jdbcType=VARCHAR}, #{visitorStartTime,jdbcType=TIMESTAMP},
      #{visitorEndTime,jdbcType=TIMESTAMP}, #{drivingStatus,jdbcType=CHAR}, #{payEntity,jdbcType=VARCHAR},
      #{visitorCode,jdbcType=VARCHAR}, #{taUserId,jdbcType=INTEGER}, #{createUser,jdbcType=INTEGER}, 
      #{createDate,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TaVisitor" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
    insert into ta_visitor
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="visitorName != null" >
        visitor_name,
      </if>
      <if test="visitorTel != null" >
        visitor_tel,
      </if>
      <if test="visitorNum != null" >
        visitor_num,
      </if>
      <if test="visitorStartTime != null" >
        visitor_start_time,
      </if>
      <if test="visitorEndTime != null" >
        visitor_end_time,
      </if>
      <if test="drivingStatus != null" >
        driving_status,
      </if>
      <if test="payEntity != null" >
        pay_entity,
      </if>
      <if test="visitorCode != null" >
        visitor_code,
      </if>
      <if test="taUserId != null" >
        ta_user_id,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateUser != null" >
        update_user,
      </if>
      <if test="updateDate != null" >
        update_darte,
      </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="visitorName != null" >
        #{visitorName,jdbcType=VARCHAR},
      </if>
      <if test="visitorTel != null" >
        #{visitorTel,jdbcType=VARCHAR},
      </if>
      <if test="visitorNum != null" >
        #{visitorNum,jdbcType=VARCHAR},
      </if>
      <if test="visitorStartTime != null" >
        #{visitorStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="visitorEndTime != null" >
        #{visitorEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="drivingStatus != null" >
        #{drivingStatus,jdbcType=CHAR},
      </if>
      <if test="payEntity != null" >
        #{payEntity,jdbcType=VARCHAR},
      </if>
      <if test="visitorCode != null" >
        #{visitorCode,jdbcType=VARCHAR},
      </if>
      <if test="taUserId != null" >
        #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TaVisitor" >
    update ta_visitor
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="visitorName != null" >
        visitor_name = #{visitorName,jdbcType=VARCHAR},
      </if>
      <if test="visitorTel != null" >
        visitor_tel = #{visitorTel,jdbcType=VARCHAR},
      </if>
      <if test="visitorNum != null" >
        visitor_num = #{visitorNum,jdbcType=VARCHAR},
      </if>
      <if test="visitorStartTime != null" >
        visitor_start_time = #{visitorStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="visitorEndTime != null" >
        visitor_end_time = #{visitorEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="drivingStatus != null" >
        driving_status = #{drivingStatus,jdbcType=CHAR},
      </if>
      <if test="payEntity != null" >
        pay_entity = #{payEntity,jdbcType=VARCHAR},
      </if>
      <if test="visitorCode != null" >
        visitor_code = #{visitorCode,jdbcType=VARCHAR},
      </if>
      <if test="taUserId != null" >
        ta_user_id = #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        update_darte = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TaVisitor" >
    update ta_visitor
    set community_id = #{communityId,jdbcType=INTEGER},
      visitor_name = #{visitorName,jdbcType=VARCHAR},
      visitor_tel = #{visitorTel,jdbcType=VARCHAR},
      visitor_num = #{visitorNum,jdbcType=VARCHAR},
      visitor_start_time = #{visitorStartTime,jdbcType=TIMESTAMP},
      visitor_end_time = #{visitorEndTime,jdbcType=TIMESTAMP},
      driving_status = #{drivingStatus,jdbcType=CHAR},
      pay_entity = #{payEntity,jdbcType=VARCHAR},
      visitor_code = #{visitorCode,jdbcType=VARCHAR},
      ta_user_id = #{taUserId,jdbcType=INTEGER},
      create_user = #{createUser,jdbcType=INTEGER},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER},
      update_darte = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <insert id="insertVistorAndLicense" parameterType="com.community.huiju.model.TaVisitor" >
    insert into ta_visitor
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="visitorName != null" >
        visitor_name,
      </if>
      <if test="visitorTel != null" >
        visitor_tel,
      </if>
      <if test="visitorNum != null" >
        visitor_num,
      </if>
      <if test="visitorStartTime != null" >
        visitor_start_time,
      </if>
      <if test="visitorEndTime != null" >
        visitor_end_time,
      </if>
      <if test="drivingStatus != null" >
        driving_status,
      </if>
      <if test="payEntity != null" >
        pay_entity,
      </if>
      <if test="visitorCode != null" >
        visitor_code,
      </if>
      <if test="taUserId != null" >
        ta_user_id,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateUser != null" >
        update_user,
      </if>
      <if test="updateDate != null" >
        update_darte,
      </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="visitorName != null" >
        #{visitorName,jdbcType=VARCHAR},
      </if>
      <if test="visitorTel != null" >
        #{visitorTel,jdbcType=VARCHAR},
      </if>
      <if test="visitorNum != null" >
        #{visitorNum,jdbcType=VARCHAR},
      </if>
      <if test="visitorStartTime != null" >
        #{visitorStartTime,jdbcType=TIMESTAMP},
      </if>
      <if test="visitorEndTime != null" >
        #{visitorEndTime,jdbcType=TIMESTAMP},
      </if>
      <if test="drivingStatus != null" >
        #{drivingStatus,jdbcType=CHAR},
      </if>
      <if test="payEntity != null" >
        #{payEntity,jdbcType=VARCHAR},
      </if>
      <if test="visitorCode != null" >
        #{visitorCode,jdbcType=VARCHAR},
      </if>
      <if test="taUserId != null" >
        #{taUserId,jdbcType=INTEGER},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

  <select id="findAllVistors" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from ta_visitor
    where community_id = #{communityId,jdbcType=INTEGER}
    and ta_user_id = #{userId,jdbcType=INTEGER}
    order by create_date DESC
  </select>
</mapper>