mirror of https://github.com/abpframework/abp.git
10 changed files with 78 additions and 15 deletions
@ -1,3 +1,3 @@ |
|||
export declare namespace ServiceTemplates { |
|||
function classTemplate(name: string): void; |
|||
function classTemplate(name: string, content: string[]): string; |
|||
} |
|||
|
|||
@ -1,9 +1,15 @@ |
|||
"use strict"; |
|||
var __importDefault = (this && this.__importDefault) || function (mod) { |
|||
return (mod && mod.__esModule) ? mod : { "default": mod }; |
|||
}; |
|||
Object.defineProperty(exports, "__esModule", { value: true }); |
|||
var change_case_1 = __importDefault(require("change-case")); |
|||
var ServiceTemplates; |
|||
(function (ServiceTemplates) { |
|||
function classTemplate(name) { |
|||
"import { RestService } from '@abp/ng.core';\nimport { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class " + name + "Service {\n\n constructor(private restService: RestService) { }\n\n}"; |
|||
function classTemplate(name, content) { |
|||
return "import { RestService } from '@abp/ng.core';\nimport { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class " + change_case_1.default.pascalCase(name) + "Service {\n\n constructor(private restService: RestService) { }\n\n " + content.forEach(function (element) { |
|||
element + '\n\n'; |
|||
}) + "\n}"; |
|||
} |
|||
ServiceTemplates.classTemplate = classTemplate; |
|||
})(ServiceTemplates = exports.ServiceTemplates || (exports.ServiceTemplates = {})); |
|||
|
|||
@ -1,7 +1,20 @@ |
|||
import { APIDefination } from './types/api-defination'; |
|||
import { ServiceTemplates } from './templates/angular/service-templates'; |
|||
import changeCase from 'change-case'; |
|||
import fse from 'fs-extra'; |
|||
|
|||
export async function angular(data: APIDefination.Response, selectedModules: string[]) { |
|||
selectedModules.forEach(module => { |
|||
console.log(module); |
|||
selectedModules.forEach(async module => { |
|||
const element = data.modules[module]; |
|||
|
|||
let contents = [] as string[]; |
|||
(Object.keys(element.controllers) || []).forEach(key => { |
|||
console.warn(element.controllers[key].controllerName); |
|||
contents.push(' '); |
|||
}); |
|||
|
|||
const service = ServiceTemplates.classTemplate(element.rootPath, contents); |
|||
await fse.writeFile(`${changeCase.kebabCase(element.rootPath + '-service')}.ts`, service); |
|||
console.log(service); |
|||
}); |
|||
} |
|||
|
|||
Loading…
Reference in new issue