<?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.iamberry.wechat.service.mapper.FirstJoinKeyMapper">
	
	<!-- 查询首次关注回复的消息 -->
	<select id="selectOne" parameterType="String" resultMap="toFirstJoinKey" >
		SELECT 
			id, createTime, imageTextNo, reMessageType, reText, title, vchar1, vchar2, vchar3, vchar4, wxpublicNo
		FROM
		    TB_WX_FIRSTJOINKEY
		WHERE
			WXPUBLICNO = #{wxpublicNo}
		LIMIT
			0, 1
	</select>
	
	<resultMap type="FirstJoinKey" id="toFirstJoinKey">
		<id property="id" column="id"/>
		<result property="createTime" column="createTime"/>
		<result property="imageTextNo" column="imageTextNo"/>
		<result property="reMessageType" column="reMessageType"/>
		<result property="reText" column="reText"/>
		<result property="title" column="title"/>
		<result property="vchar1" column="vchar1"/>
		<result property="vchar2" column="vchar2"/>
		<result property="vchar3" column="vchar3"/>
		<result property="vchar4" column="vchar4"/>
		<result property="wxpublicNo" column="wxpublicNo"/>
	</resultMap>
	
	
	<update id="updateOne">
		UPDATE
			TB_WX_FIRSTJOINKEY 
		SET
			CREATETIME = #{createTime},
			IMAGETEXTNO = #{imageTextNo},
			REMESSAGETYPE = #{reMessageType},
			RETEXT = #{reText},
			TITLE = #{title},
			VCHAR1 = #{vchar1},
			VCHAR2 = #{vchar2},
			VCHAR3 = #{vchar3},
			VCHAR4 = #{vchar4}
		WHERE
			WXPUBLICNO = #{wxpublicNo}
	</update>
	
	<insert id="addOne">
		INSERT INTO
			TB_WX_FIRSTJOINKEY (CREATETIME,IMAGETEXTNO,REMESSAGETYPE,RETEXT,TITLE,VCHAR1,VCHAR2,VCHAR3,VCHAR4,WXPUBLICNO)
		VALUES(#{createTime},#{imageTextNo},#{reMessageType},#{reText},#{title},#{vchar1},#{vchar2},#{vchar3},#{vchar4},#{wxpublicNo})
	</insert>
</mapper>