lrf402788946 5 سال پیش
والد
کامیت
a77b778305
2فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 1 0
      app/model/personchat.js
  2. 5 1
      app/service/personchat.js

+ 1 - 0
app/model/personchat.js

@@ -9,6 +9,7 @@ const Personchat = {
   receiver_name: { type: String, required: false, maxLength: 200 }, // 接收人名字
   personroom_id: { type: String, required: true, maxLength: 200 }, // 聊天房间id
   content: { type: String, required: true, maxLength: 1000 }, // 发言内容
+  send_time: { type: String, required: true, maxLength: 100 }, // 发言时间:年月日时分秒
   status: { type: String, required: false, maxLength: 100, default: "0" }, // 状态,0-未读,1-已读
 };
 const schema = new Schema(Personchat, { toJSON: { virtuals: true } });

+ 5 - 1
app/service/personchat.js

@@ -11,16 +11,20 @@ class PersonchatService extends CrudService {
     super(ctx, 'chat');
     this.model = this.ctx.model.Personchat;
   }
-  async create(query, { sender_id, receiver_id, content, personroom_id }) {
+  async create(query, { sender_id, sender_name, receiver_id, receiver_name, content, personroom_id }) {
     assert(sender_id, '缺少发送人信息');
     assert(content, '缺少发言内容');
     assert(receiver_id, '缺少接收人信息');
     assert(personroom_id, '缺少聊天房间信息');
+    const send_time = moment().format("YYYY-MM-DD HH:mm:ss");
     const res = await this.model.create({
       sender_id,
+      sender_name,
       receiver_id,
+      receiver_name,
       content,
       personroom_id,
+      send_time,
     });
     // TODO MQ
     const { mq } = this.ctx;