KwmMessageMapper.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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="com.sckw.message.dao.KwmMessageMapper">
  4. <select id="findPage" resultType="com.sckw.message.model.dto.MessageListDTO" >
  5. select m.id,
  6. mu.ent_id entId,
  7. mu.user_id userId,
  8. mu.status,
  9. mu.remark,
  10. mu.create_by createBy,
  11. mu.create_time createTime,
  12. mu.update_by updateBy,
  13. mu.update_time updateTime,
  14. mu.msg_id as msgId,
  15. m.category,
  16. m.type,
  17. m.title,
  18. m.content,
  19. m.url,
  20. m.params,
  21. m.client_type clientType,
  22. m.remark as msgRemark
  23. from kwm_message_user mu
  24. left join kwm_message m
  25. on mu.msg_id = m.id
  26. <where>
  27. m.del_flag = 0
  28. and mu.del_flag = 0
  29. <if test="item.entId != null">
  30. and mu.ent_id = #{item.entId}
  31. </if>
  32. <if test="item.query != null and item.query != ''">
  33. and (m.title like concat('%', #{item.query}, '%') or m.content like concat(#{item.query}, '%'))
  34. </if>
  35. <if test="item.userId != null">
  36. and mu.user_id = #{item.userId}
  37. </if>
  38. <if test="item.status != null">
  39. and mu.status = #{item.status}
  40. </if>
  41. <if test="item.category != null and item.category != ''">
  42. and m.category = #{item.category}
  43. </if>
  44. <if test="item.startCreateTime != null">
  45. and mu.create_time &gt;= #{item.startCreateTime,jdbcType=TIMESTAMP}
  46. </if>
  47. <if test="item.endCreateTime != null">
  48. and mu.create_time &lt;= #{item.endCreateTime,jdbcType=TIMESTAMP}
  49. </if>
  50. </where>
  51. ORDER BY mu.status, mu.create_time DESC
  52. </select>
  53. <select id="statistics" resultType="com.sckw.core.model.vo.TableTop">
  54. select
  55. mu.status as value,count(*) as total
  56. from kwm_message_user mu
  57. left join kwm_message m
  58. on mu.msg_id = m.id
  59. <where>
  60. m.del_flag = 0 and mu.del_flag = 0
  61. <if test="item.entId != null">
  62. and mu.ent_id = #{item.entId}
  63. </if>
  64. <if test="item.userId != null">
  65. and mu.user_id = #{item.userId}
  66. </if>
  67. <if test="item.category != null and item.category != ''">
  68. and m.category = #{item.category}
  69. </if>
  70. <if test="item.startCreateTime != null">
  71. and mu.create_time &gt;= #{item.startCreateTime,jdbcType=TIMESTAMP}
  72. </if>
  73. <if test="item.endCreateTime != null">
  74. and mu.create_time &lt;= #{item.endCreateTime,jdbcType=TIMESTAMP}
  75. </if>
  76. </where>
  77. group by mu.status
  78. </select>
  79. <select id="joinCount" resultType="java.lang.Long">
  80. select count(1)
  81. from kwm_message km
  82. inner join kwm_message_user kmu on km.id = kmu.msg_id and kmu.del_flag = 0
  83. <where>
  84. km.del_flag = 0
  85. <if test="para.entId != null">
  86. and kmu.ent_id = #{para.entId}
  87. </if>
  88. <if test="para.query != null and para.query != ''">
  89. and (km.title like concat('%', #{para.query}, '%') or km.content like concat(#{para.query}, '%'))
  90. </if>
  91. <if test="para.userId != null">
  92. and kmu.user_id = #{para.userId}
  93. </if>
  94. <if test="para.category != null and para.category != ''">
  95. and km.category = #{param1.category}
  96. </if>
  97. <if test="para.status != null">
  98. and km.status = #{para.status}
  99. </if>
  100. </where>
  101. </select>
  102. </mapper>