|
@@ -5,6 +5,8 @@ import { BaseService, PageOptions, SearchBase } from 'free-midway-component';
|
|
|
import { Chat } from '../entity/chat.entity';
|
|
|
import { cloneDeep, get, head } from 'lodash';
|
|
|
import { ChatMqService } from './chatMq.service';
|
|
|
+import { Types } from 'mongoose';
|
|
|
+const ObjectId = Types.ObjectId;
|
|
|
type modelType = ReturnModelType<typeof Chat>;
|
|
|
@Provide()
|
|
|
export class ChatService extends BaseService<modelType> {
|
|
@@ -13,6 +15,15 @@ export class ChatService extends BaseService<modelType> {
|
|
|
@Inject()
|
|
|
chatMqService: ChatMqService;
|
|
|
|
|
|
+
|
|
|
+ async allRead(data) {
|
|
|
+
|
|
|
+ const { group, patient, doctor, speaker } = data;
|
|
|
+ const result = await this.model.find({ group, patient, doctor, speaker: { $ne: speaker }, not_read: 1 }).lean();
|
|
|
+ const ids = result.map(i => new ObjectId(i._id).toString());
|
|
|
+ await this.model.updateMany({ _id: ids }, { $set: { not_read: 0 } });
|
|
|
+ }
|
|
|
+
|
|
|
async sendMq(data) {
|
|
|
|
|
|
const { group, patient, _id } = data;
|