From 4d487474807ea070c372b7f500ec2b64e990a527 Mon Sep 17 00:00:00 2001 From: root <295172551@qq.com> Date: Sat, 14 Jun 2025 21:32:15 +0800 Subject: [PATCH] =?UTF-8?q?start=20ApiActionResult=20=E6=94=BE=E5=9B=9E?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CoreAgent.API/Controllers/CellularNetworkController.cs | 2 +- .../CellularNetwork/StartCellularNetworkCommand.cs | 2 +- .../StartCellularNetworkCommandHandler.cs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CoreAgent.API/Controllers/CellularNetworkController.cs b/CoreAgent.API/Controllers/CellularNetworkController.cs index aaa83e3..f710564 100644 --- a/CoreAgent.API/Controllers/CellularNetworkController.cs +++ b/CoreAgent.API/Controllers/CellularNetworkController.cs @@ -34,7 +34,7 @@ public class CellularNetworkController : BaseApiController public async Task Start([FromBody] StartCellularNetworkCommand command) { _logger.LogInformation("收到启动蜂窝网络请求: {ConfigKey}", command.Key); - return await HandleRequest>(command); + return await HandleRequest>(command); } /// diff --git a/CoreAgent.Application/Commands/CellularNetwork/StartCellularNetworkCommand.cs b/CoreAgent.Application/Commands/CellularNetwork/StartCellularNetworkCommand.cs index 0ce4c13..20ba308 100644 --- a/CoreAgent.Application/Commands/CellularNetwork/StartCellularNetworkCommand.cs +++ b/CoreAgent.Application/Commands/CellularNetwork/StartCellularNetworkCommand.cs @@ -7,7 +7,7 @@ namespace CoreAgent.Application.Commands.CellularNetwork; /// /// 启动蜂窝网络命令 /// -public class StartCellularNetworkCommand : IRequest> +public class StartCellularNetworkCommand : IRequest> { /// /// 网络配置键 diff --git a/CoreAgent.Application/Handlers/CellularNetwork/StartCellularNetworkCommandHandler.cs b/CoreAgent.Application/Handlers/CellularNetwork/StartCellularNetworkCommandHandler.cs index 9ad3022..403f520 100644 --- a/CoreAgent.Application/Handlers/CellularNetwork/StartCellularNetworkCommandHandler.cs +++ b/CoreAgent.Application/Handlers/CellularNetwork/StartCellularNetworkCommandHandler.cs @@ -10,7 +10,7 @@ namespace CoreAgent.Application.Handlers.CellularNetwork; /// /// 启动蜂窝网络命令处理器 /// -public class StartCellularNetworkCommandHandler : IRequestHandler> +public class StartCellularNetworkCommandHandler : IRequestHandler> { private readonly ICellularNetworkService _cellularNetworkService; private readonly ILogger _logger; @@ -23,7 +23,7 @@ public class StartCellularNetworkCommandHandler : IRequestHandler> Handle(StartCellularNetworkCommand request, CancellationToken cancellationToken) + public async Task> Handle(StartCellularNetworkCommand request, CancellationToken cancellationToken) { try { @@ -35,12 +35,12 @@ public class StartCellularNetworkCommandHandler : IRequestHandler.Ok(result, "蜂窝网络启动成功"); + return ApiActionResult.Ok(result.NetworkStatus, "蜂窝网络启动成功"); } else { _logger.LogWarning("蜂窝网络配置 {ConfigKey} 启动失败: {Error}", request.Key, result.ErrorMessage); - return ApiActionResult.Error( + return ApiActionResult.Error( result.ErrorMessage, "NETWORK_START_ERROR", System.Net.HttpStatusCode.BadRequest); @@ -49,7 +49,7 @@ public class StartCellularNetworkCommandHandler : IRequestHandler.Error( + return ApiActionResult.Error( $"启动蜂窝网络失败: {ex.Message}", "INTERNAL_ERROR", System.Net.HttpStatusCode.InternalServerError);