Browse Source

fix IRemoteStreamContent issue on generate service

pull/16489/head
Mahmut Gundogdu 3 years ago
parent
commit
e025a3b1dc
  1. 5
      npm/ng-packs/packages/schematics/src/constants/volo.ts
  2. 1
      npm/ng-packs/packages/schematics/src/enums/binding-source-id.ts
  3. 3
      npm/ng-packs/packages/schematics/src/models/method.ts
  4. 16
      npm/ng-packs/packages/schematics/src/utils/service.ts

5
npm/ng-packs/packages/schematics/src/constants/volo.ts

@ -1,2 +1,5 @@
export const VOLO_REGEX = /^Volo\.Abp\.(Application\.Dtos|ObjectExtending)/;
export const VOLO_REMOTE_STREAM_CONTENT = 'Volo.Abp.Content.IRemoteStreamContent'
export const VOLO_REMOTE_STREAM_CONTENT = [
'Volo.Abp.Content.IRemoteStreamContent',
'Volo.Abp.Content.RemoteStreamContent',
];

1
npm/ng-packs/packages/schematics/src/enums/binding-source-id.ts

@ -3,4 +3,5 @@ export enum eBindingSourceId {
Model = 'ModelBinding',
Path = 'Path',
Query = 'Query',
FormFile = 'FormFile',
}

3
npm/ng-packs/packages/schematics/src/models/method.ts

@ -59,6 +59,7 @@ export class Body {
case eBindingSourceId.Query:
this.params.push(paramName === value ? value : `${getParamName(paramName)}: ${value}`);
break;
case eBindingSourceId.FormFile:
case eBindingSourceId.Body:
this.body = value;
break;
@ -78,7 +79,7 @@ export class Body {
}
isBlobMethod() {
return this.responseTypeWithNamespace === VOLO_REMOTE_STREAM_CONTENT;
return VOLO_REMOTE_STREAM_CONTENT.some(x => x === this.responseTypeWithNamespace);
}
private setUrlQuotes() {

16
npm/ng-packs/packages/schematics/src/utils/service.ts

@ -55,9 +55,12 @@ export function createControllerToServiceMapper({
function getTypesWithoutIRemoteStreamContent(types: Record<string, Type>) {
const newType = { ...types };
delete newType[VOLO_REMOTE_STREAM_CONTENT];
VOLO_REMOTE_STREAM_CONTENT.forEach(fileType => {
delete newType[fileType];
});
return newType;
}
function sortMethods(methods: Method[]) {
methods.sort((a, b) => (a.signature.name > b.signature.name ? 1 : -1));
}
@ -99,7 +102,14 @@ export function createActionToSignatureMapper() {
...action.parametersOnMethod,
...(versionParameter ? [versionParameter] : []),
];
signature.parameters = parameters.map(p => {
const isFormData = isRemoteStreamContent(p.typeSimple);
if (isFormData) {
const formDataParameter = new Property({ name: p.name, type: 'FormData' });
formDataParameter.setOptional(false);
return formDataParameter;
}
const type = adaptType(p.typeSimple);
const parameter = new Property({ name: p.name, type });
parameter.setDefault(p.defaultValue);
@ -112,6 +122,10 @@ export function createActionToSignatureMapper() {
};
}
export function isRemoteStreamContent(type: string) {
return VOLO_REMOTE_STREAM_CONTENT.some(x => x === type);
}
function getMethodNameFromAction(action: Action): string {
return action.uniqueName.split('Async')[0];
}

Loading…
Cancel
Save