feat(client-generator): improve angular generation

pull/2225/head
mehmet-erim 6 years ago
parent 6ca3b9905a
commit dcf30a7b46

@ -6,6 +6,7 @@
"typescript.tsdk": "../node_modules/typescript/lib",
"workbench.colorCustomizations": {
"activityBar.background": "#258ecd",
"activityBar.activeBorder": "#f0aed7",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#f0aed7",

@ -8,13 +8,26 @@ export async function angular(data: APIDefination.Response, selectedModules: str
const element = data.modules[module];
let contents = [] as string[];
(Object.keys(element.controllers) || []).forEach(key => {
console.warn(element.controllers[key].controllerName);
contents.push(' ');
const actions = (Object.keys(element.controllers) || []).map(key => element.controllers[key].actions);
actions.forEach(action => {
const actionKeys = Object.keys(action);
actionKeys.forEach(key => {
const element = action[key];
console.log(element);
switch (element.httpMethod) {
case 'GET':
contents.push(ServiceTemplates.getMethodTemplate(element.name, element.url));
break;
default:
break;
}
});
});
const service = ServiceTemplates.classTemplate(element.rootPath, contents);
await fse.writeFile(`${changeCase.kebabCase(element.rootPath + '-service')}.ts`, service);
console.log(service);
const service = ServiceTemplates.classTemplate(element.rootPath, contents.join('\n'));
await fse.writeFile(`dist/${changeCase.kebabCase(element.rootPath)}.service.ts`, service);
});
}

@ -2105,5 +2105,5 @@ axiosInstance.get = (...ar) => new Promise(resolve => {
}
}
} as any)
}, 1000);
}, 0);
})
Loading…
Cancel
Save