apps.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict';
  2. /**
  3. * [autoCreateRouter 自动创建路由]
  4. * @param {[type]} routerName [description]
  5. * @param {[type]} path [description]
  6. * @param {Array} params [description]
  7. * @return {[type]} [description]
  8. */
  9. const autoCreateRouter = function(namespaceRouter, path, actionController, params = [ 'get', 'post', 'put', 'delete' ], others = { get: 'select', post: 'create', put: 'update', delete: 'delete' }) {
  10. params.forEach(item => {
  11. namespaceRouter[item](path, actionController[others[item]]);
  12. });
  13. };
  14. /**
  15. * [框架基本路由]
  16. * @author szjcomo
  17. * @date 2021-05-25
  18. * @param {[type]} app [description]
  19. * @param {[type]} managerRouter [description]
  20. * @return {[type]} [description]
  21. */
  22. module.exports = (app, managerRouter) => {
  23. const manager = app.controller.manager;
  24. // 商品操作接口
  25. autoCreateRouter(managerRouter, '/shops/products', manager.shops.products);
  26. // 商品详细介绍接口
  27. autoCreateRouter(managerRouter, '/shops/products/desction', manager.shops.products, [ 'get' ], { get: 'selectDesction' });
  28. // 商品相册查询接口
  29. autoCreateRouter(managerRouter, '/shops/products/carousels', manager.shops.products, [ 'get' ], { get: 'selectCarousels' });
  30. // 查询商品属性接口
  31. autoCreateRouter(managerRouter, '/shops/products/spes', manager.shops.products, [ 'get' ], { get: 'selectSpes' });
  32. // 商品分类操作接口
  33. autoCreateRouter(managerRouter, '/shops/category', manager.shops.productCategory);
  34. // 商品品牌操作作接口
  35. autoCreateRouter(managerRouter, '/shops/brands', manager.shops.productBrands);
  36. // 商品供货商操作作接口
  37. autoCreateRouter(managerRouter, '/shops/suppliers', manager.shops.productSuppliers);
  38. // 商品类型操作接口
  39. autoCreateRouter(managerRouter, '/shops/types', manager.shops.productTypes);
  40. // 商品类型属性操作接口
  41. autoCreateRouter(managerRouter, '/shops/types/attr', manager.shops.productTypesItem);
  42. // 商品类型属性列表查询
  43. autoCreateRouter(managerRouter, '/shops/types/list', manager.shops.productTypesItem, [ 'get' ], { get: 'selectItems' });
  44. // 支付方式操作接口
  45. autoCreateRouter(managerRouter, '/shops/paysConfig', manager.shops.paysConfig);
  46. // 配送方式操作接口
  47. autoCreateRouter(managerRouter, '/shops/shippingsConfig', manager.shops.shippingsConfig);
  48. // 订单操作接口
  49. autoCreateRouter(managerRouter, '/shops/orders', manager.shops.orders);
  50. // 订单发货接口
  51. autoCreateRouter(managerRouter, '/shops/orders/action', manager.shops.orders, [ 'put', 'post', 'get' ], {
  52. put: 'orderDeliver',
  53. post: 'orderReceive',
  54. get: 'orderLogs'
  55. });
  56. // 打印小票接口
  57. autoCreateRouter(managerRouter, '/shops/order/print', manager.shops.orders, [ 'get' ], { get: 'orderPrinter' });
  58. // 用户管理接口
  59. autoCreateRouter(managerRouter, '/shops/users', manager.shops.users);
  60. // 用户资金明细
  61. autoCreateRouter(managerRouter, '/shops/users/moneylog', manager.shops.users, [ 'get' ], { get: 'moneyLogs' });
  62. };