fix 移动api日志位置
This commit is contained in:
@@ -208,13 +208,4 @@ public class DevicesController : ControllerBase
|
||||
return await _deviceService.GetRecentNumbersAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取api日志
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("logs")]
|
||||
public async Task<Pagination<ApiLogResponse>> GetLogsAsync([FromQuery]ApiLogRequest request)
|
||||
{
|
||||
return await _deviceService.GetLogsAsync(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Device.Request;
|
||||
|
||||
public class ApiLogRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志级别 LogLevel
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(LogLevel))]
|
||||
public LogLevel? Level { get; set; }
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Basic.Device.Response;
|
||||
|
||||
public class ApiLogResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间UTC
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Timestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产生时间
|
||||
/// </summary>
|
||||
public DateTime RaiseTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.Parse(Timestamp).ToLocalTime();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 级别
|
||||
/// </summary>
|
||||
public string Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Template { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息内容
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常内容
|
||||
/// </summary>
|
||||
public string Exception { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 属性
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Properties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public DateTime _TS { get; set; }
|
||||
}
|
||||
@@ -24,6 +24,4 @@ public interface IDeviceService : IScopeDependency
|
||||
|
||||
Task<List<RecentNumberResponse>> GetRecentNumbersAsync();
|
||||
|
||||
Task<Pagination<ApiLogResponse>> GetLogsAsync(ApiLogRequest request);
|
||||
|
||||
}
|
||||
|
||||
@@ -405,15 +405,5 @@ public class DeviceService : IDeviceService
|
||||
return list;
|
||||
}
|
||||
|
||||
public async Task<Pagination<ApiLogResponse>> GetLogsAsync(ApiLogRequest request)
|
||||
{
|
||||
var logs = await _dbContext.ChangeDb("log").Queryable<ApiLogEntity>()
|
||||
.WhereIF(request.Search.IsPresent(), x => x.Message.Contains(request.Search))
|
||||
.WhereIF(request.Level.HasValue, x => x.Level == request.Level)
|
||||
.Select<ApiLogResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return logs;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -388,6 +388,7 @@ public class BalanceService : IBalanceService
|
||||
obj.LunchNumberOfPeople = first.Where(x => x.BusinessShiftCode.ToString() == shiftCodeDict["Lunch"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = first.Where(x => x.BusinessShiftCode.ToString() == shiftCodeDict["Dinner"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = first.Where(x => x.BusinessShiftCode.ToString() == shiftCodeDict["LateNight"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.TotalNumberOfPeople = obj.BreakfastNumberOfPeople + obj.LunchNumberOfPeople + obj.DinnerNumberOfPeople + obj.LateNightNumberOfPeople;
|
||||
lst.Add(obj);
|
||||
}
|
||||
// 分页操作
|
||||
|
||||
36
Src/Dlhis.Common/ApiLog/ApiLogServiceController.cs
Normal file
36
Src/Dlhis.Common/ApiLog/ApiLogServiceController.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Dlhis.Common.Request;
|
||||
using Dlhis.Common.Response;
|
||||
using Dlhis.Common.Services.Implements;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Common.ApiLog
|
||||
{
|
||||
/// <summary>
|
||||
/// api日志控制器
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ApiLogServiceController : ControllerBase
|
||||
{
|
||||
private readonly IApiLogService _apiLogService;
|
||||
|
||||
public ApiLogServiceController(IApiLogService apiLogService)
|
||||
{
|
||||
_apiLogService = apiLogService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取api日志
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("logs")]
|
||||
public async Task<Pagination<ApiLogResponse>> GetLogsAsync([FromQuery] ApiLogRequest request)
|
||||
{
|
||||
return await _apiLogService.GetLogsAsync(request);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Startup;
|
||||
|
||||
class Program
|
||||
@@ -13,6 +14,6 @@ public class Startup : DefaultStartup
|
||||
{
|
||||
public Startup(IConfiguration configuration) : base(configuration)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
14
Src/Dlhis.Common/Request/ApiLogRequest.cs
Normal file
14
Src/Dlhis.Common/Request/ApiLogRequest.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Common.Request
|
||||
{
|
||||
public class ApiLogRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志级别 LogLevel
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(LogLevel))]
|
||||
public LogLevel? Level { get; set; }
|
||||
}
|
||||
}
|
||||
57
Src/Dlhis.Common/Response/ApiLogResponse.cs
Normal file
57
Src/Dlhis.Common/Response/ApiLogResponse.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Common.Response
|
||||
{
|
||||
public class ApiLogResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 时间UTC
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Timestamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产生时间
|
||||
/// </summary>
|
||||
public DateTime RaiseTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.Parse(Timestamp).ToLocalTime();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 级别
|
||||
/// </summary>
|
||||
public string Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模板
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Template { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消息内容
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 异常内容
|
||||
/// </summary>
|
||||
public string Exception { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 属性
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Properties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public DateTime _TS { get; set; }
|
||||
}
|
||||
}
|
||||
32
Src/Dlhis.Common/Services/ApiLogService.cs
Normal file
32
Src/Dlhis.Common/Services/ApiLogService.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Dlhis.Common.Request;
|
||||
using Dlhis.Common.Response;
|
||||
using Dlhis.Common.Services.Implements;
|
||||
using Dlhis.Entity.Common;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
|
||||
namespace Dlhis.Common.Services
|
||||
{
|
||||
public class ApiLogService : IApiLogService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public ApiLogService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<Pagination<ApiLogResponse>> GetLogsAsync(ApiLogRequest request)
|
||||
{
|
||||
var logs = await _dbContext.ChangeDb("log").Queryable<ApiLogEntity>()
|
||||
.WhereIF(request.Search.IsPresent(), x => x.Message.Contains(request.Search))
|
||||
.WhereIF(request.Level.HasValue, x => x.Level == request.Level)
|
||||
.Select<ApiLogResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return logs;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Src/Dlhis.Common/Services/Implements/IApiLogService.cs
Normal file
11
Src/Dlhis.Common/Services/Implements/IApiLogService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Dlhis.Common.Request;
|
||||
using Dlhis.Common.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Common.Services.Implements
|
||||
{
|
||||
public interface IApiLogService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<ApiLogResponse>> GetLogsAsync(ApiLogRequest request);
|
||||
}
|
||||
}
|
||||
48
Src/Dlhis.Common/SqlSugarPack.cs
Normal file
48
Src/Dlhis.Common/SqlSugarPack.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Common;
|
||||
|
||||
public class SqlSugarPack : BaseAppPack
|
||||
{
|
||||
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddSqlSugar(sp =>
|
||||
{
|
||||
var configuration = sp.GetService<IConfiguration>();
|
||||
return new List<ConnectionConfig>
|
||||
{
|
||||
new ConnectionConfig
|
||||
{
|
||||
ConfigId = "face",
|
||||
ConnectionString = configuration.GetSection("SqlSugarOptions:FaceConnectionString").Value,
|
||||
DbType = DbType.MySql,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
MoreSettings = new ConnMoreSettings
|
||||
{
|
||||
DisableNvarchar = true,
|
||||
}
|
||||
},
|
||||
new ConnectionConfig
|
||||
{
|
||||
ConfigId = "log",
|
||||
ConnectionString = configuration.GetSection("SqlSugarOptions:LogConnectionString").Value,
|
||||
DbType = DbType.MySql,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
MoreSettings = new ConnMoreSettings
|
||||
{
|
||||
DisableNvarchar = true,
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,8 @@
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
"FaceConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=face;charset=utf8mb4;",
|
||||
"LogConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=log;charset=utf8mb4;",
|
||||
"Timeout": 30,
|
||||
"SlowSqlTime": 1,
|
||||
"EnableSqlLog": false
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Dlhis.Entity.Basic.Entity;
|
||||
namespace Dlhis.Entity.Common;
|
||||
|
||||
/// <summary>
|
||||
/// api日志表
|
||||
Reference in New Issue
Block a user