feat: first commit

This commit is contained in:
2025-03-27 19:37:24 +08:00
commit 3e2aa46ea1
81 changed files with 106573 additions and 0 deletions
+108
View File
@@ -0,0 +1,108 @@
import _ from "lodash";
// import RouterFactor from "../RouterFactory.mjs";
// import DBHelper from "../DBHelper.mjs";
import {RouterFactor,DBHelper} from "funjia-server/lib/funjia-server.mjs";
const getBackupHistory = (router) => {
const rF = new RouterFactor({
router,
db: DBHelper.backupDB,
name: "backupHistory"
});
rF.createGetList();
rF.createGetDetail();
rF.createAdd();
rF.createUpdate();
rF.createDelete();
// router.post('/api/backupHistory/add', async (ctx) => {
// ctx.type = 'application/json';
// const db = await getBackupDb();
// // You can also use this syntax if you prefer
// if (!db.data.backupHistory)
// db.data.backupHistory = [];
// const {
// backupHistory
// } = db.data;
// const data = ctx.request.body;
// console.log("add:", data);
// data.id = cuid();
// data.createTime = new Date();
// backupHistory.push(data)
// // Write db.data content to db.json
// await db.write()
// ctx.body = {
// code: 0,
// };
// });
// router.post('/api/backupHistory/upd', async (ctx) => {
// ctx.type = 'application/json';
// const db = await getBackupDb();
// // You can also use this syntax if you prefer
// if (!db.data.backupHistory)
// db.data = {
// backupHistory: []
// }
// const {
// backupHistory
// } = db.data;
// const data = ctx.request.body;
// const id = data.id;
// console.log("数据Id", id);
// if (id && backupHistory) {
// const currentDetail = backupHistory.find(item => item.id == id);
// if (currentDetail) {
// _.merge(currentDetail, data);
// }
// // Write db.data content to db.json
// await db.write()
// }
// ctx.body = {
// code: 0,
// };
// });
// router.post('/api/backupHistory/delete', async (ctx) => {
// ctx.type = 'application/json';
// const db = await getBackupDb();
// // You can also use this syntax if you prefer
// if (!db.data.backupHistory)
// db.data = {
// backupHistory: []
// }
// let {
// backupHistory
// } = db.data;
// const data = ctx.request.body;
// const ids = data.ids;
// if (ids.length > 0 && backupHistory) {
// let id = null;
// for (let i = 0; i < ids.length; i++) {
// id = ids[i];
// const idx = backupHistory.findIndex(item => item.id == id);
// if (idx != -1) {
// backupHistory.splice(idx, 1);
// }
// }
// // Write db.data content to db.json
// await db.write()
// }
// ctx.body = {
// code: 0,
// };
// });
}
export default getBackupHistory;