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); }, };