| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 | 
							- <?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:必须与对应的接口全类名一致
 
-  -->
 
- <mapper namespace="com.iamberry.app.mapper.MessageMapper">
 
- 	<sql id="messageAllField">
 
- 		ID,TITLE, CONTENT,URL,
 
- 		FORWORD,IS_NEEDSEND,IS_READ,
 
- 		CREATE_DATE,READ_DATE,SEND_TYPE,
 
- 		USER,REMARK,SEND_RESULT
 
- 	</sql>
 
- 	<!--通过<resultMap>映射实体类属性名和表的字段名对应关系 -->
 
-     <resultMap type="Message" id="messageMap">
 
-         <id property="id" column="ID"/>
 
-         <result property="title" column="TITLE"/>
 
-         <result property="content" column="CONTENT"/>
 
-         <result property="url" column="URL"/>
 
-         <result property="forword" column="FORWORD"/>
 
-         <result property="is_needsend" column="IS_NEEDSEND"/>
 
-         
 
-         <result property="is_read" column="IS_READ"/>
 
-         <result property="create_date" column="CREATE_DATE"/>
 
-         <result property="read_date" column="READ_DATE"/>
 
-         <result property="send_type" column="SEND_TYPE"/>
 
-         <result property="user" column="USER"/>
 
-         <result property="remark" column="REMARK"/>
 
-         <result property="send_result" column="SEND_RESULT"/>
 
-     </resultMap>
 
-     
 
- 	<sql id="userAttribute">
 
- 		ID,
 
- 		USERNAME,
 
- 		PASSWORD,
 
- 		TOKEN,
 
- 		DISPLAY_NAME,
 
- 		DISPLAY_PICTURE,
 
- 		CREATED_ON,
 
- 		EXT_OPEN_ID,
 
- 		EXT_NAME,
 
- 		EXT_TYPE,
 
- 		LOCATION,
 
- 		BABY_NICKNAME,
 
- 		BABY_DOB,
 
- 		BABY_GENDER,
 
- 		STATUS_ 
 
- 	</sql>
 
- 	
 
- 	<!-- 查询符合条件的用户列表 -->
 
- 	<select id="selectUser" parameterType="PageBean" resultType="User">
 
- 		SELECT 
 
- 			<include refid="userAttribute"></include>
 
- 		FROM USER
 
- 		WHERE 1=1
 
- 	    <if test="params.username!=null and params.username!=''" >
 
