|
@@ -29,8 +29,13 @@ export class ChatService extends BaseService<modelType> {
|
|
|
|
|
|
/**
|
|
|
* 根据医护.查找最后发送消息记录
|
|
|
+ * @param doctor 医生id
|
|
|
+ * @param skip 分页
|
|
|
+ * @param limit 分页
|
|
|
+ * @param name 患者姓名,查询用
|
|
|
+ * @returns
|
|
|
*/
|
|
|
- async getLastChatRecordList(doctor: string, skip: number, limit: number) {
|
|
|
+ async getLastChatRecordList(doctor: string, skip?: number, limit?: number, name?: string) {
|
|
|
const pipes = [];
|
|
|
const query = { doctor };
|
|
|
pipes.push({ $match: query });
|
|
@@ -72,8 +77,11 @@ export class ChatService extends BaseService<modelType> {
|
|
|
},
|
|
|
});
|
|
|
pipes.push({ $unwind: '$dInfo' });
|
|
|
- if (skip && skip >= 0) pipes.push({ $skip: skip });
|
|
|
+ if (name) {
|
|
|
+ pipes.push({ $match: { 'pInfo.name': name } });
|
|
|
+ }
|
|
|
pipes.push({ $project: this.lastChatRecordListItem });
|
|
|
+ if (skip && skip >= 0) pipes.push({ $skip: skip });
|
|
|
if (limit && limit > 0) pipes.push({ $limit: limit });
|
|
|
const result = await this.model.aggregate(pipes);
|
|
|
return result;
|