|
@@ -0,0 +1,78 @@
|
|
|
+using Microsoft.AspNetCore.Hosting;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.Extensions.Configuration;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.Filter;
|
|
|
+using TEAMModelOS.Models;
|
|
|
+using TEAMModelOS.SDK;
|
|
|
+using TEAMModelOS.SDK.Context.Constant;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
+using TEAMModelOS.SDK.Models.Table;
|
|
|
+
|
|
|
+namespace TEAMModelOS.Controllers
|
|
|
+{
|
|
|
+ [ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
|
+ [Route("log")]
|
|
|
+ [ApiController]
|
|
|
+ public class TablesLogController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly AzureCosmosFactory _azureCosmos;
|
|
|
+ //blob和table容器
|
|
|
+ private readonly AzureStorageFactory _azureStorage;
|
|
|
+ private readonly SnowflakeId _snowflakeId;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly Option _option;
|
|
|
+ private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
+ private readonly IWebHostEnvironment _environment;
|
|
|
+ private readonly IConfiguration _configuration;
|
|
|
+
|
|
|
+ public TablesLogController(IConfiguration configuration, CoreAPIHttpService coreAPIHttpServic, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage,SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option)
|
|
|
+ {
|
|
|
+ _azureCosmos = azureCosmos;
|
|
|
+ _snowflakeId = snowflakeId;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _option = option?.Value;
|
|
|
+ _environment = environment;
|
|
|
+ _coreAPIHttpService = coreAPIHttpServic;
|
|
|
+ _configuration = configuration;
|
|
|
+ _azureStorage = azureStorage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取日志信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "admin")]
|
|
|
+ [HttpPost("get-lists")]
|
|
|
+ public async Task<IActionResult> GetLog(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
|
|
|
+ jsonElement.TryGetProperty("startDate", out JsonElement startDate);
|
|
|
+ jsonElement.TryGetProperty("endDate", out JsonElement endDate);
|
|
|
+ var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOptLog");
|
|
|
+
|
|
|
+ StringBuilder tableSql = new();
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty($"{tmdId}"))
|
|
|
+ tableSql.Append($" tmdId eq {tmdId} ");
|
|
|
+ if (!string.IsNullOrEmpty($"{startDate}"))
|
|
|
+ tableSql.Append(!string.IsNullOrEmpty(tableSql.ToString()) ? $" and time ge {startDate}L " : $"time ge {startDate}L ");
|
|
|
+ if (!string.IsNullOrEmpty($"{endDate}"))
|
|
|
+ tableSql.Append(!string.IsNullOrEmpty(tableSql.ToString()) ? $" and time le {endDate}L " : $" time le {endDate}L ");
|
|
|
+
|
|
|
+ var logs = await table.QueryWhereString<OptLog>(tableSql.ToString());
|
|
|
+
|
|
|
+ return Ok(new { state = RespondCode.Ok, logs,cnt= logs.Count });
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|