Просмотр исходного кода

modify removeAttachment (service)

zamis 5 лет назад
Родитель
Сommit
9ebb2d2309
1 измененных файлов с 18 добавлено и 4 удалено
  1. 18 4
      src/server/service/attachment.js

+ 18 - 4
src/server/service/attachment.js

@@ -43,14 +43,28 @@ class AttachmentService {
     return attachment;
     return attachment;
   }
   }
 
 
-  async removeAttachment(attachmentId) {
+  async removeAttachment(attachments) {
     const Attachment = this.crowi.model('Attachment');
     const Attachment = this.crowi.model('Attachment');
     const { fileUploadService } = this.crowi;
     const { fileUploadService } = this.crowi;
+    // console.log(attachments);
+    console.log('===============');
+    console.log(attachments);
+    console.log('===============');
 
 
-    const attachment = await Attachment.findById(attachmentId);
-    await fileUploadService.deleteFile(attachment);
 
 
-    return attachment.remove();
+    await attachments.forEach(attachment => Attachment.findById(attachment._id));
+    console.log('===============');
+
+    console.log(attachments);
+    console.log('===============');
+
+    await attachments.forEach(attachment => fileUploadService.deleteFile(attachment));
+    console.log('===============');
+    console.log(attachments);
+    console.log('===============');
+
+
+    return attachments.forEach(attachment => attachment.remove());
   }
   }
 
 
 }
 }