'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, '/shops/products', manager.shops.products); // 商品详细介绍接口 autoCreateRouter(managerRouter, '/shops/products/desction', manager.shops.products, [ 'get' ], { get: 'selectDesction' }); // 商品相册查询接口 autoCreateRouter(managerRouter, '/shops/products/carousels', manager.shops.products, [ 'get' ], { get: 'selectCarousels' }); // 查询商品属性接口 autoCreateRouter(managerRouter, '/shops/products/spes', manager.shops.products, [ 'get' ], { get: 'selectSpes' }); // 商品分类操作接口 autoCreateRouter(managerRouter, '/shops/category', manager.shops.productCategory); // 商品品牌操作作接口 autoCreateRouter(managerRouter, '/shops/brands', manager.shops.productBrands); // 商品供货商操作作接口 autoCreateRouter(managerRouter, '/shops/suppliers', manager.shops.productSuppliers); // 商品类型操作接口 autoCreateRouter(managerRouter, '/shops/types', manager.shops.productTypes); // 商品类型属性操作接口 autoCreateRouter(managerRouter, '/shops/types/attr', manager.shops.productTypesItem); // 商品类型属性列表查询 autoCreateRouter(managerRouter, '/shops/types/list', manager.shops.productTypesItem, [ 'get' ], { get: 'selectItems' }); // 支付方式操作接口 autoCreateRouter(managerRouter, '/shops/paysConfig', manager.shops.paysConfig); // 配送方式操作接口 autoCreateRouter(managerRouter, '/shops/shippingsConfig', manager.shops.shippingsConfig); // 订单操作接口 autoCreateRouter(managerRouter, '/shops/orders', manager.shops.orders); // 订单发货接口 autoCreateRouter(managerRouter, '/shops/orders/action', manager.shops.orders, [ 'put', 'post', 'get' ], { put: 'orderDeliver', post: 'orderReceive', get: 'orderLogs' }); // 打印小票接口 autoCreateRouter(managerRouter, '/shops/order/print', manager.shops.orders, [ 'get' ], { get: 'orderPrinter' }); // 用户管理接口 autoCreateRouter(managerRouter, '/shops/users', manager.shops.users); // 用户资金明细 autoCreateRouter(managerRouter, '/shops/users/moneylog', manager.shops.users, [ 'get' ], { get: 'moneyLogs' }); };