<?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.QywxTagMapper">
  <resultMap id="BaseResultMap" type="com.gic.haoban.manage.service.entity.TabQywxTag">
    <id column="qywx_tag_id" jdbcType="VARCHAR" property="qywxTagId"/>
    <result column="wx_enterprise_id" jdbcType="VARCHAR" property="wxEnterpriseId"/>
    <result column="qywx_group_key" jdbcType="VARCHAR" property="qywxGroupKey"/>
    <result column="qywx_group_name" jdbcType="VARCHAR" property="qywxGroupName"/>
    <result column="order" jdbcType="BIGINT" property="order"/>
    <result column="status_flag" jdbcType="INTEGER" property="statusFlag"/>
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  </resultMap>
  <sql id="Base_Column_List">
    qywx_tag_id, wx_enterprise_id, qywx_group_key, qywx_group_name, `order`, status_flag,
    create_time, update_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from tab_haoban_qywx_tag
    where qywx_tag_id = #{qywxTagId,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from tab_haoban_qywx_tag
    where qywx_tag_id = #{qywxTagId,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.gic.haoban.manage.service.entity.TabQywxTag">
    insert into tab_haoban_qywx_tag (qywx_tag_id, wx_enterprise_id, qywx_group_key, 
      qywx_group_name, `order`, status_flag,
      create_time, update_time)
    values (#{qywxTagId,jdbcType=VARCHAR}, #{wxEnterpriseId,jdbcType=VARCHAR}, #{qywxGroupKey,jdbcType=VARCHAR}, 
      #{qywxGroupName,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT}, #{statusFlag,jdbcType=INTEGER}, 
      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.gic.haoban.manage.service.entity.TabQywxTag">
    insert into tab_haoban_qywx_tag
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="qywxTagId != null">
        qywx_tag_id,
      </if>
      <if test="wxEnterpriseId != null">
        wx_enterprise_id,
      </if>
      <if test="qywxGroupKey != null">
        qywx_group_key,
      </if>
      <if test="qywxGroupName != null">
        qywx_group_name,
      </if>
      <if test="order != null">
        `order`,
      </if>
      <if test="statusFlag != null">
        status_flag,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="qywxTagId != null">
        #{qywxTagId,jdbcType=VARCHAR},
      </if>
      <if test="wxEnterpriseId != null">
        #{wxEnterpriseId,jdbcType=VARCHAR},
      </if>
      <if test="qywxGroupKey != null">
        #{qywxGroupKey,jdbcType=VARCHAR},
      </if>
      <if test="qywxGroupName != null">
        #{qywxGroupName,jdbcType=VARCHAR},
      </if>
      <if test="order != null">
        #{order,jdbcType=BIGINT},
      </if>
      <if test="statusFlag != null">
        #{statusFlag,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.TabQywxTag">
    update tab_haoban_qywx_tag
    <set>
      <if test="wxEnterpriseId != null">
        wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
      </if>
      <if test="qywxGroupKey != null">
        qywx_group_key = #{qywxGroupKey,jdbcType=VARCHAR},
      </if>
      <if test="qywxGroupName != null">
        qywx_group_name = #{qywxGroupName,jdbcType=VARCHAR},
      </if>
      <if test="order != null">
        `order` = #{order,jdbcType=BIGINT},
      </if>
      <if test="statusFlag != null">
        status_flag = #{statusFlag,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 qywx_tag_id = #{qywxTagId,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gic.haoban.manage.service.entity.TabQywxTag">
    update tab_haoban_qywx_tag
    set wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR},
      qywx_group_key = #{qywxGroupKey,jdbcType=VARCHAR},
      qywx_group_name = #{qywxGroupName,jdbcType=VARCHAR},
      `order` = #{order,jdbcType=BIGINT},
      status_flag = #{statusFlag,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      update_time = #{updateTime,jdbcType=TIMESTAMP}
    where qywx_tag_id = #{qywxTagId,jdbcType=VARCHAR}
  </update>

  <select id="getByQywxGroupKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from tab_haoban_qywx_tag
    where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
    and qywx_group_key=#{qywxTagGroupKey}
    and status_flag=1
  </select>
  <update id="delByGroupKey">
    UPDATE
      tab_haoban_qywx_tag
    SET
      status_flag=0,
      update_time=now()
    where wx_enterprise_id = #{wxEnterpriseId,jdbcType=VARCHAR}
    and qywx_group_key=#{qywxTagGroupKey}
    and status_flag=1
  </update>
</mapper>