fix: 修复readServiceMethodSignature - 正确构造Service文件路径
🐛 Bug: - findServiceFile期望字符串参数,但传入了对象 - 代码逻辑重复 ✅ 修复: - 从methodServiceCalls提取serviceImplName - 正确调用findServiceFile(serviceImplName + '.service.ts') - 删除重复的代码逻辑
This commit is contained in:
@@ -616,16 +616,7 @@ ${methodBody}
|
||||
*/
|
||||
readServiceMethodSignature(method, javaController) {
|
||||
try {
|
||||
// 获取Service文件路径
|
||||
const servicePath = this.findServiceFile(javaController);
|
||||
if (!servicePath || !fs.existsSync(servicePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 读取Service文件内容
|
||||
const serviceContent = fs.readFileSync(servicePath, 'utf-8');
|
||||
|
||||
// 从methodServiceCalls中获取实际调用的Service方法名
|
||||
// 从methodServiceCalls中获取实际调用的Service名称
|
||||
const javaMethodName = method.javaMethodName;
|
||||
const methodServiceCalls = javaController.methodServiceCalls || {};
|
||||
const serviceCalls = methodServiceCalls[javaMethodName] || [];
|
||||
@@ -634,6 +625,24 @@ ${methodBody}
|
||||
return null;
|
||||
}
|
||||
|
||||
const serviceImplName = serviceCalls[0].serviceImpl;
|
||||
|
||||
// 获取Service文件的相对路径
|
||||
const serviceRelPath = this.findServiceFile(serviceImplName + '.service.ts');
|
||||
if (!serviceRelPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 构造完整路径
|
||||
const servicePath = path.join(this.outputDir, 'services', serviceRelPath);
|
||||
if (!fs.existsSync(servicePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 读取Service文件内容
|
||||
const serviceContent = fs.readFileSync(servicePath, 'utf-8');
|
||||
|
||||
// 获取Service方法名(已经在上面获取了serviceCalls)
|
||||
const serviceMethodName = serviceCalls[0].serviceMethod;
|
||||
|
||||
// 提取方法签名:async methodName(param1: Type1, param2: Type2): Promise<ReturnType>
|
||||
|
||||
Reference in New Issue
Block a user