'use strict'; // 路由配置 const routes = [ { method: 'get', path: '/updateapply', controller: 'updateapply.index', middleware: [ 'applyQuery' ], name: 'updateapplyQuery', zh: '绩效修改申请列表查询' }, { method: 'post', path: '/updateapply', controller: 'updateapply.create', name: 'updateapplyCreate', zh: '创建绩效修改申请设置' }, { method: 'post', path: '/updateapply/:id', controller: 'updateapply.update', name: 'updateapplyUpdate', zh: '修改绩效修改申请设置' }, // { method: 'delete', path: '/updateapply/:id', controller: 'achievementSetting.destroy', name: 'settingDelete', zh: '删除绩效设置' }, ]; module.exports = app => { const { router, config } = app; const mwares = app.middleware; for (const route of routes) { const { method, path, controller: ctl, zh } = route; let { middleware = [] } = route; if (!method || !path || !ctl) continue; // 拼全路径 const allPath = `${config.routePrefix}${path}`; // 处理中间件 if (middleware.length > 0) middleware = middleware.map(i => mwares[i]()); // 注册路由 router[method](zh, allPath, ...middleware, ctl); } };