|
@@ -6,12 +6,12 @@ const bcrypt = require("bcryptjs");
|
|
|
const router = express.Router(); // get an instance of the express Router
|
|
|
const querystring = require("querystring");
|
|
|
var mysql = require("./mysql");
|
|
|
-// const _mysqlLabor = ["123.58.32.151", "pbl"]; //edu數據庫信息
|
|
|
-// const _mysqluser = ["123.58.32.151", "cocorobouser"]; //用户数据库信息
|
|
|
+const _mysqlLabor = ["123.58.32.151", "pbl"]; //edu數據庫信息
|
|
|
+const _mysqluser = ["123.58.32.151", "cocorobouser"]; //用户数据库信息
|
|
|
// const _getmysqlLabor = ["123.58.32.151", "pbl"]; //edu數據庫信息
|
|
|
// const _getmysqluser = ["123.58.32.151", "cocorobouser"]; //edu數據庫信息
|
|
|
-const _mysqlLabor = ["172.16.12.5", "pbl"]; //edu數據庫信息
|
|
|
-const _mysqluser = ["172.16.12.5", "cocorobouser"]; //edu數據庫信息
|
|
|
+// const _mysqlLabor = ["172.16.12.5", "pbl"]; //edu數據庫信息
|
|
|
+// const _mysqluser = ["172.16.12.5", "cocorobouser"]; //edu數據庫信息
|
|
|
// const _getmysqlLabor = ["172.16.12.5", "pbl"]; //edu數據庫信息
|
|
|
// const _getmysqluser = ["172.16.12.5", "cocorobouser"]; //edu數據庫信息
|
|
|
const _getmysqlLabor2 = ["172.16.12.7", "pbl"]; //edu數據庫信息
|
|
@@ -141,20 +141,54 @@ router.route("/getFile").all(async (req, res, next) => {
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getFile");
|
|
|
mysql.usselect(p, async function(ret) {
|
|
|
console.log(ret);
|
|
|
- // let array = []
|
|
|
- res.end(JSON.stringify(ret));
|
|
|
- // try {
|
|
|
- // const response = await client.documents.list({ ids: [] });
|
|
|
- // console.log(response);
|
|
|
-
|
|
|
- // res.status(200).json({ result: response.results });
|
|
|
- // } catch (error) {
|
|
|
- // res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
- // }
|
|
|
+ let data = ret[0];
|
|
|
+ const array = data.map(item => item.documentid);
|
|
|
+ try {
|
|
|
+ const response = await client.documents.list({ ids: array });
|
|
|
+ console.log(response);
|
|
|
+ let data2 = response.results.map(doc => {
|
|
|
+ doc.documentid = doc.id;
|
|
|
+ delete doc.id;
|
|
|
+ return doc;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 合并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("/addFolder").all(async (req, res, next) => {
|
|
|
+ //mode的处理
|
|
|
+ if (req.body[0]) {
|
|
|
+ try {
|
|
|
+ const response = await client.collections.create({
|
|
|
+ name: req.body[0].n,
|
|
|
+ description: req.body[0].fd
|
|
|
+ });
|
|
|
+ p = [...Object.values(req.body[0]), response.results.id];
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addFolder");
|
|
|
+ mysql.usselect(p, async function(ret) {
|
|
|
+ res.end(JSON.stringify(ret));
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
|
|
|
function generateAPIKey(username) {
|
|
|
let timeStamp = new Date().getTime();
|