<?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.gic.haoban.manage.service.dao.mapper.TabHaobanUserMapper">
  <resultMap type="com.gic.haoban.manage.service.entity.TabHaobanUser" id="result-map-tabHaobanUser">
      <result column="user_id"  property="userId"/>
      <result column="wx_enterprise_id"  property="wxEnterpriseId"/>
      <result column="phone_number"  property="phoneNumber"/>
      <result column="status_flag"  property="statusFlag"/>
      <result column="create_time"  property="createTime"/>
      <result column="update_time"  property="updateTime"/>
      <result column="default_gic_eid"  property="defaultGicEid"/>
  </resultMap>
  <sql id="Base_Column_List">
	  user_id,
	  wx_enterprise_id,
	  phone_number,
	  status_flag,
	  create_time,
	  update_time,
	  default_gic_eid
  </sql>
  <!-- ===================== 新增 ======================== -->
  <insert id="insert" parameterType="tabHaobanUser" useGeneratedKeys="true" keyProperty="id">
  <![CDATA[
  INSERT INTO tab_haoban_user(
	  user_id,
	  wx_enterprise_id,
	  phone_number,
	  status_flag,
	  create_time,
	  update_time,
	  default_gic_eid
  )VALUES(
	  #{userId,jdbcType=CHAR},
	  #{wxEnterpriseId,jdbcType=VARCHAR},
	  #{phoneNumber,jdbcType=VARCHAR},
	  #{statusFlag,jdbcType=INTEGER},
	  #{createTime,jdbcType=TIMESTAMP},
	  #{updateTime,jdbcType=TIMESTAMP},
	  #{defaultGicEid,jdbcType=VARCHAR}
  )
  ]]>
  </insert>
  
    <update id="updateDefaultGicEid">
    	update tab_haoban_user set default_gic_eid = #{gicEid} where user_id = #{userId}
    </update>
  
  <!-- ============ 查询=============-->
  <select id="selectByPhone"  resultMap="result-map-tabHaobanUser">
  SELECT * FROM tab_haoban_user WHERE wx_enterprise_id=#{wxEnterpriseId} and phone_number=#{phone}
  </select>
  
  <select id="selectById"  resultMap="result-map-tabHaobanUser">
  	SELECT * FROM tab_haoban_user WHERE user_id=#{userId} 
  </select>
  
</mapper> 