diff --git a/core/package.json b/core/package.json index 8b65ec6..8c7e83e 100644 --- a/core/package.json +++ b/core/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.1.24", + "version": "7.1.25", "description": "", "main": "dist/index.js", "typings": "index.d.ts", diff --git a/core/src/package.json b/core/src/package.json index 1c58050..8e59e6a 100644 --- a/core/src/package.json +++ b/core/src/package.json @@ -1,6 +1,6 @@ { "name": "@cool-midway/core", - "version": "7.1.24", + "version": "7.1.25", "description": "", "main": "index.js", "typings": "index.d.ts", diff --git a/core/src/tag/data.ts b/core/src/tag/data.ts index eb57354..9d9bff6 100644 --- a/core/src/tag/data.ts +++ b/core/src/tag/data.ts @@ -20,7 +20,20 @@ import * as _ from 'lodash'; export class CoolUrlTagData { data = {}; + /** + * 初始化 + */ async init() { + // 类标记 + await this.classTag(); + // 方法标记 + await this.methodTag(); + } + + /** + * 类标记 + */ + async classTag() { const tags = listModule(COOL_URL_TAG_KEY); for (const controller of tags) { // class的标记 @@ -37,18 +50,28 @@ export class CoolUrlTagData { })) ); } - // 方法标记 - const listPropertyMetas = listPropertyDataFromClass(COOL_METHOD_TAG_KEY, controller); - const requestMetas = getClassMetadata(WEB_ROUTER_KEY, controller); - for (const propertyMeta of listPropertyMetas) { - const _data = this.data[propertyMeta.tag] || []; - const requestMeta = _.find(requestMetas, { method: propertyMeta.key }) - if(requestMeta){ - this.data[propertyMeta.tag] = _.uniq(_data.concat( - controllerOption.prefix + requestMeta.path - )) - } - } + } + } + + /** + * 方法标记 + */ + async methodTag() { + const controllers = listModule(CONTROLLER_KEY); + for (const controller of controllers) { + const controllerOption = getClassMetadata(CONTROLLER_KEY, controller); + // 方法标记 + const listPropertyMetas = listPropertyDataFromClass(COOL_METHOD_TAG_KEY, controller); + const requestMetas = getClassMetadata(WEB_ROUTER_KEY, controller); + for (const propertyMeta of listPropertyMetas) { + const _data = this.data[propertyMeta.tag] || []; + const requestMeta = _.find(requestMetas, { method: propertyMeta.key }) + if(requestMeta){ + this.data[propertyMeta.tag] = _.uniq(_data.concat( + controllerOption.prefix + requestMeta.path + )) + } + } } }