'use strict'; /** * [autoCreateRouter 自动创建路由] * @param {[type]} routerName [description] * @param {[type]} path [description] * @param {Array} params [description] * @return {[type]} [description] */ const autoCreateRouter = function(namespaceRouter, path, actionController, params = [ 'get', 'post', 'put', 'delete' ], others = { get: 'select', post: 'create', put: 'update', delete: 'delete' }) { params.forEach(item => { namespaceRouter[item](path, actionController[others[item]]); }); }; /** * [框架基本路由] * @author szjcomo * @date 2021-05-25 * @param {[type]} app [description] * @param {[type]} managerRouter [description] * @return {[type]} [description] */ module.exports = (app, managerRouter) => { const manager = app.controller.manager; // 获取控制台数据 autoCreateRouter(managerRouter, '/console', manager.login, [ 'get' ], { get: 'manager' }); // 管理员数据接口 autoCreateRouter(managerRouter, '/admin_user', manager.adminUser); // 管理员角色数据接口 autoCreateRouter(managerRouter, '/roles', manager.roles); // 获取角色权限接口 autoCreateRouter(managerRouter, '/roles/auth', manager.roles, [ 'get', 'post' ], { get: 'getRoleAuth', post: 'roleAuth' }); // 权限节点接口 autoCreateRouter(managerRouter, '/accesss', manager.accesss); // 配置操作接口 autoCreateRouter(managerRouter, '/configs', manager.configs); // 配置设置接口 autoCreateRouter(managerRouter, '/configs/setting', manager.configs, [ 'post' ], { post: 'setting' }); // 文章操作接口 autoCreateRouter(managerRouter, '/articles', manager.articles); // 文章分数接口 autoCreateRouter(managerRouter, '/articles/category', manager.articlesCategory); };