first commit

This commit is contained in:
2025-04-14 01:17:15 +08:00
commit 5de91493af
4 changed files with 131 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
(async function () {
const res = await fetch("http://all.funjia.top/api/dynamic/list/dataDict", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ "page": 1, "pageSize": 100000, "userId": "cl3fqx6zb000034ny90rd333s" })
});
const importData = await res.json();
importData.data.forEach(element => {
console.log(element)
saveData({ unionKey: element.unionKey, value: element.value, desc: element.desc });
});
})()
function saveData(importData) {
fetch("http://127.0.0.1:1337/api/data-dicts", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ data: importData })
}).then((res) => {
console.log(res);
}).catch((err) => {
console.log(err)
})
}
+51
View File
@@ -0,0 +1,51 @@
(async function () {
const res = await fetch("http://all.funjia.top/api/QA/list", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ "page": 1, "pageSize": 100000, "userId": "cl3fqx6zb000034ny90rd333s" })
});
const importDataObj = await res.json(),
tagDataObj = await getTag(),
importData = importDataObj.data,
tagData = tagDataObj.data;
// console.log(tagData);
// return;
for (const item of importData) {
console.log(item.tag);
const tag = tagData.filter(tDItem => (Array.isArray(item.tag) ? item.tag : [item.tag]).some((child) => child == tDItem.name));
console.log(tag);
await saveData({ question: item.question, answer: item.answer, tags: tag.map((child) => child.documentId) });
await sleep(200);
}
})()
async function sleep(timeout) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, timeout);
});
}
async function getTag() {
const res = await fetch("http://127.0.0.1:1337/api/tags", {
method: "get",
headers: {
"Content-Type": "application/json"
}
});
return res.json();
}
function saveData(importData) {
return fetch("http://127.0.0.1:1337/api/question-answers", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ data: importData })
})
}
+29
View File
@@ -0,0 +1,29 @@
(async function () {
const res = await fetch("http://all.funjia.top/api/dynamic/list/tag", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ "page": 1, "pageSize": 100000, "userId": "cl3fqx6zb000034ny90rd333s" })
});
const importData = await res.json();
importData.data.forEach(element => {
// console.log(element)
saveData({name:element.name});
});
})()
function saveData(importData) {
fetch("http://127.0.0.1:1337/api/tags", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ data: importData })
}).then((res) => {
console.log(res);
}).catch((err) => {
console.log(err)
})
}
+22
View File
@@ -0,0 +1,22 @@
fetch("http://localhost:1337/api/data-dicts", {
"headers": {
"accept": "application/json",
// "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
// "authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNzQ0MDMxMzczLCJleHAiOjE3NDY2MjMzNzN9.FWwOQj0R91paBYDIptE1z0o4BZroJbHhgj1IFPTqw_Q",
"content-type": "application/json",
// "sec-ch-ua": "\"Microsoft Edge\";v=\"113\", \"Chromium\";v=\"113\", \"Not-A.Brand\";v=\"24\"",
// "sec-ch-ua-mobile": "?0",
// "sec-ch-ua-platform": "\"Windows\"",
// "sec-fetch-dest": "empty",
// "sec-fetch-mode": "cors",
// "sec-fetch-site": "same-origin"
},
"referrer": "http://localhost:1337/api/data-dicts",
"referrerPolicy": "same-origin",
"body": "{\"unionKey\":\"test\",\"value\":\"test\",\"desc\":\"test2\"}",
"method": "POST",
"mode": "cors",
"credentials": "include"
}).then(async (res)=>{
console.log(await res.text());
});