接口
/**
* 客户列表
*/
export async function getCustomerList(data = {}) {
return request({
url: '/v1/customer/queryPage',
data,
MODULE: moduleInfo.kylinQuery,
});
}
const fs = require('fs');
function getFilePathFromDir(dir, filePathList) {
const names = fs.readdirSync(dir);
names.forEach((name) => {
const stat = fs.statSync(`${dir}/${name}`);
if (stat.isDirectory()) {
getFilePathFromDir(`${dir}/${name}`, filePathList);
} else {
filePathList.push(`${dir}/${name}`);
}
});
}
const filePathList = [];
getFilePathFromDir('src/service', filePathList);
const warns = [];
const results = [];
let allApis = [];
filePathList.forEach((p) => {
const data = fs.readFileSync(p, 'utf-8');
const apis = data.split(/return request|return requestExt/);
apis.splice(0, 1);
allApis = allApis.concat(apis);
apis.forEach((api) => {
const modMatch = api.match(/moduleInfo\.(.+),?/);
if (!modMatch || modMatch.length === 0) {
warns.push(`【${api}】匹配module参数失败, 被忽略`);
return;
}
const module = modMatch[1];
const partUrlMatch = api.match(/url: ['`"](.+)['`"]/);
if (!partUrlMatch || partUrlMatch.length === 0) {
warns.push(`【${api}】匹配url失败, 被忽略`);
return;
}
const partUrl = partUrlMatch[1];
results.push({
module,
url: partUrl,
});
});
});
if (warns && warns.length > 0) {
console.log(
'\x1B[33m%s\x1B[39m',
`警告[${warns.length}]:\r\n`,
warns.join('\r\n'),
);
console.log('\x1B[33m%s\x1B[39m', '!!!请确认以上警告不会对功能造成影响');
} else {
console.log('\x1B[32m%s\x1B[39m', '读取完成');
}
console.log({
apiLength: allApis.length,
resultsLength: results.length,
});
console.log('\r\n------------ 开始写文件 success.txt ------------');
fs.writeFileSync('./success.txt', JSON.stringify(results));
console.log('\x1B[32m%s\x1B[39m', '写入完成\r\n');