<?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">
<!-- namespace必须指向DAO接口 -->
<mapper namespace="com.jpsoft.shinestar.modules.wechat.dao.ReplyMessageDAO">
    <sql id="Base_Column_List">
    id_,
    event_,
    message_,
    callback_url,
    create_time,
    update_time
</sql>
    <resultMap id="ReplyMessageMap" type="com.jpsoft.shinestar.modules.wechat.entity.ReplyMessage">
		<id property="id" column="id_" />
			<result property="event" column="event_" />
			<result property="message" column="message_" />
			<result property="callbackUrl" column="callback_url" />
			<result property="createTime" column="create_time" />
			<result property="updateTime" column="update_time" />
			</resultMap>
	<insert id="insert" parameterType="com.jpsoft.shinestar.modules.wechat.entity.ReplyMessage">
	<!--
	<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
		select sys_guid() from dual
	</selectKey>
	-->
	<![CDATA[
		insert into wechat_reply_message
	    (id_,event_,message_,callback_url,create_time,update_time)
		values
		(
#{id,jdbcType=VARCHAR}
,#{event,jdbcType=VARCHAR}
,#{message,jdbcType=VARCHAR}
,#{callbackUrl,jdbcType=VARCHAR}
,#{createTime,jdbcType= TIMESTAMP }
,#{updateTime,jdbcType= TIMESTAMP }
		)
	]]>
	</insert>
	<delete id="delete" parameterType="string">
		delete from wechat_reply_message where id_=#{id,jdbcType=VARCHAR}
	</delete>
	<update id="update" parameterType="com.jpsoft.shinestar.modules.wechat.entity.ReplyMessage">
		update wechat_reply_message
		<set>
				<if test="event!=null">
		event_=#{event,jdbcType=VARCHAR},
		</if>
				<if test="message!=null">
		message_=#{message,jdbcType=VARCHAR},
		</if>
				<if test="callbackUrl!=null">
		callback_url=#{callbackUrl,jdbcType=VARCHAR},
		</if>
				<if test="createTime!=null">
		create_time=#{createTime,jdbcType= TIMESTAMP },
		</if>
				<if test="updateTime!=null">
		update_time=#{updateTime,jdbcType= TIMESTAMP },
		</if>
		</set>
	where id_=#{id}
	</update>
	<select id="get" parameterType="string" resultMap="ReplyMessageMap">
		select
id_,event_,message_,callback_url,create_time,update_time		from wechat_reply_message where id_=#{0}
	</select>
	<select id="exist" parameterType="string" resultType="int">
		select count(*) from wechat_reply_message where id_=#{0}
	</select>
	<select id="list" resultMap="ReplyMessageMap">
		select * from wechat_reply_message
	</select>
	<select id="search" parameterType="hashmap" resultMap="ReplyMessageMap">
		<![CDATA[
			select * from wechat_reply_message
		]]>
		<where>
			<if test="searchParams.id != null">
				and ID_ like #{searchParams.id}
			</if>
		</where>
		<foreach item="sort" collection="sortList"  open="order by" separator=",">
	        ${sort.name} ${sort.order}
	 	</foreach>
	</select>

<!--auto generated by MybatisCodeHelper on 2020-03-23-->
    <select id="findByEvent" resultMap="ReplyMessageMap">
        select
        <include refid="Base_Column_List"/>
        from wechat_reply_message
        where event_=#{event}
    </select>
</mapper>