完善路由标签CoolTag可以单独使用

This commit is contained in:
COOL 2025-01-02 15:16:04 +08:00
parent b670e8ead7
commit 0623782867
3 changed files with 37 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "7.1.24", "version": "7.1.25",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -1,6 +1,6 @@
{ {
"name": "@cool-midway/core", "name": "@cool-midway/core",
"version": "7.1.24", "version": "7.1.25",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"typings": "index.d.ts", "typings": "index.d.ts",

View File

@ -20,7 +20,20 @@ import * as _ from 'lodash';
export class CoolUrlTagData { export class CoolUrlTagData {
data = {}; data = {};
/**
*
*/
async init() { async init() {
// 类标记
await this.classTag();
// 方法标记
await this.methodTag();
}
/**
*
*/
async classTag() {
const tags = listModule(COOL_URL_TAG_KEY); const tags = listModule(COOL_URL_TAG_KEY);
for (const controller of tags) { for (const controller of tags) {
// class的标记 // 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){ async methodTag() {
this.data[propertyMeta.tag] = _.uniq(_data.concat( const controllers = listModule(CONTROLLER_KEY);
controllerOption.prefix + requestMeta.path 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
))
}
}
} }
} }