You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
136 lines
5.5 KiB
136 lines
5.5 KiB
using CellularManagement.Application.Features.StackCoreIMSBindings.Commands.CreateStackCoreIMSBinding;
|
|
using CellularManagement.Application.Features.StackCoreIMSBindings.Commands.DeleteStackCoreIMSBinding;
|
|
using CellularManagement.Application.Features.StackCoreIMSBindings.Commands.UpdateStackCoreIMSBinding;
|
|
using CellularManagement.Application.Features.StackCoreIMSBindings.Queries.GetStackCoreIMSBindingById;
|
|
using CellularManagement.Application.Features.StackCoreIMSBindings.Queries.GetStackCoreIMSBindings;
|
|
using CellularManagement.Domain.Common;
|
|
using CellularManagement.Presentation.Abstractions;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace CellularManagement.Presentation.Controllers;
|
|
|
|
/// <summary>
|
|
/// 栈核心网IMS绑定管理控制器
|
|
/// </summary>
|
|
[Route("api/stackcoreimsbindings")]
|
|
[ApiController]
|
|
[Authorize]
|
|
public class StackCoreIMSBindingsController : ApiController
|
|
{
|
|
private readonly ILogger<StackCoreIMSBindingsController> _logger;
|
|
|
|
/// <summary>
|
|
/// 初始化栈核心网IMS绑定控制器
|
|
/// </summary>
|
|
public StackCoreIMSBindingsController(IMediator mediator, ILogger<StackCoreIMSBindingsController> logger)
|
|
: base(mediator)
|
|
{
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取栈核心网IMS绑定列表
|
|
/// </summary>
|
|
[HttpGet]
|
|
public async Task<OperationResult<GetStackCoreIMSBindingsResponse>> GetAll([FromQuery] GetStackCoreIMSBindingsQuery query)
|
|
{
|
|
_logger.LogInformation("开始获取栈核心网IMS绑定列表,页码: {PageNumber}, 每页数量: {PageSize}, 栈ID: {StackId}, 核心网ID: {CnId}, IMS ID: {ImsId}",
|
|
query.PageNumber, query.PageSize, query.StackId, query.CnId, query.ImsId);
|
|
|
|
var result = await mediator.Send(query);
|
|
if (!result.IsSuccess)
|
|
{
|
|
_logger.LogWarning("获取栈核心网IMS绑定列表失败: {Message}", result.ErrorMessages);
|
|
return result;
|
|
}
|
|
|
|
_logger.LogInformation("成功获取栈核心网IMS绑定列表,共 {Count} 条记录", result.Data?.TotalCount ?? 0);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取栈核心网IMS绑定详情
|
|
/// </summary>
|
|
[HttpGet("{id}")]
|
|
public async Task<OperationResult<GetStackCoreIMSBindingByIdResponse>> GetById(string id)
|
|
{
|
|
_logger.LogInformation("开始获取栈核心网IMS绑定详情,绑定ID: {StackCoreIMSBindingId}", id);
|
|
|
|
var result = await mediator.Send(new GetStackCoreIMSBindingByIdQuery { StackCoreIMSBindingId = id });
|
|
if (!result.IsSuccess)
|
|
{
|
|
_logger.LogWarning("获取栈核心网IMS绑定详情失败: {Message}", result.ErrorMessages);
|
|
return result;
|
|
}
|
|
|
|
_logger.LogInformation("成功获取栈核心网IMS绑定详情,绑定ID: {StackCoreIMSBindingId}", id);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建栈核心网IMS绑定
|
|
/// </summary>
|
|
[HttpPost]
|
|
public async Task<OperationResult<CreateStackCoreIMSBindingResponse>> Create([FromBody] CreateStackCoreIMSBindingCommand command)
|
|
{
|
|
_logger.LogInformation("开始创建栈核心网IMS绑定,栈ID: {StackId}, 索引: {Index}, 核心网ID: {CnId}, IMS ID: {ImsId}",
|
|
command.StackId, command.Index, command.CnId, command.ImsId);
|
|
|
|
var result = await mediator.Send(command);
|
|
if (!result.IsSuccess)
|
|
{
|
|
_logger.LogWarning("创建栈核心网IMS绑定失败: {Message}", result.ErrorMessages);
|
|
return result;
|
|
}
|
|
|
|
_logger.LogInformation("成功创建栈核心网IMS绑定,绑定ID: {StackCoreIMSBindingId}", result.Data?.StackCoreIMSBindingId);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新栈核心网IMS绑定
|
|
/// </summary>
|
|
[HttpPut("{id}")]
|
|
public async Task<OperationResult<UpdateStackCoreIMSBindingResponse>> Update(string id, [FromBody] UpdateStackCoreIMSBindingCommand command)
|
|
{
|
|
_logger.LogInformation("开始更新栈核心网IMS绑定,绑定ID: {StackCoreIMSBindingId}", id);
|
|
|
|
if (id != command.StackCoreIMSBindingId)
|
|
{
|
|
_logger.LogWarning("栈核心网IMS绑定ID不匹配,路径ID: {PathId}, 命令ID: {CommandId}", id, command.StackCoreIMSBindingId);
|
|
return OperationResult<UpdateStackCoreIMSBindingResponse>.CreateFailure("栈核心网IMS绑定ID不匹配");
|
|
}
|
|
|
|
var result = await mediator.Send(command);
|
|
if (!result.IsSuccess)
|
|
{
|
|
_logger.LogWarning("更新栈核心网IMS绑定失败: {Message}", result.ErrorMessages);
|
|
return result;
|
|
}
|
|
|
|
_logger.LogInformation("成功更新栈核心网IMS绑定,绑定ID: {StackCoreIMSBindingId}", id);
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除栈核心网IMS绑定
|
|
/// </summary>
|
|
[HttpDelete("{id}")]
|
|
public async Task<OperationResult<bool>> Delete(string id)
|
|
{
|
|
_logger.LogInformation("开始删除栈核心网IMS绑定,绑定ID: {StackCoreIMSBindingId}", id);
|
|
|
|
var result = await mediator.Send(new DeleteStackCoreIMSBindingCommand { StackCoreIMSBindingId = id });
|
|
if (!result.IsSuccess)
|
|
{
|
|
_logger.LogWarning("删除栈核心网IMS绑定失败: {Message}", result.ErrorMessages);
|
|
return result;
|
|
}
|
|
|
|
_logger.LogInformation("成功删除栈核心网IMS绑定,绑定ID: {StackCoreIMSBindingId}", id);
|
|
return result;
|
|
}
|
|
}
|