Files
TsxVueClassApi/bin/service-code-generation/index.js
2024-09-27 00:48:07 +08:00

30 lines
884 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const config = require('./config')
const readApiList = require('./utils/ReadApiList')
const file = require('./utils/File')
let ServerMap = new Map();
// Map(3) {
// 'Car' => Map(2) { 'IndexTest' => 'IndexTest', 'carList' => 'carList' },
// 'Index' => Map(1) { 'reg' => 'reg' },
// 'Order' => Map(1) { 'test' => 'test' }
// }
let main = async () => {
let readApi = new readApiList(config.apiListPath)
let res = await readApi.getFileList()
res.forEach(v => {
// [ 'Car', 'IndexTest' ]
let key = v.split(":")[0].split("_")
if (!ServerMap.get(key[0])) {
ServerMap.set(key[0], new Map())
}
ServerMap.get(key[0]).set(key[1],key[1])
});
// 根据接口对象的配置文件自动生成service文件和代码
ServerMap.forEach((value,key) => {
file.createdService(key,value)
})
}
main()