2024-07-04 11:02:45 +05:00
|
|
|
using AsbCloudApp.Data;
|
2021-12-17 16:30:00 +05:00
|
|
|
using AsbCloudApp.Services;
|
2021-11-10 14:23:53 +05:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2021-12-17 16:30:00 +05:00
|
|
|
using System.Collections.Generic;
|
2021-11-10 14:23:53 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
namespace AsbCloudWebApi.Controllers;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Мониторинг запросов, ошибок, пользователей
|
|
|
|
/// </summary>
|
|
|
|
[Route("api/[controller]")]
|
|
|
|
[ApiController]
|
|
|
|
[Authorize]
|
|
|
|
public class RequestTrackerController : ControllerBase
|
2021-11-10 14:23:53 +05:00
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
private readonly IRequerstTrackerService service;
|
|
|
|
|
|
|
|
public RequestTrackerController(IRequerstTrackerService service)
|
|
|
|
{
|
|
|
|
this.service = service;
|
|
|
|
}
|
2023-05-19 16:51:41 +05:00
|
|
|
|
2022-06-16 17:37:10 +05:00
|
|
|
/// <summary>
|
2024-08-19 10:01:07 +05:00
|
|
|
/// Получить последние `take` запросов к серверу
|
2022-06-16 17:37:10 +05:00
|
|
|
/// </summary>
|
2024-08-19 10:01:07 +05:00
|
|
|
/// <param name="take">от 1 до 1000</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Permission]
|
|
|
|
public IActionResult GetAll(int take = 512)
|
2021-11-10 14:23:53 +05:00
|
|
|
{
|
2024-08-19 10:01:07 +05:00
|
|
|
var result = service.GetAll(take);
|
|
|
|
return Ok(result);
|
|
|
|
}
|
2021-11-10 14:23:53 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
/// <summary>
|
|
|
|
/// Получить последние `take` быстрых запросов к серверу
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="take">от 1 до 1000</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("fast")]
|
|
|
|
[Permission]
|
|
|
|
public IActionResult GetFast(int take = 512)
|
|
|
|
{
|
|
|
|
var result = service.GetFast(take);
|
|
|
|
return Ok(result);
|
|
|
|
}
|
2021-11-10 14:23:53 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
/// <summary>
|
|
|
|
/// Получить последние `take` медленных запросов к серверу
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="take">от 1 до 1000</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("slow")]
|
|
|
|
[Permission]
|
|
|
|
public IActionResult GetSlow(int take = 512)
|
|
|
|
{
|
|
|
|
var result = service.GetSlow(take);
|
|
|
|
return Ok(result);
|
|
|
|
}
|
2021-11-10 14:23:53 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
/// <summary>
|
|
|
|
/// Получить последние `take` ошибок при выполнении запросов
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="take">от 1 до 1000</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("error")]
|
|
|
|
[Permission]
|
|
|
|
public IActionResult GetError(int take = 512)
|
|
|
|
{
|
|
|
|
var result = service.GetError(take);
|
|
|
|
return Ok(result);
|
2021-11-10 14:23:53 +05:00
|
|
|
}
|
2023-05-19 16:51:41 +05:00
|
|
|
|
2024-08-19 10:01:07 +05:00
|
|
|
/// <summary>
|
|
|
|
/// Получить последних пользователей обращавшихся к серверу. Уникальность пользователя проверяется по логину и Ip.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="take">от 1 до 1000</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("users")]
|
|
|
|
[Permission]
|
|
|
|
[ProducesResponseType(typeof(IEnumerable<RequestLogUserDto>), (int)System.Net.HttpStatusCode.OK)]
|
|
|
|
public IActionResult GetUsersStat(int take = 512)
|
|
|
|
{
|
|
|
|
var result = service.GetUsersStat(take);
|
|
|
|
return Ok(result);
|
|
|
|
}
|
2021-11-10 14:23:53 +05:00
|
|
|
}
|