|
@@ -30,22 +30,24 @@ const client = new r2rClient("https://r2rserver.cocorobo.cn/");
|
|
|
|
|
|
// 配置 multer 存储选项
|
|
|
const storage = multer.diskStorage({
|
|
|
- destination: function (req, file, cb) {
|
|
|
- req.setEncoding('utf-8');
|
|
|
- cb(null, 'uploads/'); // 文件上传目录
|
|
|
- },
|
|
|
- filename: function (req, file, cb) {
|
|
|
- req.setEncoding('utf-8');
|
|
|
- // 使用 Buffer 处理文件名,确保编码正确
|
|
|
- const fileExtension = file.originalname.split('.').pop(); // 获取文件后缀
|
|
|
- const fileNameWithoutExt = Buffer.from(file.originalname.slice(0, -(fileExtension.length + 1)), 'latin1').toString('utf8'); // 转换编码
|
|
|
- cb(null, fileNameWithoutExt + '-' + Date.now() + '.' + fileExtension); // 使用时间戳和原始文件名
|
|
|
- }
|
|
|
+ destination: function (req, file, cb) {
|
|
|
+ req.setEncoding('utf-8');
|
|
|
+ cb(null, 'uploads/'); // 文件上传目录
|
|
|
+ },
|
|
|
+ filename: function (req, file, cb) {
|
|
|
+ req.setEncoding('utf-8');
|
|
|
+ // 使用 Buffer 处理文件名,确保编码正确
|
|
|
+ const fileExtension = file.originalname.split('.').pop(); // 获取文件后缀
|
|
|
+ const fileNameWithoutExt = Buffer.from(file.originalname.slice(0, -(fileExtension.length + 1)), 'latin1').toString('utf8'); // 转换编码
|
|
|
+ cb(null, fileNameWithoutExt + '-' + Date.now() + '.' + fileExtension); // 使用时间戳和原始文件名
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
-const upload = multer({ storage: storage, limits: {
|
|
|
- fileSize: 100 * 1024 * 1024 // 100MB
|
|
|
-} });
|
|
|
+const upload = multer({
|
|
|
+ storage: storage, limits: {
|
|
|
+ fileSize: 100 * 1024 * 1024 // 100MB
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
router.route("/login").all(async (req, res, next) => {
|
|
|
loginHandler(req, res)
|
|
@@ -54,9 +56,9 @@ router.route("/login").all(async (req, res, next) => {
|
|
|
router.route("/logout").all(async (req, res, next) => {
|
|
|
try {
|
|
|
const response = await client.users.logout();
|
|
|
- res.status(200).json({result: response.results});
|
|
|
+ res.status(200).json({ result: response.results });
|
|
|
} catch (error) {
|
|
|
- res.status(500).json({error: error instanceof Error ? error.message : "An error occurred"});
|
|
|
+ res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -68,7 +70,7 @@ router.route("/getDocument").all(async (req, res, next) => {
|
|
|
offset: 0,
|
|
|
});
|
|
|
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" });
|
|
@@ -82,7 +84,7 @@ router.route("/listChunks").all(async (req, res, next) => {
|
|
|
id: "5111165f-965c-5d61-89e3-1f74b0178032",
|
|
|
});
|
|
|
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" });
|
|
@@ -94,7 +96,7 @@ router.route("/extract").all(async (req, res, next) => {
|
|
|
try {
|
|
|
const response = await client.documents.extract({ id: "5111165f-965c-5d61-89e3-1f74b0178032" })
|
|
|
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" });
|
|
@@ -117,7 +119,7 @@ router.post('/upload', upload.single('file'), async (req, res) => {
|
|
|
const path = require('path');
|
|
|
const filePath = path.resolve(__dirname, 'uploads', req.file.filename);
|
|
|
console.log(filePath);
|
|
|
-
|
|
|
+
|
|
|
let filename = Buffer.from(req.file.originalname, 'latin1').toString('utf8');
|
|
|
const fs = require('fs');
|
|
|
const file = new File([fs.readFileSync('./uploads/q-1739170522767.doc')], filename, { type: req.file.mimetype });
|
|
@@ -126,7 +128,7 @@ router.post('/upload', upload.single('file'), async (req, res) => {
|
|
|
metadata: { title: filename }
|
|
|
});
|
|
|
console.log(response);
|
|
|
-
|
|
|
+
|
|
|
res.status(200).json({ message: 'File uploaded successfully', file: req.file });
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
@@ -137,14 +139,14 @@ router.post('/upload', upload.single('file'), async (req, res) => {
|
|
|
router.route("/getFile").all(async (req, res, next) => {
|
|
|
//mode的处理
|
|
|
if (req.body[0]) {
|
|
|
- p = Object.values(req.body[0]);
|
|
|
+ p = Object.values(req.body[0]);
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getFile");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
let data = ret[0];
|
|
|
// const array = data.map(item => item.documentid);
|
|
|
try {
|
|
|
// const response = await client.documents.list({ collection_ids: [req.body[0].folderid] });
|
|
|
- const response = await client.collections.listDocuments({id: req.body[0].folderid});
|
|
|
+ const response = await client.collections.listDocuments({ id: req.body[0].folderid });
|
|
|
// console.log(response);
|
|
|
let data2 = response.results.map(doc => {
|
|
|
doc.documentid = doc.id;
|
|
@@ -173,12 +175,12 @@ router.route("/getFileP").all(async (req, res, next) => {
|
|
|
if (req.body) {
|
|
|
p = [req.body.uid, req.body.folderid, req.body.n, req.body.page, req.body.num];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getFile");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
let data = ret[0];
|
|
|
// const array = data.map(item => item.documentid);
|
|
|
try {
|
|
|
// const response = await client.documents.list({ collection_ids: [req.body.folderid] });
|
|
|
- const response = await client.collections.listDocuments({id: req.body[0].folderid});
|
|
|
+ const response = await client.collections.listDocuments({ id: req.body[0].folderid });
|
|
|
// console.log(response);
|
|
|
let data2 = response.results.map(doc => {
|
|
|
doc.documentid = doc.id;
|
|
@@ -204,9 +206,9 @@ router.route("/getFileP").all(async (req, res, next) => {
|
|
|
router.route("/getFile2").all(async (req, res, next) => {
|
|
|
//mode的处理
|
|
|
if (req.body[0]) {
|
|
|
- p = Object.values(req.body[0]);
|
|
|
+ p = Object.values(req.body[0]);
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getFile2");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
let data = ret[0];
|
|
|
// const array = data.map(item => item.documentid);
|
|
|
try {
|
|
@@ -241,12 +243,12 @@ router.route("/addFolder").all(async (req, res, next) => {
|
|
|
name: decodeURIComponent(req.body[0].n),
|
|
|
description: decodeURIComponent(req.body[0].fd)
|
|
|
});
|
|
|
- p = [...Object.values(req.body[0]), response.results.id];
|
|
|
+ p = [...Object.values(req.body[0]), response.results.id];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addFolder");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ 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" });
|
|
|
}
|
|
@@ -262,12 +264,12 @@ router.route("/deleteFolder").all(async (req, res, next) => {
|
|
|
let folderids = decodeURIComponent(req.body[0].folderids).split(",")
|
|
|
let ids = req.body[0].ids
|
|
|
await Promise.all(folderids.map(folderid => client.collections.delete({ id: folderid })));
|
|
|
- p = [ids];
|
|
|
+ p = [ids];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "deleteFolder");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ 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" });
|
|
|
}
|
|
@@ -283,17 +285,17 @@ router.route("/updateFolder").all(async (req, res, next) => {
|
|
|
const { folderid, ...folderData } = req.body[0]; // 解构赋值,排除folderid
|
|
|
const response = await client.collections.update({
|
|
|
id: folderid,
|
|
|
- name: decodeURIComponent(req.body[0].n),
|
|
|
- description: decodeURIComponent(req.body[0].d)
|
|
|
+ name: decodeURIComponent(req.body[0].n),
|
|
|
+ description: decodeURIComponent(req.body[0].d)
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
p = Object.values(folderData); // 获取剩余属性的键
|
|
|
-
|
|
|
+
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "updateFolder2");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ 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" });
|
|
|
}
|
|
@@ -309,7 +311,7 @@ router.route("/removeFile").all(async (req, res, next) => {
|
|
|
let ids = req.body[0].ids;
|
|
|
|
|
|
// 使用 Promise.all 确保所有删除操作都被执行
|
|
|
- const removePromises = documentids.map(documentid =>
|
|
|
+ const removePromises = documentids.map(documentid =>
|
|
|
client.collections.removeDocument({ id: folderid, documentId: documentid })
|
|
|
);
|
|
|
|
|
@@ -320,7 +322,7 @@ router.route("/removeFile").all(async (req, res, next) => {
|
|
|
|
|
|
p = [ids, folderid];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "removeFile");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|
|
@@ -335,22 +337,22 @@ router.route("/moveFile").all(async (req, res, next) => {
|
|
|
let ids = decodeURIComponent(req.body[0].ids).split(",")
|
|
|
|
|
|
// 使用 Promise.all 确保所有添加操作都被执行
|
|
|
- await Promise.all(documentids.map(documentid =>
|
|
|
- client.collections.addDocument({
|
|
|
+ await Promise.all(documentids.map(documentid =>
|
|
|
+ client.collections.addDocument({
|
|
|
id: folderid,
|
|
|
- documentId: documentid
|
|
|
+ documentId: documentid
|
|
|
}).catch(error => {
|
|
|
console.error("移动文件时发生错误:", error);
|
|
|
})
|
|
|
));
|
|
|
-
|
|
|
+
|
|
|
for (const id of ids) {
|
|
|
p = [id, folderid];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "moveFile");
|
|
|
- await mysql.usselect(p, async function(ret) {});
|
|
|
+ await mysql.usselect(p, async function (ret) { });
|
|
|
}
|
|
|
res.status(200).json({ messages: "移动成功" });
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
// 这里不返回错误,确保deleteFile执行完
|
|
|
console.error("处理过程中发生错误:", error);
|
|
@@ -358,14 +360,14 @@ router.route("/moveFile").all(async (req, res, next) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
-//移入文件
|
|
|
+//删除文件
|
|
|
router.route("/deleteFile").all(async (req, res, next) => {
|
|
|
if (req.body[0]) {
|
|
|
let documentids = decodeURIComponent(req.body[0].documentids).split(",");
|
|
|
let ids = req.body[0].ids;
|
|
|
|
|
|
// 使用 Promise.all 确保所有删除操作都被执行
|
|
|
- Promise.all(documentids.map(documentid =>
|
|
|
+ Promise.all(documentids.map(documentid =>
|
|
|
client.documents.delete({ id: documentid }).catch(error => {
|
|
|
console.error("删除文件时发生错误:", error);
|
|
|
})
|
|
@@ -373,7 +375,7 @@ router.route("/deleteFile").all(async (req, res, next) => {
|
|
|
|
|
|
p = [ids];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "deleteFile");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
|
|
@@ -394,10 +396,10 @@ router.route("/searchFile").all(async (req, res, next) => {
|
|
|
if (req.body) {
|
|
|
try {
|
|
|
let filters = {}
|
|
|
- if(req.body.type == 1){
|
|
|
- filters = {"document_id": {"$in": req.body.ids}}
|
|
|
- }else if(req.body.type == 2){
|
|
|
- filters = {"collection_ids": {"$in": req.body.ids}}
|
|
|
+ if (req.body.type == 1) {
|
|
|
+ filters = { "document_id": { "$in": req.body.ids } }
|
|
|
+ } else if (req.body.type == 2) {
|
|
|
+ filters = { "collection_ids": { "$in": req.body.ids } }
|
|
|
}
|
|
|
const response = await client.retrieval.search({
|
|
|
query: req.body.query,
|
|
@@ -405,13 +407,13 @@ router.route("/searchFile").all(async (req, res, next) => {
|
|
|
filters: filters,
|
|
|
useSemanticSearch: true,
|
|
|
chunkSettings: {
|
|
|
- limit: req.body.limit ? req.body.limit : 10,
|
|
|
+ limit: req.body.limit ? req.body.limit : 10,
|
|
|
enabled: true
|
|
|
},
|
|
|
}
|
|
|
});
|
|
|
res.status(200).json({ result: response.results });
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
@@ -424,10 +426,10 @@ router.route("/extractFile").all(async (req, res, next) => {
|
|
|
if (req.body) {
|
|
|
try {
|
|
|
const response = client.documents.extract({
|
|
|
- id:req.body.id
|
|
|
+ id: req.body.id
|
|
|
})
|
|
|
res.status(200).json({ result: response.results });
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
@@ -436,16 +438,16 @@ router.route("/extractFile").all(async (req, res, next) => {
|
|
|
});
|
|
|
|
|
|
//添加上传好的知识库文件
|
|
|
-router.route("/addFile").all((req,res,next)=>{
|
|
|
- getmysql2(req, res, "add_file", req.body.n, req.body.did, req.body.uid, req.body.fid, req.body.mofid);
|
|
|
+router.route("/addFile").all((req, res, next) => {
|
|
|
+ getmysql2(req, res, "add_file", req.body.n, req.body.did, req.body.uid, req.body.fid, req.body.mofid);
|
|
|
})
|
|
|
|
|
|
//获取文件详情
|
|
|
router.route("/getFileDetail").all(async (req, res, next) => {
|
|
|
if (req.body[0]) {
|
|
|
- p = Object.values(req.body[0]);
|
|
|
+ p = Object.values(req.body[0]);
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], "getFileDetail");
|
|
|
- mysql.usselect(p, async function(ret) {
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
let data = ret[0][0];
|
|
|
// const array = data.map(item => item.documentid);
|
|
|
try {
|
|
@@ -477,7 +479,7 @@ router.route("/getChunks").all(async (req, res, next) => {
|
|
|
limit,
|
|
|
});
|
|
|
res.status(200).json({ result: response });
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
@@ -498,7 +500,7 @@ router.route("/getEntities").all(async (req, res, next) => {
|
|
|
limit,
|
|
|
});
|
|
|
res.status(200).json({ result: response });
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
@@ -520,7 +522,7 @@ router.route("/getRelationships").all(async (req, res, next) => {
|
|
|
limit,
|
|
|
});
|
|
|
res.status(200).json({ result: response });
|
|
|
-
|
|
|
+
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
@@ -542,8 +544,8 @@ router.route("/getEntitiesAndRelationships").all(async (req, res, next) => {
|
|
|
id: documentId,
|
|
|
includeVectors: false,
|
|
|
});
|
|
|
- res.status(200).json({ Entities: response,Relationships: response2 });
|
|
|
-
|
|
|
+ res.status(200).json({ Entities: response, Relationships: response2 });
|
|
|
+
|
|
|
} catch (error) {
|
|
|
res.status(500).json({ error: error instanceof Error ? error.message : "An error occurred" });
|
|
|
}
|
|
@@ -557,13 +559,51 @@ router.route("/extractFile2").all(async (req, res, next) => {
|
|
|
try {
|
|
|
const response = await client.documents.extract({ id: req.body[0].documentid });
|
|
|
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" });
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+//复制文件夹
|
|
|
+router.route("/copyFolder").all(async (req, res, next) => {
|
|
|
+ if (req.body[0]) {
|
|
|
+
|
|
|
+ const response = await client.collections.create({
|
|
|
+ name: decodeURIComponent(req.body[0].n),
|
|
|
+ description: decodeURIComponent(req.body[0].fd)
|
|
|
+ });
|
|
|
+ let folderid = response.results.id;
|
|
|
+ p2 = [req.body[0].folderid]
|
|
|
+ p2.unshift(_mysqlLabor[0], _mysqlLabor[1], "selectFolderFile");
|
|
|
+ mysql.usselect(p2, async function (ret2) {
|
|
|
+ let file = ret2[0]
|
|
|
+ if (file.length) {
|
|
|
+ let documentids = file.map(item => item.documentid);
|
|
|
+ // 使用 Promise.all 确保所有添加操作都被执行
|
|
|
+ await Promise.all(documentids.map(documentid =>
|
|
|
+ client.collections.addDocument({
|
|
|
+ id: folderid,
|
|
|
+ documentId: documentid
|
|
|
+ }).catch(error => {
|
|
|
+ console.error("移动文件时发生错误:", error);
|
|
|
+ })
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ let ids = file.map(item => item.fileid);
|
|
|
+ console.log(ids);
|
|
|
+
|
|
|
+ p = [req.body[0].n, req.body[0].fd, req.body[0].uid, 2, folderid, req.body[0].folderid, ids.join(",")];
|
|
|
+ p.unshift(_mysqlLabor[0], _mysqlLabor[1], "addFolder2");
|
|
|
+ mysql.usselect(p, async function (ret) {
|
|
|
+ res.end(JSON.stringify(ret));
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
function generateAPIKey(username) {
|
|
|
let timeStamp = new Date().getTime();
|
|
@@ -578,78 +618,78 @@ function generateAPIKey(username) {
|
|
|
return digest;
|
|
|
}
|
|
|
|
|
|
-queryString = function(url) {
|
|
|
+queryString = function (url) {
|
|
|
var a = url.split("?");
|
|
|
var json = querystring.parse(a[1]);
|
|
|
return json;
|
|
|
};
|
|
|
|
|
|
//post存儲過程處理
|
|
|
-postmysql = function(req, res, functionname) {
|
|
|
+postmysql = function (req, res, functionname) {
|
|
|
//mode的處理
|
|
|
if (req.body[0]) {
|
|
|
p = Object.values(req.body[0]);
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
//post存儲過程處理
|
|
|
-postmysql2 = function(req, res, functionname) {
|
|
|
+postmysql2 = function (req, res, functionname) {
|
|
|
//mode的處理
|
|
|
if (req.body) {
|
|
|
p = Object.values(req.body)[0].split(",");
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
//post存儲過程處理
|
|
|
-postmysql3 = function(req, res, functionname) {
|
|
|
+postmysql3 = function (req, res, functionname) {
|
|
|
//mode的處理
|
|
|
if (req.body) {
|
|
|
console.log(req);
|
|
|
p = Object.values(req.body);
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
//get獲取數據庫信息
|
|
|
-getmysql = function(req, res, functionname, ...p) {
|
|
|
+getmysql = function (req, res, functionname, ...p) {
|
|
|
p = p || [];
|
|
|
p.unshift(_getmysqlLabor[0], _getmysqlLabor[1], functionname);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
}); //
|
|
|
};
|
|
|
|
|
|
//get獲取數據庫信息
|
|
|
-getmysql2 = function(req, res, functionname, ...p) {
|
|
|
+getmysql2 = function (req, res, functionname, ...p) {
|
|
|
p = p || [];
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1], functionname);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
}); //
|
|
|
};
|
|
|
|
|
|
//get獲取數據庫信息
|
|
|
-getmysql3 = function(req, res, functionname, ...p) {
|
|
|
+getmysql3 = function (req, res, functionname, ...p) {
|
|
|
p = p || [];
|
|
|
p.unshift(_getmysqlLabor2[0], _getmysqlLabor2[1], functionname);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
}); //
|
|
|
};
|
|
@@ -657,7 +697,7 @@ getmysql3 = function(req, res, functionname, ...p) {
|
|
|
|
|
|
//post存储过程处理
|
|
|
|
|
|
-userpostmysql = function(req, res, functionname) {
|
|
|
+userpostmysql = function (req, res, functionname) {
|
|
|
//mode的处理
|
|
|
|
|
|
if (req.body.mode) {
|
|
@@ -667,7 +707,7 @@ userpostmysql = function(req, res, functionname) {
|
|
|
|
|
|
//执行存储过程
|
|
|
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|
|
@@ -675,38 +715,38 @@ userpostmysql = function(req, res, functionname) {
|
|
|
|
|
|
//get获取数据库信息
|
|
|
|
|
|
-usergetmysql = function(req, res, functionname, ...p) {
|
|
|
+usergetmysql = function (req, res, functionname, ...p) {
|
|
|
p = p || [];
|
|
|
|
|
|
p.unshift(_mysqluser[0], _mysqluser[1], functionname);
|
|
|
-
|
|
|
+
|
|
|
//执行存储过程
|
|
|
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
}); //
|
|
|
};
|
|
|
|
|
|
//post存儲過程處理
|
|
|
-postmysqlLocal = function(req, res) {
|
|
|
+postmysqlLocal = function (req, res) {
|
|
|
//mode的處理
|
|
|
if (req.body[0]) {
|
|
|
p = Object.values(req.body[0]);
|
|
|
p.unshift(_localhost[0], _localhost[1]);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-postmysqlOnline = function(req, res) {
|
|
|
+postmysqlOnline = function (req, res) {
|
|
|
//mode的處理
|
|
|
if (req.body[0]) {
|
|
|
p = Object.values(req.body[0]);
|
|
|
p.unshift(_mysqlLabor[0], _mysqlLabor[1]);
|
|
|
//執行存儲過程
|
|
|
- mysql.usselect(p, function(ret) {
|
|
|
+ mysql.usselect(p, function (ret) {
|
|
|
res.end(JSON.stringify(ret));
|
|
|
});
|
|
|
}
|