<?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="messageReadSqlMapper">
	
	<sql id="base_column">
		id,
		message_id as messageId,
		account_id as accountId,
	</sql>
	
	<insert id="addMessageRead" parameterType="com.cloudcross.ssp.model.MessageRead">
		insert into t_message_read (message_id,account_id)
		values(#{messageId},#{accountId})
	</insert>
	
<!-- 	<select id="selectByParams"  parameterType="map" resultType="Message">
		select 
		<include refid="base_column" />
		from t_message where 1 = 1
	
		<if test="type!=null">	
			and t_message.type = #{type}
		</if>
		
		order by id   desc
		limit #{pager.offset}, #{pager.limit}
	</select>
	
	<select id="countByParams" parameterType="map" resultType="int">
		select count(id)
		from t_message where 1 = 1	
	</select>
	
	<update id="updateRead" parameterType="HashMap">
	update t_order 
		set t_message.read = #{read},send_time = #{modifyDate}
		where t_message.id in
		<foreach item="messageId" collection="messageIdList"
	      open="(" separator="," close=")">
	        #{messageId}
		</foreach>
	</update>

	 -->
	<select id="selectByAccountId" parameterType="java.lang.Long" resultType="long">
		select message_id from t_message_read where 1=1
		
		<if test="_parameter!=null">	
		 and t_message_read.account_id = #{_parameter,jdbcType=VARCHAR}
		</if>
		
	</select>
	

	
</mapper>
	
