updateapply.js 1.1 KB

123456789101112131415161718192021222324
  1. 'use strict';
  2. // 路由配置
  3. const routes = [
  4. { method: 'get', path: '/updateapply', controller: 'updateapply.index', middleware: [ 'applyQuery' ], name: 'updateapplyQuery', zh: '绩效修改申请列表查询' },
  5. { method: 'post', path: '/updateapply', controller: 'updateapply.create', name: 'updateapplyCreate', zh: '创建绩效修改申请设置' },
  6. { method: 'post', path: '/updateapply/:id', controller: 'updateapply.update', name: 'updateapplyUpdate', zh: '修改绩效修改申请设置' },
  7. // { method: 'delete', path: '/updateapply/:id', controller: 'achievementSetting.destroy', name: 'settingDelete', zh: '删除绩效设置' },
  8. ];
  9. module.exports = app => {
  10. const { router, config } = app;
  11. const mwares = app.middleware;
  12. for (const route of routes) {
  13. const { method, path, controller: ctl, zh } = route;
  14. let { middleware = [] } = route;
  15. if (!method || !path || !ctl) continue;
  16. // 拼全路径
  17. const allPath = `${config.routePrefix}${path}`;
  18. // 处理中间件
  19. if (middleware.length > 0) middleware = middleware.map(i => mwares[i]());
  20. // 注册路由
  21. router[method](zh, allPath, ...middleware, ctl);
  22. }
  23. };