- 			AND USERNAME LIKE CONCAT('%',#{params.username},'%')
 
- 	    </if>
 
- 		<if test='recordBegin>0 and pageSize>0'>
 
- 			limit ${recordBegin},${pageSize}
 
- 	    </if>
 
- 	    <if test='recordBegin==0 and pageSize>0 '>
 
- 			limit ${pageSize}
 
- 	    </if> 
 
- 	</select>
 
- 	
 
- 	<!-- 获取用户总条数 -->
 
- 	<select id="selectUserCount" parameterType="SerchParam" resultType="int">
 
- 		SELECT COUNT(ID) FROM USER WHERE 1=1 
 
- 	 	<if test="username!=null and username!=''">
 
-     		AND USERNAME LIKE CONCAT('%',#{username},'%')
 
-     	</if>
 
- 	</select>
 
- 	
 
- 	<!-- 获取符合条件所有消息 -->
 
- 	<select id="selectMessageRecoreds" parameterType="PageBean" resultMap="messageMap">
 
- 		SELECT 
 
- 			<include refid="messageAllField"></include>
 
- 		FROM (
 
- 			SELECT ID,TITLE, CONTENT,URL,FORWORD,IS_NEEDSEND,IS_READ,CREATE_DATE,READ_DATE,SEND_TYPE,
 
- 			(SELECT USERNAME FROM USER WHERE ID = a.user) USER,REMARK,SEND_RESULT  FROM MESSAGE a 
 
- 		) a
 
-     	WHERE 1=1
 
-     	<if test="params.title!=null and params.title!=''" >
 
- 			AND TITLE LIKE CONCAT('%',#{params.title},'%') 
 
-     	</if>
 
- 		<if test="params.username!=null and params.username!=''">
 
- 			AND USER LIKE CONCAT('%',#{params.username},'%') 
 
- 		</if>
 
- 		<if test="params.beginDate!= null and  params.beginDate!= ''" >
 
- 			<![CDATA[AND DATE_FORMAT(create_date, '%Y-%m-%d') >= DATE_FORMAT(#{params.beginDate},'%Y-%m-%d')]]>
 
- 		</if>
 
- 		<if test="params.endDate!= null and params.endDate!= ''">
 
- 			<![CDATA[AND DATE_FORMAT(create_date, '%Y-%m-%d') <= DATE_FORMAT(#{params.endDate},'%Y-%m-%d')]]>
 
-     	</if>
 
- 		ORDER BY CREATE_DATE DESC,USER 
 
- 	    <if test='recordBegin>0 and pageSize>0'>
 
- 			LIMIT ${recordBegin},${pageSize}
 
- 	    </if>
 
- 	    <if test='recordBegin==0 and pageSize>0 '>
 
- 			LIMIT ${pageSize}
 
- 	    </if>
 
- 	</select>
 
- 	
 
- 	<!-- 获取所有消息的总条数 -->
 
- 	<select id="selectMessageCount" parameterType="SerchParam" resultType="int">
 
- 		SELECT COUNT(1) FROM MESSAGE
 
- 		WHERE 1=1
 
- 	    <if test="title!=null and title!=''">
 
- 			AND TITLE LIKE CONCAT('%',#{title},'%') 
 
- 	    </if>
 
- 	    <if test="beginDate!= null and  beginDate!= ''">
 
- 			<![CDATA[AND DATE_FORMAT(create_date, '%Y-%m-%d') >= DATE_FORMAT(#{beginDate},'%Y-%m-%d')]]>
 
- 	    </if>
 
- 	    <if test="endDate!= null and endDate!= ''">
 
- 			<![CDATA[AND DATE_FORMAT(create_date, '%Y-%m-%d') <= DATE_FORMAT(#{endDate},'%Y-%m-%d')]]>
 
- 	    </if>
 
- 	</select>
 
- 	
 
- 	<!-- 根据id 修改一条消息 -->
 
- 	<update id="updateMessage" parameterType="Message">
 
- 		UPDATE MESSAGE 
 
- 		<set>
 
- 			<if test="title != null and title != ''">
 
- 				TITLE=#{title},
 
- 			</if>
 
- 			<if test="content != null and content != ''">
 
- 				CONTENT=#{content},
 
- 			</if>
 
- 			<if test="url != null and url != ''">
 
- 				URL=#{url},
 
- 			</if>
 
- 			<if test="forword != null and forword != ''">
 
- 				FORWORD=#{forword},
 
- 			</if>
 
- 			<if test="is_needsend != null and is_needsend != ''">
 
- 				IS_NEEDSEND=#{is_needsend},
 
- 			</if>
 
- 			<if test="is_read != null and is_read != ''">
 
- 				IS_READ=#{is_read},
 
- 			</if>
 
- 			<if test="create_date != null and create_date != ''">
 
- 				CREATE_DATE=#{create_date},
 
- 			</if>
 
- 			<if test="read_date != null and read_date != ''">
 
- 				READ_DATE=#{read_date},
 
- 			</if>
 
- 			<if test="send_type != null and send_type != ''">
 
- 				SEND_TYPE=#{send_type},
 
- 			</if>
 
- 			<if test="user != null and user != ''">
 
- 				USER=#{user},
 
- 			</if>
 
- 			<if test="remark != null and remark != ''">
 
- 				REMARK=#{remark},
 
- 			</if>
 
- 			<if test="send_result != null and send_result != ''">
 
- 				SEND_RESULT=#{send_result}
 
- 			</if>
 
- 		</set>
 
- 		WHERE ID=#{id}
 
- 	</update>
 
- 	
 
- 	<!-- 添加一条消息 -->
 
- 	<insert id="insertMessage" parameterType="Message"
 
- 		useGeneratedKeys="true" keyProperty="id">
 
- 		INSERT INTO MESSAGE
 
- 			(
 
- 				TITLE, CONTENT,URL, FORWORD,IS_NEEDSEND,IS_READ,
 
- 				CREATE_DATE,READ_DATE,SEND_TYPE, USER,REMARK,SEND_RESULT
 
- 			)
 
- 		VALUES
 
- 			(
 
- 				#{title},#{content},#{url},#{forword},#{is_needsend},#{is_read},
 
- 				#{create_date},#{read_date},#{send_type},#{user},
 
- 				#{remark},#{send_result}
 
- 			)
 
- 	</insert>
 
- 	
 
- 	<!-- 获取系统的所有消息 -->
 
- 	<select id="selectSysMessageRecoreds" resultMap="messageMap">
 
- 		SELECT 
 
- 			<include refid="messageAllField"></include>
 
- 		FROM MESSAGE 
 
- 		WHERE USER IS NULL 
 
- 		ORDER BY CREATE_DATE DESC
 
- 	</select>
 
- 	
 
- 	<!-- 根据id获取一条信息  -->
 
- 	<select id="selectUserMessageByid" parameterType="Long" resultMap="messageMap">
 
- 		SELECT 
 
- 			<include refid="messageAllField"></include>
 
- 		FROM MESSAGE WHERE ID = #{id}
 
- 	</select>
 
- 	
 
- 	<!-- 根据用户id获取该用户的所有消息 -->
 
- 	<select id="selectUserMessageRecoreds" parameterType="Long" resultMap="messageMap">
 
- 		SELECT
 
- 			<include refid="messageAllField"></include>
 
- 		FROM MESSAGE WHERE USER=#{userid}  ORDER BY CREATE_DATE DESC
 
- 	</select>
 
- 	
 
- 	<!--  获取某状态的用户消息 -->
 
- 	<select id="selectUserMessageByisread" resultType="int">
 
- 		SELECT COUNT(1)  FROM message where is_read = #{1} and user=#{0}	
 
- 	</select>
 
- </mapper>
 
 
  |