index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. 'use strict';
  2. // 路由配置
  3. const rkey = 'statistics/index';
  4. const ckey = 'statistics.index';
  5. const keyZh = '统计';
  6. const routes = [
  7. { method: 'get', path: `${rkey}/dockProduct`, controller: `${ckey}.dockProduct`, name: `${ckey}dockProduct`, zh: `${keyZh}-展会产品统计` },
  8. { method: 'get', path: `${rkey}/dockIndex`, controller: `${ckey}.dockIndex`, name: `${ckey}dockIndex`, zh: `${keyZh}-不知道` },
  9. { method: 'get', path: `${rkey}/index`, controller: `${ckey}.index`, name: `${ckey}Index`, zh: `${keyZh}-展会首页统计` },
  10. { method: 'get', path: `${rkey}/patent`, controller: `${ckey}.patent`, name: `${ckey}patent`, zh: `${keyZh}-首页专利统计` },
  11. { method: 'get', path: `${rkey}/product`, controller: `${ckey}.product`, name: `${ckey}product`, zh: `${keyZh}-首页成果统计` },
  12. { method: 'get', path: `${rkey}/expert`, controller: `${ckey}.expert`, name: `${ckey}expert`, zh: `${keyZh}-首页专家统计` },
  13. { method: 'get', path: `${rkey}/circle`, controller: `${ckey}.circle`, name: `${ckey}circle`, zh: `${keyZh}-首页数据统计` },
  14. { method: 'get', path: `${rkey}/orgCount`, controller: `${ckey}.orgCount`, name: `${ckey}orgCount`, zh: `${keyZh}-企业数量统计` },
  15. { method: 'get', path: `${rkey}/pac`, controller: `${ckey}.policyApplyCount`, name: `${ckey}policyApplyCount`, zh: `${keyZh}-创新券申请统计` },
  16. { method: 'get', path: `${rkey}/declare`, controller: `${ckey}.declare`, name: `${ckey}declare`, zh: `${keyZh}-高企申报个步骤统计` },
  17. { method: 'get', path: `${rkey}/patentUserIndex`, controller: `${ckey}.patentUserIndex`, name: `${ckey}patentUserIndex`, zh: `${keyZh}-专利运营用户首页统计` },
  18. {
  19. method: 'get',
  20. path: `${rkey}/patentInfoByApplyPerson`,
  21. controller: `${ckey}.patentInfoByApplyPerson`,
  22. name: `${ckey}patentInfoByApplyPerson`,
  23. zh: `${keyZh}-根据申请人统计,申请人所在的专利信息数量`,
  24. },
  25. ];
  26. module.exports = app => {
  27. const { router, config } = app;
  28. const mwares = app.middleware;
  29. console.log(`${keyZh}: ${rkey}`);
  30. for (const route of routes) {
  31. const { method, path, controller: ctl, zh } = route;
  32. let { middleware = [] } = route;
  33. if (!method || !path || !ctl) continue;
  34. // 拼全路径
  35. const allPath = `${config.routePrefix}/${path}`;
  36. // 处理中间件
  37. if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
  38. // 注册路由
  39. router[method](zh, allPath, ...middleware, ctl);
  40. }
  41. };