| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?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">
- <mapper namespace="com.nb.im.mapper.ImRoomMapper">
- <resultMap id="imRoomResult" type="com.nb.im.service.dto.ImRoomResult">
- <result column="id" property="id"/>
- <result column="assist_id" property="assistId"/>
- <result column="patient_id" property="patientId"/>
- <result column="patient_code" property="patientCode"/>
- <result column="patient_name" property="patientName"/>
- <result column="patient_age" property="patientAge"/>
- <result column="patient_sex" property="patientSex"/>
- <result column="manage_type" property="manageType"/>
- <result column="status" property="status"/>
- <result column="sponsor_type" property="sponsorType"/>
- <result column="total_count" property="totalCount"/>
- <result column="last_msg_time" property="lastMsgTime"/>
- <result column="payload" property="payload"/>
- <result column="operation_type" property="operationType"/>
- <result column="msg_type" property="msgType"/>
- <result column="patient_name_ps" property="patientNamePs"/>
- <result column="doctorNickname" property="doctorNickname"/>
- <result column="doctorId" property="doctorId"/>
- <result column="assist_avatar" property="assistAvatar"/>
- <result column="doctor_avatar" property="doctorAvatar"/>
- <result column="create_time" property="createTime"/>
- <result column="update_time" property="updateTime"/>
- </resultMap>
- <select id="queryPageNoneMsgBlurry" resultMap="imRoomResult">
- select
- r.id as id,
- r.patient_code as patient_code,
- r.patient_age as patient_age,
- r.patient_name_ps as patient_name_ps,
- r.patient_name as patient_name,
- r.patient_sex as patient_sex,
- r.manage_type as manage_type,
- r.`status` as status,
- r.last_msg_time as last_msg_time,
- r.sponsor_type as sponsor_type,
- r.total_count as total_count,
- r.create_time as create_time,
- r.update_time as update_time,
- r.doctor_avatar as doctor_avatar,
- r.assist_avatar as assist_avatar,
- r.assist_id as assist_id,
- r.patient_id as patient_id,
- <if test="query.assistId != null">
- ru.nickname as doctorNickname,
- ru.user_id as doctorId,
- </if>
- rm.payload as payload,
- rm.msg_type as msg_type,
- rm.operation_type as operation_type
- from
- (select * from im_room
- <where>
- <if test="query.doctorId != null">
- and doctor_id=#{query.doctorId}
- </if>
- <if test="query.patientInfo != null">
- and (patient_code like concat('%',#{query.patientInfo},'%') or patient_name like concat('%',#{query.patientInfo},'%') )
- </if>
- <if test="query.manageType != null">
- and manage_type=#{query.manageType}
- </if>
- <if test="query.patientId != null">
- and patient_id=#{query.patientId}
- </if>
- <if test="query.assistId != null">
- and assist_id=#{query.assistId}
- </if>
- <if test="query.status != null and query.status.size > 0">
- and status in
- <foreach item="st" index="index" collection="query.status" open="(" separator="," close=")">
- #{st, jdbcType=VARCHAR}
- </foreach>
- </if>
- </where>
- ) as r
- left join (select * from im_msg) as rm
- on rm.id=r.last_msg_id
- <if test="query.assistId != null">
- left join (select * from im_room_user where
- user_id != #{query.assistId}
- ) as ru
- on ru.im_room_id=r.id
- </if>
- <where>
- <if test="query.successTime != null">
- and (r.success_time > #{query.successTime}
- or r.create_time > #{query.successTime})
- </if>
- </where>
- order by last_msg_time desc
- </select>
- <select id="queryPageMsgBlurry" resultMap="imRoomResult">
- -- todo
- </select>
- <select id="maxSort" resultType="java.lang.Long">
- SELECT
- MAX( sort )
- FROM
- im_msg
- GROUP BY
- room_id
- HAVING
- room_id = #{roomId};
- </select>
- <select id="queryDoctorRecentList" resultMap="imRoomResult">
- select
- r.id as id,
- r.patient_code as patient_code,
- r.patient_age as patient_age,
- r.patient_name_ps as patient_name_ps,
- r.patient_name as patient_name,
- r.patient_sex as patient_sex,
- r.manage_type as manage_type,
- r.`status` as status,
- r.last_msg_time as last_msg_time,
- r.sponsor_type as sponsor_type,
- r.total_count as total_count,
- r.create_time as create_time,
- r.update_time as update_time,
- r.doctor_avatar as doctor_avatar,
- r.assist_avatar as assist_avatar,
- r.assist_id as assist_id,
- r.patient_id as patient_id,
- rm.payload as payload,
- rm.msg_type as msg_type,
- rm.operation_type as operation_type
- from
- (select * from im_room
- <where>
- <if test="query.doctorId != null">
- and doctor_id=#{query.doctorId}
- </if>
- <if test="query.patientInfo != null">
- and (patient_code like concat('%',#{query.patientInfo},'%') or patient_name like concat('%',#{query.patientInfo},'%') )
- </if>
- <if test="query.manageType != null">
- and manage_type=#{query.manageType}
- </if>
- <if test="query.patientId != null">
- and patient_id=#{query.patientId}
- </if>
- </where>
- ) as r
- join (select MAX(id) as id,doctor_id,patient_id,assist_id from im_room group by doctor_id,patient_id,assist_id) as ir2 on r.id=ir2.id
- left join (select * from im_msg) as rm
- on rm.id=r.last_msg_id
- <where>
- <if test="query.successTime != null">
- and (r.success_time > #{query.successTime}
- or r.create_time > #{query.successTime})
- </if>
- </where>
- order by doctor_top desc , case when (status =1) then 0 else 1 end desc ,create_time desc
- </select>
- </mapper>
|