使用 maf重构
This commit is contained in:
@@ -9,6 +9,7 @@ using Repository;
|
||||
public class TransactionRecordController(
|
||||
ITransactionRecordRepository transactionRepository,
|
||||
ISmartHandleService smartHandleService,
|
||||
ISmartHandleServiceV2 smartHandleServiceV2,
|
||||
ILogger<TransactionRecordController> logger
|
||||
) : ControllerBase
|
||||
{
|
||||
@@ -603,28 +604,28 @@ public class TransactionRecordController(
|
||||
/// 一句话录账解析
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<TransactionParseResult>> ParseOneLine([FromBody] ParseOneLineRequestDto request)
|
||||
public async Task<BaseResponse<Service.AgentFramework.TransactionParseResult>> ParseOneLine([FromBody] ParseOneLineRequestDto request)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Text))
|
||||
{
|
||||
return "请求参数缺失:text".Fail<TransactionParseResult>();
|
||||
return "请求参数缺失:text".Fail<Service.AgentFramework.TransactionParseResult>();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var result = await smartHandleService.ParseOneLineBillAsync(request.Text);
|
||||
var agentResult = await smartHandleServiceV2.ParseOneLineBillAgentAsync(request.Text);
|
||||
|
||||
if (result == null)
|
||||
if (agentResult?.Data == null)
|
||||
{
|
||||
return "AI解析失败".Fail<TransactionParseResult>();
|
||||
return "AI解析失败".Fail<Service.AgentFramework.TransactionParseResult>();
|
||||
}
|
||||
|
||||
return result.Ok();
|
||||
return agentResult.Data.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "一句话录账解析失败,文本: {Text}", request.Text);
|
||||
return ("AI解析失败: " + ex.Message).Fail<TransactionParseResult>();
|
||||
return ("AI解析失败: " + ex.Message).Fail<Service.AgentFramework.TransactionParseResult>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user