mirror of https://github.com/abpframework/abp.git
1 changed files with 15 additions and 5 deletions
@ -1,18 +1,28 @@ |
|||||
import changeCase from 'change-case'; |
import changeCase from 'change-case'; |
||||
|
import { replacer } from '../../utils/replacer'; |
||||
|
|
||||
export namespace ServiceTemplates { |
export namespace ServiceTemplates { |
||||
export function classTemplate(name: string, contents: string[]) { |
export function classTemplate(name: string, content: string) { |
||||
return `import { RestService } from '@abp/ng.core';
|
return `import { RestService } from '@abp/ng.core';
|
||||
import { Injectable } from '@angular/core'; |
import { Injectable } from '@angular/core'; |
||||
|
import { Observable } from 'rxjs' |
||||
|
|
||||
@Injectable({ |
@Injectable({ |
||||
providedIn: 'root', |
providedIn: 'root', |
||||
}) |
}) |
||||
export class ${changeCase.pascalCase(name)}Service { |
export class ${changeCase.pascalCase(name)}Service { |
||||
|
constructor(private restService: RestService) {} |
||||
constructor(private restService: RestService) { } |
${content} |
||||
|
|
||||
${contents[0]} |
|
||||
}`;
|
}`;
|
||||
} |
} |
||||
|
|
||||
|
export function getMethodTemplate(name: string, url: string, params: string[] = [], queryParams?: object) { |
||||
|
return ` |
||||
|
${changeCase.camelCase(replacer(name))}(${params.join(', ')}): Observable<any> { |
||||
|
return this.restService.request<void, any>({ |
||||
|
method: 'GET', |
||||
|
url: '/${url}${params.length ? '/' + params.join('/') : ''}', |
||||
|
}); |
||||
|
}`;
|
||||
|
} |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue