Files

70 lines
2.3 KiB
C#
Raw Permalink Normal View History

using Microsoft.AspNetCore.Mvc;
using QYZH.InteractiveMagazine.IService;
using QYZH.InteractiveMagazine.Models.Common;
using QYZH.InteractiveMagazine.Models.Dto;
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
/// <summary>
/// 操作日志控制器
/// </summary>
[Route("api/[controller]")]
[ApiController]
public class OperationLogController : BaseController
{
private readonly IOperationLogService _operationLogService;
private readonly ILogger<OperationLogController> _logger;
public OperationLogController(IOperationLogService operationLogService, ILogger<OperationLogController> logger)
{
_operationLogService = operationLogService;
_logger = logger;
}
/// <summary>
/// 分页查询操作日志
/// </summary>
[HttpPost("list")]
public async Task<BaseResponse<PageListModel<OperationLogOutput>>> GetList([FromBody] OperationLogQueryInput input)
{
try
{
var result = await _operationLogService.GetListAsync(input);
return Success(result);
}
catch (BusinessException ex)
{
_logger.LogWarning(ex, "查询操作日志业务异常: {Message}", ex.Message);
return BaseResponse<PageListModel<OperationLogOutput>>.Fail(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "查询操作日志系统异常");
return BaseResponse<PageListModel<OperationLogOutput>>.Fail("查询操作日志失败,请稍后重试");
}
}
/// <summary>
/// 获取操作日志详情
/// </summary>
[HttpGet("{id}")]
public async Task<BaseResponse<OperationLogDetailOutput>> GetDetail(long id)
{
try
{
var result = await _operationLogService.GetDetailAsync(id);
return Success(result);
}
catch (BusinessException ex)
{
_logger.LogWarning(ex, "查询操作日志详情业务异常: {Message}", ex.Message);
return BaseResponse<OperationLogDetailOutput>.Fail(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "查询操作日志详情系统异常");
return BaseResponse<OperationLogDetailOutput>.Fail("查询操作日志详情失败,请稍后重试");
}
}
}