|
|
|
using CoreAgent.Application.Commands.CellularNetwork;
|
|
|
|
using CoreAgent.Domain.Models.Network;
|
|
|
|
using MediatR;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
namespace CoreAgent.API.Controllers;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 蜂窝网络控制器
|
|
|
|
/// </summary>
|
|
|
|
[ApiVersion("1.0")]
|
|
|
|
public class CellularNetworkController : BaseApiController
|
|
|
|
{
|
|
|
|
private readonly ILogger<CellularNetworkController> _logger;
|
|
|
|
|
|
|
|
public CellularNetworkController(
|
|
|
|
IMediator mediator,
|
|
|
|
ILogger<CellularNetworkController> logger) : base(mediator, logger)
|
|
|
|
{
|
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 启动蜂窝网络
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="command">启动命令</param>
|
|
|
|
/// <returns>操作结果</returns>
|
|
|
|
[HttpPost("start")]
|
|
|
|
public async Task<IActionResult> Start([FromBody] StartCellularNetworkCommand command)
|
|
|
|
{
|
|
|
|
_logger.LogInformation("收到启动蜂窝网络请求: {ConfigKey}", command.Key);
|
|
|
|
return await HandleRequest<StartCellularNetworkCommand, CellularNetworkOperationResult>(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 停止蜂窝网络
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="command">停止命令</param>
|
|
|
|
/// <returns>操作结果</returns>
|
|
|
|
[HttpPost("stop")]
|
|
|
|
public async Task<IActionResult> Stop([FromBody] StopCellularNetworkCommand command)
|
|
|
|
{
|
|
|
|
_logger.LogInformation("收到停止蜂窝网络请求: {InterfaceName}", command.InterfaceName);
|
|
|
|
return await HandleRequest<StopCellularNetworkCommand, bool>(command);
|
|
|
|
}
|
|
|
|
}
|