105 lines
3.2 KiB
C#
105 lines
3.2 KiB
C#
using System.Data.Entity;
|
|
using BITKit;
|
|
using IDIS;
|
|
using IDIS_Server_SIM.Data;
|
|
using IDIS_Server_SIM.Extensions;
|
|
using IDIS.Models;
|
|
using IDIS.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace IDIS_Server_SIM.Controllers;
|
|
|
|
[ApiController]
|
|
public class IDIS_QueryController:Controller
|
|
{
|
|
private readonly IDIS_Statistics_MySQLBased _statisticsService;
|
|
private readonly IDIS_Service_MySQLBased _service;
|
|
private readonly QueryService _queryService;
|
|
private readonly ILogger<IDIS_QueryController> _logger;
|
|
public IDIS_QueryController(IDIS_Statistics_MySQLBased statisticsService, ILogger<IDIS_QueryController> logger, QueryService queryService, IDIS_Service_MySQLBased service)
|
|
{
|
|
_statisticsService = statisticsService;
|
|
_logger = logger;
|
|
_queryService = queryService;
|
|
_service = service;
|
|
}
|
|
/// <summary>
|
|
/// 查询当日的解析的标识
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[Route("/api/query/today")]
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetTodayQuery()
|
|
{
|
|
var result = await _statisticsService.GetTodayQuery();
|
|
|
|
return new IDIS_Response(result).ToActionResult();
|
|
}
|
|
/// <summary>
|
|
/// 查询该标识的解析次数
|
|
/// </summary>
|
|
/// <param name="handle">标识码,标识码为null则是查询所有表示的解析次数</param>
|
|
/// <returns></returns>
|
|
[Route("/api/query/count")]
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetQueryCount(string handle=null)
|
|
{
|
|
if (string.IsNullOrEmpty(handle))
|
|
{
|
|
var result =await EntityFrameworkQueryableExtensions.ToArrayAsync(_statisticsService.queryCounter);
|
|
return new IDIS_Response(result).ToActionResult();
|
|
}
|
|
else
|
|
{
|
|
var result = await _statisticsService.GetQueryCount(handle);
|
|
return new IDIS_Response(result).ToActionResult();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 查询所有标识的解析次数综合
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route(("/api/query/all_count"))]
|
|
public async Task<IActionResult> GetQueryAllCount()
|
|
{
|
|
return new IDIS_Response(await _statisticsService.GetAllQueryCount()).ToActionResult();
|
|
}
|
|
/// <summary>
|
|
/// 获取所有标识的数量
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route(("/api/all_count"))]
|
|
public IActionResult GetAllCount()
|
|
{
|
|
var count = _service.handles.Count();
|
|
return new IDIS_Response(count).ToActionResult();
|
|
}
|
|
/// <summary>
|
|
/// 通过标签查询标识
|
|
/// </summary>
|
|
/// <param name="tags">标签,多个标签使用;分隔</param>
|
|
/// <param name="today">是否仅查询今日的标识</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route(("/api/query/by"))]
|
|
public async Task<IActionResult> GetQueryByTag(string tags,bool today=false)
|
|
{
|
|
return new IDIS_Response(await _queryService.QueryByTag(today,tags.Split(";"))).ToActionResult();
|
|
}
|
|
/// <summary>
|
|
/// 通过Tag获取解析记录
|
|
/// </summary>
|
|
/// <param name="tags">标签,多个标签使用;分隔</param>
|
|
/// <param name="today">是否仅查询今日的标识</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[Route(("/api/queryRecords/by"))]
|
|
public async Task<IActionResult> GetQueryRecordsByTag(string tags, bool today = false)
|
|
{
|
|
return new IDIS_Response(await _queryService.QueryRecordsByTag(today,tags.Split(";"))).ToActionResult();
|
|
}
|
|
} |