<?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.hm.HmQrcodeTempMapper">
	<resultMap type="com.gic.haoban.manage.service.entity.hm.TabHmQrcodeTemp"
		id="result-map-tabHaobanHmQrcodeTemp">
		<result column="id" property="id" />
		<result column="wx_config_id" property="wxConfigId" />
		<result column="wx_qrcode" property="wxQrcode" />
		<result column="wx_enterprise_id" property="wxEnterpriseId" />
		<result column="create_time" property="createTime" />
		<result column="update_time" property="updateTime" />
		<result column="status_flag" property="statusFlag" />
		<result column="relation_id" property="relationId" />
		<result column="corpid" property="corpid"/>
	</resultMap>
	<sql id="Base_Column_List">
		id,
		wx_config_id,
		wx_qrcode,
		wx_enterprise_id, corpid ,
		create_time,
		update_time,
		status_flag , relation_id
	</sql>
	<!-- ===================== 新增 ======================== -->
	<insert id="insert" parameterType="com.gic.haoban.manage.service.entity.hm.TabHmQrcodeTemp">
  <![CDATA[
  INSERT INTO tab_haoban_hm_qrcode_temp(
  	  id,
	  wx_config_id,
	  wx_qrcode,
	  wx_enterprise_id,
	  create_time,
	  update_time,
	  status_flag , relation_id , corpid
  )VALUES(
  	  #{id} ,
	  #{wxConfigId,jdbcType=VARCHAR},
	  #{wxQrcode,jdbcType=VARCHAR},
	  #{wxEnterpriseId,jdbcType=CHAR},
	  #{createTime,jdbcType=TIMESTAMP},
	  #{updateTime,jdbcType=TIMESTAMP},
	  #{statusFlag,jdbcType=INTEGER} , #{relationId} , #{corpid}
  )
  ]]>
	</insert>

	<!-- =====================删除==================== -->
	<update id="deleteByPrimaryKey" parameterType="long">
		UPDATE tab_haoban_hm_qrcode_temp SET status_flag = 0 , update_time=now() WHERE id = #{id} and status_flag=1
	</update>


	<select id="listAll" resultMap="result-map-tabHaobanHmQrcodeTemp">
		select <include refid="Base_Column_List" /> from tab_haoban_hm_qrcode_temp where create_time >= DATE_ADD(now(),INTERVAL -6 HOUR)  and create_time <![CDATA[<=]]> DATE_ADD(now(),INTERVAL -1 HOUR) and  status_flag = 1  limit 10000
	</select>
</mapper> 