MessageInfo.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.employment.modules.base.dao.MessageInfoDAO">
  6. <resultMap id="MessageInfoMap" type="com.jpsoft.employment.modules.base.entity.MessageInfo">
  7. <id property="id" column="id_" />
  8. <result property="type" column="type_" />
  9. <result property="sendTime" column="send_time" />
  10. <result property="title" column="title_" />
  11. <result property="content" column="content_" />
  12. <result property="senderId" column="sender_id" />
  13. <result property="recipientId" column="recipient_id" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="createBy" column="create_by" />
  17. <result property="updateBy" column="update_by" />
  18. <result property="delFlag" column="del_flag" />
  19. <result property="isRead" column="is_read" />
  20. </resultMap>
  21. <insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.MessageInfo">
  22. <!--
  23. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  24. select sys_guid() from dual
  25. </selectKey>
  26. -->
  27. <![CDATA[
  28. insert into base_message_info
  29. (id_,type_,send_time,title_,content_,sender_id,recipient_id,create_time,update_time,create_by,update_by,del_flag,is_read)
  30. values
  31. (
  32. #{id,jdbcType=VARCHAR}
  33. ,#{type,jdbcType=VARCHAR}
  34. ,#{sendTime,jdbcType= TIMESTAMP }
  35. ,#{title,jdbcType=VARCHAR}
  36. ,#{content,jdbcType=VARCHAR}
  37. ,#{senderId,jdbcType=VARCHAR}
  38. ,#{recipientId,jdbcType=VARCHAR}
  39. ,#{createTime,jdbcType= TIMESTAMP }
  40. ,#{updateTime,jdbcType= TIMESTAMP }
  41. ,#{createBy,jdbcType=VARCHAR}
  42. ,#{updateBy,jdbcType=VARCHAR}
  43. ,#{delFlag,jdbcType= NUMERIC }
  44. ,#{isRead,jdbcType= NUMERIC }
  45. )
  46. ]]>
  47. </insert>
  48. <delete id="delete" parameterType="string">
  49. delete from base_message_info where id_=#{id,jdbcType=VARCHAR}
  50. </delete>
  51. <update id="update" parameterType="com.jpsoft.employment.modules.base.entity.MessageInfo">
  52. update base_message_info
  53. <set>
  54. <if test="type!=null">
  55. type_=#{type,jdbcType=VARCHAR},
  56. </if>
  57. <if test="sendTime!=null">
  58. send_time=#{sendTime,jdbcType= TIMESTAMP },
  59. </if>
  60. <if test="title!=null">
  61. title_=#{title,jdbcType=VARCHAR},
  62. </if>
  63. <if test="content!=null">
  64. content_=#{content,jdbcType=VARCHAR},
  65. </if>
  66. <if test="senderId!=null">
  67. sender_id=#{senderId,jdbcType=VARCHAR},
  68. </if>
  69. <if test="recipientId!=null">
  70. recipient_id=#{recipientId,jdbcType=VARCHAR},
  71. </if>
  72. <if test="createTime!=null">
  73. create_time=#{createTime,jdbcType= TIMESTAMP },
  74. </if>
  75. <if test="updateTime!=null">
  76. update_time=#{updateTime,jdbcType= TIMESTAMP },
  77. </if>
  78. <if test="createBy!=null">
  79. create_by=#{createBy,jdbcType=VARCHAR},
  80. </if>
  81. <if test="updateBy!=null">
  82. update_by=#{updateBy,jdbcType=VARCHAR},
  83. </if>
  84. <if test="delFlag!=null">
  85. del_flag=#{delFlag,jdbcType= NUMERIC },
  86. </if>
  87. <if test="isRead!=null">
  88. is_read=#{isRead,jdbcType= NUMERIC },
  89. </if>
  90. </set>
  91. where id_=#{id}
  92. </update>
  93. <select id="get" parameterType="string" resultMap="MessageInfoMap">
  94. select * from base_message_info where id_=#{0}
  95. </select>
  96. <select id="exist" parameterType="string" resultType="int">
  97. select count(*) from base_message_info where id_=#{0}
  98. </select>
  99. <select id="list" resultMap="MessageInfoMap">
  100. select * from base_message_info
  101. </select>
  102. <select id="findByRecipientId" resultType="java.util.Map">
  103. select count(*) as 'count',type_ as 'type' from base_message_info
  104. where del_flag=false and is_read=false and recipient_id=#{0}
  105. group by type_
  106. </select>
  107. <select id="findByRecipientIdAndType" resultMap="MessageInfoMap">
  108. select * from base_message_info
  109. where del_flag=false and recipient_id=#{recipientId} and type_=#{type}
  110. </select>
  111. <select id="search" parameterType="hashmap" resultMap="MessageInfoMap">
  112. <![CDATA[
  113. select * from base_message_info
  114. ]]>
  115. <where>
  116. del_flag = false
  117. <if test="searchParams.type != null">
  118. and type_ = #{searchParams.type}
  119. </if>
  120. <if test="searchParams.recipientId != null">
  121. and recipient_id = #{searchParams.recipientId}
  122. </if>
  123. </where>
  124. <foreach item="sort" collection="sortList" open="order by" separator=",">
  125. ${sort.name} ${sort.order}
  126. </foreach>
  127. </select>
  128. <select id="getCount" resultType="int">
  129. SELECT COUNT(*) FROM base_message_info
  130. WHERE del_flag = 0
  131. AND is_read = 0
  132. AND type_ = #{type}
  133. <if test="senderId != null">
  134. AND sender_id = #{senderId}
  135. </if>
  136. <if test="recipientId != null">
  137. AND recipient_id = #{recipientId}
  138. </if>
  139. </select>
  140. </mapper>