lsc 2 months ago
parent
commit
3399f3b29e
1 changed files with 37 additions and 0 deletions
  1. 37 0
      pbl.js

+ 37 - 0
pbl.js

@@ -172,6 +172,43 @@ router.route("/getFile").all(async (req, res, next) => {
     }
     }
 });
 });
 
 
+//获取文档列表
+router.route("/getFileD").all(async (req, res, next) => {
+    //mode的处理
+    if (req.body[0]) {
+        p = Object.values(req.body[0]);
+        p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getFileD");
+        mysql.usselect(p, async function (ret) {
+            let data = ret[0];
+            // const array = data.map(item => item.documentid);
+            const array = data.map(item => item.documentid);
+            try {
+                const response = await client.documents.list({ ids: array });
+                // const response = await client.collections.listDocuments({ id: req.body[0].folderid });
+                // const response = await client.collections.listDocuments({ collection_ids: req.body[0].folderid.split(",") });
+                
+                // console.log(response);
+                let data2 = response.results.map(doc => {
+                    doc.documentid = doc.id;
+                    delete doc.id;
+                    return doc;
+                });
+                // console.log(data2);
+
+                // 合并data和data2,根据documentid
+                const mergedData = data.map(item => {
+                    const correspondingDoc = data2.find(doc => doc.documentid === item.documentid);
+                    return { ...item, ...correspondingDoc };
+                });
+
+                res.status(200).json({ result: mergedData });
+            } catch (error) {
+                res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
+            }
+        });
+    }
+});
+
 //获取文档列表
 //获取文档列表
 router.route("/getFileOpen").all(async (req, res, next) => {
 router.route("/getFileOpen").all(async (req, res, next) => {
     //mode的处理
     //mode的处理