- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const FRONT_FILES = [
|
|
path.join(__dirname, '..', 'niucloud-admin-java', 'admin', 'src', 'app', 'api'),
|
|
path.join(__dirname, '..', 'niucloud-php', 'admin', 'src', 'app', 'api'),
|
|
];
|
|
|
|
function collectFrontendApiPaths() {
|
|
const paths = new Set();
|
|
const methodMap = new Map();
|
|
for (const dir of FRONT_FILES) {
|
|
if (!fs.existsSync(dir)) continue;
|
|
for (const file of fs.readdirSync(dir)) {
|
|
if (!file.endsWith('.ts')) continue;
|
|
const full = path.join(dir, file);
|
|
const txt = fs.readFileSync(full, 'utf8');
|
|
const rx = /request\.(get|post|put|delete)\(\s*[`'"]([^`'"\)]+)[`'"]/gi;
|
|
let m;
|
|
while ((m = rx.exec(txt))) {
|
|
const method = m[1].toUpperCase();
|
|
const p = m[2].replace(/^\//, '');
|
|
// Only admin panel sys/pay/... apis; skip absolute http urls
|
|
if (/^https?:\/\//i.test(p)) continue;
|
|
const backendPath = `adminapi/${p}`;
|
|
const key = `${method} ${backendPath}`;
|
|
if (!paths.has(key)) {
|
|
paths.add(key);
|
|
methodMap.set(key, { method, path: backendPath });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Array.from(methodMap.values())
|
|
.sort((a, b) => (a.path === b.path ? a.method.localeCompare(b.method) : a.path.localeCompare(b.path)));
|
|
}
|
|
|
|
function main() {
|
|
const list = collectFrontendApiPaths();
|
|
const outDir = path.join(__dirname, 'contracts');
|
|
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
|
const outFile = path.join(outDir, 'routes.json');
|
|
fs.writeFileSync(outFile, JSON.stringify(list, null, 2));
|
|
console.log(`Wrote ${list.length} routes to ${outFile}`);
|
|
}
|
|
|
|
main();
|
|
|
|
|