|
|
@ -10,7 +10,7 @@ namespace CoreAgent.Application.Handlers.CellularNetwork; |
|
|
|
/// <summary>
|
|
|
|
/// 启动蜂窝网络命令处理器
|
|
|
|
/// </summary>
|
|
|
|
public class StartCellularNetworkCommandHandler : IRequestHandler<StartCellularNetworkCommand, ApiActionResult<CellularNetworkOperationResult>> |
|
|
|
public class StartCellularNetworkCommandHandler : IRequestHandler<StartCellularNetworkCommand, ApiActionResult<NetworkStatus>> |
|
|
|
{ |
|
|
|
private readonly ICellularNetworkService _cellularNetworkService; |
|
|
|
private readonly ILogger<StartCellularNetworkCommandHandler> _logger; |
|
|
@ -23,7 +23,7 @@ public class StartCellularNetworkCommandHandler : IRequestHandler<StartCellularN |
|
|
|
_logger = logger; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<ApiActionResult<CellularNetworkOperationResult>> Handle(StartCellularNetworkCommand request, CancellationToken cancellationToken) |
|
|
|
public async Task<ApiActionResult<NetworkStatus>> Handle(StartCellularNetworkCommand request, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
@ -35,12 +35,12 @@ public class StartCellularNetworkCommandHandler : IRequestHandler<StartCellularN |
|
|
|
if (result.IsSuccess) |
|
|
|
{ |
|
|
|
_logger.LogInformation("蜂窝网络配置 {ConfigKey} 启动成功", request.Key); |
|
|
|
return ApiActionResult<CellularNetworkOperationResult>.Ok(result, "蜂窝网络启动成功"); |
|
|
|
return ApiActionResult<NetworkStatus>.Ok(result.NetworkStatus, "蜂窝网络启动成功"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogWarning("蜂窝网络配置 {ConfigKey} 启动失败: {Error}", request.Key, result.ErrorMessage); |
|
|
|
return ApiActionResult<CellularNetworkOperationResult>.Error( |
|
|
|
return ApiActionResult<NetworkStatus>.Error( |
|
|
|
result.ErrorMessage, |
|
|
|
"NETWORK_START_ERROR", |
|
|
|
System.Net.HttpStatusCode.BadRequest); |
|
|
@ -49,7 +49,7 @@ public class StartCellularNetworkCommandHandler : IRequestHandler<StartCellularN |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
_logger.LogError(ex, "启动蜂窝网络配置 {ConfigKey} 失败", request.Key); |
|
|
|
return ApiActionResult<CellularNetworkOperationResult>.Error( |
|
|
|
return ApiActionResult<NetworkStatus>.Error( |
|
|
|
$"启动蜂窝网络失败: {ex.Message}", |
|
|
|
"INTERNAL_ERROR", |
|
|
|
System.Net.HttpStatusCode.InternalServerError); |
|
|
|