Files
funjia-admin-template-vue/server/routers/backupHistory.mjs
T

108 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;