From 7c480461e38ffe7d2aa6fb121da413057cb41a63 Mon Sep 17 00:00:00 2001 From: Arman Ozak Date: Thu, 27 Aug 2020 23:32:38 +0300 Subject: [PATCH] feat: generate Volo.Abp.NameValue as generic type --- .../packages/schematics/src/constants/volo.ts | 10 +++++----- npm/ng-packs/packages/schematics/src/utils/model.ts | 11 +++-------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/npm/ng-packs/packages/schematics/src/constants/volo.ts b/npm/ng-packs/packages/schematics/src/constants/volo.ts index a6726594ee..12aa166d66 100644 --- a/npm/ng-packs/packages/schematics/src/constants/volo.ts +++ b/npm/ng-packs/packages/schematics/src/constants/volo.ts @@ -4,19 +4,19 @@ export const VOLO_REGEX = /^Volo\.Abp\.(Application\.Dtos|ObjectExtending)/; export const VOLO_NAME_VALUE = new Interface({ base: null, - identifier: 'NameValue', + identifier: 'NameValue', ref: 'Volo.Abp.NameValue', namespace: 'Volo.Abp', properties: [ new Property({ - name: 'Name', + name: 'name', type: 'string', refs: ['System.String'], }), new Property({ - name: 'Value', - type: 'string', - refs: ['System.String'], + name: 'value', + type: 'T', + refs: ['T'], }), ], }); diff --git a/npm/ng-packs/packages/schematics/src/utils/model.ts b/npm/ng-packs/packages/schematics/src/utils/model.ts index 19435f5f76..2ac5949050 100644 --- a/npm/ng-packs/packages/schematics/src/utils/model.ts +++ b/npm/ng-packs/packages/schematics/src/utils/model.ts @@ -40,10 +40,11 @@ export function createImportRefsToModelReducer(params: ModelGeneratorParams) { const index = models.findIndex(m => m.namespace === _interface.namespace); if (index > -1) { if (models[index].interfaces.some(i => i.identifier === _interface.identifier)) return; + if (_interface.ref.startsWith(VOLO_NAME_VALUE.ref)) return; models[index].interfaces.push(_interface); } else { - if (_interface.ref === VOLO_NAME_VALUE.ref) _interface = VOLO_NAME_VALUE; + if (_interface.ref.startsWith(VOLO_NAME_VALUE.ref)) _interface = VOLO_NAME_VALUE; const { namespace } = _interface; @@ -135,13 +136,7 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP prop.refs.forEach(type => !types[type]?.isEnum && refs.push(type)); return refs; }, []) - .concat( - base - ? parseGenerics(typeDef.baseType!) - .toGenerics() - .join('') - : [], - ) + .concat(base ? parseGenerics(typeDef.baseType!).toGenerics() : []) .reduce(reduceRefsToInterfaces, interfaces); } }