|
@@ -0,0 +1,33 @@
|
|
|
+'use strict';
|
|
|
+// 路由配置
|
|
|
+const rkey = 'patent';
|
|
|
+const ckey = 'dock.patent';
|
|
|
+const keyZh = '专利';
|
|
|
+const routes = [
|
|
|
+ { method: 'post', path: `${rkey}/import`, controller: `${ckey}.toImport`, name: `${ckey}import`, zh: `${keyZh}导入` },
|
|
|
+ { method: 'post', path: `${rkey}/export`, controller: `${ckey}.toExport`, name: `${ckey}export`, zh: `${keyZh}导出` },
|
|
|
+ { method: 'get', path: `${rkey}/getByCN/:create_number`, controller: `${ckey}.getByCN`, name: `${ckey}getByCN`, zh: `查询${keyZh}-由申请号获取` },
|
|
|
+
|
|
|
+ { method: 'get', path: `${rkey}`, controller: `${ckey}.index`, name: `${ckey}Query`, zh: `${keyZh}列表查询` },
|
|
|
+ { method: 'get', path: `${rkey}/:id`, controller: `${ckey}.show`, name: `${ckey}Show`, zh: `${keyZh}查询` },
|
|
|
+ { method: 'post', path: `${rkey}`, controller: `${ckey}.create`, name: `${ckey}Create`, zh: `创建${keyZh}` },
|
|
|
+ { method: 'post', path: `${rkey}/:id`, controller: `${ckey}.update`, name: `${ckey}Update`, zh: `修改${keyZh}` },
|
|
|
+ { method: 'delete', path: `${rkey}/:id`, controller: `${ckey}.destroy`, name: `${ckey}Delete`, zh: `删除${keyZh}` },
|
|
|
+];
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { router, config } = app;
|
|
|
+ const mwares = app.middleware;
|
|
|
+ console.log(`${keyZh}: ${rkey}`);
|
|
|
+ for (const route of routes) {
|
|
|
+ const { method, path, controller: ctl, zh } = route;
|
|
|
+ let { middleware = [] } = route;
|
|
|
+ if (!method || !path || !ctl) continue;
|
|
|
+ // 拼全路径
|
|
|
+ const allPath = `${config.routePrefix}/${path}`;
|
|
|
+ // 处理中间件
|
|
|
+ if (middleware.length > 0) middleware = middleware.map(i => mwares[i]({ enable: true }));
|
|
|
+ // 注册路由
|
|
|
+ router[method](zh, allPath, ...middleware, ctl);
|
|
|
+ }
|
|
|
+};
|