<?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.TabHaobanMemberClerkChatConfigMapper">
  <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.MemberClerkChatConfig">
    <id column="member_clerk_chat_config_id" jdbcType="INTEGER" property="memberClerkChatConfigId" />
    <result column="staff_id" jdbcType="VARCHAR" property="staffId" />
    <result column="enterprise_id" jdbcType="VARCHAR" property="enterpriseId" />
    <result column="member_id" jdbcType="VARCHAR" property="memberId" />
    <result column="config_id" jdbcType="VARCHAR" property="configId" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  </resultMap>
  <sql id="Base_Column_List">
    member_clerk_chat_config_id, staff_id, enterprise_id, member_id, config_id, status, 
    create_time, update_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from tab_haoban_member_clerk_chat_config
    where member_clerk_chat_config_id = #{memberClerkChatConfigId,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from tab_haoban_member_clerk_chat_config
    where member_clerk_chat_config_id = #{memberClerkChatConfigId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.MemberClerkChatConfig">
    insert into tab_haoban_member_clerk_chat_config (member_clerk_chat_config_id, staff_id, 
      enterprise_id, member_id, config_id, 
      status, create_time, update_time
      )
    values (#{memberClerkChatConfigId,jdbcType=INTEGER}, #{staffId,jdbcType=VARCHAR}, 
      #{enterpriseId,jdbcType=VARCHAR}, #{memberId,jdbcType=VARCHAR}, #{configId,jdbcType=VARCHAR}, 
      #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.MemberClerkChatConfig">
    insert into tab_haoban_member_clerk_chat_config
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="memberClerkChatConfigId != null">
        member_clerk_chat_config_id,
      </if>
      <if test="staffId != null">
        staff_id,
      </if>
      <if test="enterpriseId != null">
        enterprise_id,
      </if>
      <if test="memberId != null">
        member_id,
      </if>
      <if test="configId != null">
        config_id,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="memberClerkChatConfigId != null">
        #{memberClerkChatConfigId,jdbcType=INTEGER},
      </if>
      <if test="staffId != null">
        #{staffId,jdbcType=VARCHAR},
      </if>
      <if test="enterpriseId != null">
        #{enterpriseId,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="configId != null">
        #{configId,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.gic.haoban.manage.service.entity.MemberClerkChatConfig">
    update tab_haoban_member_clerk_chat_config
    <set>
      <if test="staffId != null">
        staff_id = #{staffId,jdbcType=VARCHAR},
      </if>
      <if test="enterpriseId != null">
        enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
      </if>
      <if test="memberId != null">
        member_id = #{memberId,jdbcType=VARCHAR},
      </if>
      <if test="configId != null">
        config_id = #{configId,jdbcType=VARCHAR},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </set>
    where member_clerk_chat_config_id = #{memberClerkChatConfigId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.MemberClerkChatConfig">
    update tab_haoban_member_clerk_chat_config
    set staff_id = #{staffId,jdbcType=VARCHAR},
      enterprise_id = #{enterpriseId,jdbcType=VARCHAR},
      member_id = #{memberId,jdbcType=VARCHAR},
      config_id = #{configId,jdbcType=VARCHAR},
      status = #{status,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where member_clerk_chat_config_id = #{memberClerkChatConfigId,jdbcType=INTEGER}
  </update>

  <select id="getChatByMemberIdStaffId"  resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from tab_haoban_member_clerk_chat_config
    where staff_id = #{staffId,jdbcType=VARCHAR} and member_id = #{memberId,jdbcType=VARCHAR}
    and status =1
  </select>
  
</mapper>