- 重构sys模块架构,严格按admin/api/core分层 - 对齐所有sys实体与数据库表结构 - 实现完整的adminapi控制器,匹配PHP/Java契约 - 修复依赖注入问题,确保服务正确注册 - 添加自动迁移工具和契约验证 - 完善多租户支持和审计功能 - 统一命名规范,与PHP业务逻辑保持一致
65 lines
2.3 KiB
JavaScript
65 lines
2.3 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function collectFromDir(dir) {
|
|
const list = [];
|
|
if (!fs.existsSync(dir)) return list;
|
|
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(/^\//, '');
|
|
if (/^https?:\/\//i.test(p)) continue;
|
|
list.push({ method, path: p });
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
function toKey(r) {
|
|
return `${r.method} ${r.path}`;
|
|
}
|
|
|
|
function unique(list) {
|
|
const map = new Map();
|
|
for (const r of list) map.set(toKey(r), r);
|
|
return Array.from(map.values()).sort((a, b) => (a.path === b.path ? a.method.localeCompare(b.method) : a.path.localeCompare(b.path)));
|
|
}
|
|
|
|
function main() {
|
|
const javaDir = path.join(__dirname, '..', 'niucloud-admin-java', 'admin', 'src', 'app', 'api');
|
|
const phpDir = path.join(__dirname, '..', 'niucloud-php', 'admin', 'src', 'app', 'api');
|
|
|
|
const javaList = unique(collectFromDir(javaDir));
|
|
const phpList = unique(collectFromDir(phpDir));
|
|
|
|
const javaSet = new Set(javaList.map(toKey));
|
|
const phpSet = new Set(phpList.map(toKey));
|
|
|
|
const both = javaList.filter((r) => phpSet.has(toKey(r)));
|
|
const onlyJava = javaList.filter((r) => !phpSet.has(toKey(r)));
|
|
const onlyPhp = phpList.filter((r) => !javaSet.has(toKey(r)));
|
|
|
|
const outDir = path.join(__dirname, 'contracts');
|
|
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
|
fs.writeFileSync(path.join(outDir, 'routes.java.json'), JSON.stringify(javaList, null, 2));
|
|
fs.writeFileSync(path.join(outDir, 'routes.php.json'), JSON.stringify(phpList, null, 2));
|
|
fs.writeFileSync(path.join(outDir, 'routes.intersection.json'), JSON.stringify(both, null, 2));
|
|
fs.writeFileSync(path.join(outDir, 'routes.only-java.json'), JSON.stringify(onlyJava, null, 2));
|
|
fs.writeFileSync(path.join(outDir, 'routes.only-php.json'), JSON.stringify(onlyPhp, null, 2));
|
|
|
|
console.log(`Java total: ${javaList.length}`);
|
|
console.log(`PHP total: ${phpList.length}`);
|
|
console.log(`Overlap: ${both.length}`);
|
|
console.log(`Only Java: ${onlyJava.length}`);
|
|
console.log(`Only PHP: ${onlyPhp.length}`);
|
|
}
|
|
|
|
main();
|
|
|
|
|