You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
5.6 KiB
118 lines
5.6 KiB
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Wood.Data.Repository;
|
|
using Wood.Entity;
|
|
using Wood.Entity.SystemManage;
|
|
using Wood.Service.SystemManage.Dto;
|
|
using Wood.Service.SystemManage.Param;
|
|
|
|
namespace Wood.Service.SystemManage
|
|
{
|
|
/// <summary>
|
|
/// 日志信息
|
|
/// </summary>
|
|
public class LogService : ApiService
|
|
{
|
|
private readonly SqlSugarRepository<LogLoginEntity> _logLoginRepository;
|
|
private readonly SqlSugarRepository<LogJobEntity> _logJobRepository;
|
|
private readonly SqlSugarRepository<LogEventEntity> _logEventRepository;
|
|
private readonly SqlSugarRepository<LogExceptionEntity> _logExceptionRepository;
|
|
private readonly SqlSugarRepository<LogOperationEntity> _logOperationRepository;
|
|
private readonly SqlSugarRepository<LogDiffEntity> _logDiffRepository;
|
|
|
|
public LogService(SqlSugarRepository<LogLoginEntity> logLoginRepository, SqlSugarRepository<LogJobEntity> logJobRepository, SqlSugarRepository<LogEventEntity> logEventRepository, SqlSugarRepository<LogExceptionEntity> logExceptionRepository, SqlSugarRepository<LogDiffEntity> logDiffRepository, SqlSugarRepository<LogOperationEntity> logOperationRepository)
|
|
{
|
|
_logLoginRepository = logLoginRepository;
|
|
_logJobRepository = logJobRepository;
|
|
_logEventRepository = logEventRepository;
|
|
_logExceptionRepository = logExceptionRepository;
|
|
_logDiffRepository = logDiffRepository;
|
|
_logOperationRepository = logOperationRepository;
|
|
}
|
|
/// <summary>
|
|
/// 登录日志
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <returns></returns>
|
|
public async Task<TDataPaged<LogLoginDto>> PagedLogin(LogLoginParam param)
|
|
{
|
|
return await _logLoginRepository.AsQueryable()
|
|
.Where(it => it.CreateTime >= param.StartTime && it.CreateTime <= param.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(param.UserName), it => it.Account == param.UserName!)
|
|
.Select(it => new LogLoginDto()
|
|
{
|
|
Id = it.Id.SelectAll()
|
|
})
|
|
.ToPagedListAsync(param);
|
|
}
|
|
/// <summary>
|
|
/// job日志
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <returns></returns>
|
|
public async Task<TDataPaged<LogJobEntity>> PagedJob(LogJobParam param)
|
|
{
|
|
return await _logJobRepository.AsQueryable()
|
|
.Where(it => it.CreateTime >= param.StartTime && it.CreateTime <= param.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(param.JobId), it => it.JobId == param.JobId!)
|
|
.ToPagedListAsync(param);
|
|
}
|
|
/// <summary>
|
|
/// 事件日志
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <returns></returns>
|
|
public async Task<TDataPaged<LogEventEntity>> PagedEvent(LogEventParam param)
|
|
{
|
|
return await _logEventRepository.AsQueryable()
|
|
.Where(it => it.CreateTime >= param.StartTime && it.CreateTime <= param.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(param.EventName), it => it.EventName == param.EventName!)
|
|
.ToPagedListAsync(param);
|
|
}
|
|
/// <summary>
|
|
/// 错误日志
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <returns></returns>
|
|
public async Task<TDataPaged<LogExceptionEntity>> PagedException(LogExceptionParam param)
|
|
{
|
|
return await _logExceptionRepository.AsQueryable()
|
|
.Where(it => it.CreateTime >= param.StartTime && it.CreateTime <= param.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(param.ControllerName), it => it.ControllerName == param.ControllerName!)
|
|
.WhereIF(!string.IsNullOrEmpty(param.RequestUrl), it => it.RequestUrl == param.RequestUrl!)
|
|
.WhereIF(!string.IsNullOrEmpty(param.Source), it => it.Source == param.Source!)
|
|
.WhereIF(!string.IsNullOrEmpty(param.ActionName), it => it.ActionName == param.ActionName!)
|
|
.ToPagedListAsync(param);
|
|
}
|
|
/// <summary>
|
|
/// 操作日志
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <returns></returns>
|
|
public async Task<TDataPaged<LogOperationEntity>> PagedOperation(LogOperationParam param)
|
|
{
|
|
return await _logOperationRepository.AsQueryable()
|
|
.Where(it => it.CreateTime >= param.StartTime && it.CreateTime <= param.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(param.ControllerName), it => it.ControllerName == param.ControllerName!)
|
|
.WhereIF(!string.IsNullOrEmpty(param.ActionName), it => it.ActionName == param.ActionName!)
|
|
.WhereIF(!string.IsNullOrEmpty(param.RequestUrl), it => it.RequestUrl == param.RequestUrl!)
|
|
.ToPagedListAsync(param);
|
|
}
|
|
/// <summary>
|
|
/// 差异日志
|
|
/// </summary>
|
|
/// <param name="param"></param>
|
|
/// <returns></returns>
|
|
public async Task<TDataPaged<LogDiffEntity>> PagedDiff(LogDiffParam param)
|
|
{
|
|
return await _logDiffRepository.AsQueryable()
|
|
.Where(it => it.CreateTime >= param.StartTime && it.CreateTime <= param.EndTime)
|
|
.WhereIF(!string.IsNullOrEmpty(param.TableName), it => it.Tables!.Contains(param.TableName!))
|
|
.ToPagedListAsync(param);
|
|
}
|
|
}
|
|
}
|
|
|