This commit is contained in:
张成
2025-11-21 16:53:49 +08:00
commit 8309808835
286 changed files with 32656 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
const { sys_menu, op } = require("../../middleware/baseModel");
const autoFile = require("../service/autoFile");
const funTool = require("../../tool/funTool");
module.exports = {
"GET /sys_menu/index": async (ctx, next) => {
const menuRows = await sys_menu.findAll({
order: [["sort", "ASC"]],
});
let newMenuRows = menuRows.map((row) => {
let newRow = row.toJSON();
let nodeIds = funTool.getParantNode(newRow, menuRows);
newRow.parent_node_ids = nodeIds.reverse();
return newRow;
});
return ctx.success(newMenuRows);
},
"POST /sys_menu/add": async (ctx, next) => {
let row = ctx.getBody();
const res = await sys_menu.create(row);
return ctx.success(res);
},
"POST /sys_menu/edit": async (ctx, next) => {
let row = ctx.getBody();
let id = ctx.get("id");
const resList = await sys_menu.update(row, {
where: {
id: id,
},
});
return ctx.success(resList);
},
"POST /sys_menu/del": async (ctx, next) => {
let id = ctx.get("id");
const res = await sys_menu.destroy({ where: { id: id } });
return ctx.success(res);
},
};