MessageMapper.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="jnpf.message.mapper.MessageMapper">
  4. <resultMap id="Message" type="jnpf.message.entity.MessageReceiveEntity">
  5. <id column="f_id" property="id"/>
  6. <result column="f_title" property="title"/>
  7. <result column="f_type" property="type"/>
  8. <result column="f_creator_time" property="creatorTime"/>
  9. <result column="f_creator_user_id" property="creatorUserId"/>
  10. <result column="f_last_modify_time" property="lastModifyTime"/>
  11. <result column="f_enabled_mark" property="enabledMark"/>
  12. <result column="f_is_read" property="isRead"/>
  13. <result column="f_last_modify_user_id" property="lastModifyUserId"/>
  14. </resultMap>
  15. <select id="getMessageList" parameterType="map" resultMap="Message">
  16. SELECT r.f_id, r.f_title, r.f_type, r.f_is_read, r.f_creator_time, r.f_creator_user_id, r.f_last_modify_time, r.f_last_modify_user_id,
  17. u.f_real_name,u.f_account FROM base_message r
  18. LEFT JOIN base_user u ON u.f_id = r.f_user_id where 1 = 1
  19. <if test="map.userId != null">
  20. AND r.f_user_id= #{map.userId}
  21. </if>
  22. <if test="map.keyword != null">
  23. AND (r.f_title like #{map.keyword} OR u.f_real_name LIKE #{map.keyword} OR u.f_account LIKE #{map.keyword})
  24. </if>
  25. <if test="map.type != null">
  26. AND r.f_type = #{map.type}
  27. </if>
  28. <if test="map.isRead != null">
  29. AND r.f_is_read = #{map.isRead}
  30. </if>
  31. ORDER BY r.f_last_modify_time desc
  32. </select>
  33. <select id="getUnreadCount" resultType="int">
  34. SELECT COUNT(1) FROM base_message
  35. WHERE f_user_id = #{userId} AND f_is_read = 0 AND f_type = #{type}
  36. </select>
  37. <select id="getInfoDefault" parameterType="int" resultMap="Message">
  38. SELECT * FROM base_message WHERE 1 = 1 AND f_type = #{type} ORDER BY f_creator_time DESC
  39. </select>
  40. </mapper>