ImRoomMapper.xml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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.nb.im.mapper.ImRoomMapper">
  4. <resultMap id="imRoomResult" type="com.nb.im.service.dto.ImRoomResult">
  5. <result column="id" property="id"/>
  6. <result column="patient_code" property="patientCode"/>
  7. <result column="patient_name" property="patientName"/>
  8. <result column="patient_age" property="patientAge"/>
  9. <result column="patient_sex" property="patientSex"/>
  10. <result column="manage_type" property="manageType"/>
  11. <result column="status" property="status"/>
  12. <result column="sponsor_type" property="sponsorType"/>
  13. <result column="total_count" property="totalCount"/>
  14. <result column="last_msg_time" property="lastMsgTime"/>
  15. <result column="payload" property="payload"/>
  16. <result column="operation_type" property="operationType"/>
  17. <result column="msg_type" property="msgType"/>
  18. <result column="doctorNickname" property="doctorNickname"/>
  19. <result column="doctorId" property="doctorId"/>
  20. <result column="create_time" property="createTime"/>
  21. </resultMap>
  22. <select id="queryPageNoneMsgBlurry" resultMap="imRoomResult">
  23. select
  24. r.id as id,
  25. r.patient_code as patient_code,
  26. r.patient_age as patient_age,
  27. r.patient_name as patient_name,
  28. r.patient_sex as patient_sex,
  29. r.manage_type as manage_type,
  30. r.`status` as status,
  31. r.last_msg_time as last_msg_time,
  32. r.sponsor_type as sponsor_type,
  33. r.total_count as total_count,
  34. r.create_time as create_time,
  35. <if test="query.assistId != null">
  36. ru.nickname as doctorNickname,
  37. ru.user_id as doctorId,
  38. </if>
  39. rm.payload as payload,
  40. rm.msg_type as msg_type,
  41. rm.operation_type as operation_type
  42. from
  43. (select * from im_room
  44. <where>
  45. <if test="query.doctorId != null">
  46. and doctor_id=#{query.doctorId}
  47. </if>
  48. <if test="query.patientInfo != null">
  49. and (patient_code like concat('%',#{query.patientInfo},'%') or patient_name like concat('%',#{query.patientInfo},'%') )
  50. </if>
  51. <if test="query.manageType != null">
  52. and manage_type=#{query.manageType}
  53. </if>
  54. <if test="query.patientId != null">
  55. and patient_id=#{query.patientId}
  56. </if>
  57. <if test="query.assistId != null">
  58. and assist_id=#{query.assistId}
  59. </if>
  60. </where>
  61. ) as r
  62. left join (select * from im_msg) as rm
  63. on rm.id=r.last_msg_id
  64. <if test="query.assistId != null">
  65. left join (select * from im_room_user where
  66. user_id != #{query.assistId}
  67. ) as ru
  68. on ru.im_room_id=r.id
  69. </if>
  70. order by last_msg_time desc
  71. </select>
  72. <select id="queryPageMsgBlurry" resultMap="imRoomResult">
  73. -- todo
  74. </select>
  75. <select id="maxSort" resultType="Long">
  76. SELECT
  77. MAX( sort )
  78. FROM
  79. im_msg
  80. GROUP BY
  81. room_id
  82. HAVING
  83. room_id = #{roomId};
  84. </select>
  85. </mapper>