<?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="messageSqlMapper">
	
	<sql id="base_column">
		t_message.id,
		t_message.content,	
		t_message.send_time as sendTime,
		t_message.type
	</sql>
	
	<insert id="addMessage" parameterType="com.cloudcross.ssp.model.Message">
		insert into t_message(content,send_time,type)
		values(#{content},#{sendTime},#{type})
	</insert>
	
	<select id="selectByParams"  parameterType="map" resultType="com.cloudcross.ssp.model.Message">
		select 
		<include refid="base_column" />
		from t_message
		<where>
			<if test="type!=null">	
				and type = #{type}
			</if>
			<if test="value!=null">	
				and content like #{value}
			</if>
		</where>	
		
		order by id   desc
		limit #{pager.offset}, #{pager.limit}
	</select>
	
	<select id="countByParams" parameterType="map" resultType="int">
		select count(id) from t_message
		<where>
			<if test="type!=null">	
				and type = #{type}
			</if>
			<if test="value!=null">	
				and content like #{value}
			</if>
		</where>	
	</select>

	
<select id="selectByType" parameterType="int" resultType="com.cloudcross.ssp.model.Message">
		select 
		<include refid="base_column" />
		from t_message
		<where>
		<if test="type!=null">	
			and type = #{type}
		</if>
			
		</where>
	</select>
<!-- 	
	<select id="selectByRead"  parameterType="int"  resultType="Message">
		select t_message.*,t_message_read.account_id 
	 from t_message left join t_message_read on t_message.id=t_message_read.message_id  	
	</select>	
	
<select id="selectByParams"  parameterType="map" resultType="Message">
		select 
		<include refid="base_column" />
		from t_message where 1 = 1
			
		<if test="type!=null">	
			and type = #{type}
		</if>
		
		order by id   desc
		limit #{pager.offset}, #{pager.limit}
	</select>


  -->	

	
</mapper>
	
