init commit
This commit is contained in:
95
20220330_Vote/Ewide.Core/Service/Log/Dto/OpLogInput.cs
Normal file
95
20220330_Vote/Ewide.Core/Service/Log/Dto/OpLogInput.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求日志参数
|
||||
/// </summary>
|
||||
public class OpLogInput : PageInputBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作类型(0其他 1增加 2删除 3编辑)(见LogAnnotionOpTypeEnum)
|
||||
/// </summary>
|
||||
public int? OpType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否执行成功(Y-是,N-否)
|
||||
/// </summary>
|
||||
public bool? Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 具体消息
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ip
|
||||
/// </summary>
|
||||
public string Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// </summary>
|
||||
public string Location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 浏览器
|
||||
/// </summary>
|
||||
public string Browser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作系统
|
||||
/// </summary>
|
||||
public string Os { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求地址
|
||||
/// </summary>
|
||||
public string Url { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类名称
|
||||
/// </summary>
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 方法名称
|
||||
/// </summary>
|
||||
public string MethodName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求方式(GET POST PUT DELETE)
|
||||
/// </summary>
|
||||
public string ReqMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求参数
|
||||
/// </summary>
|
||||
public string Param { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回结果
|
||||
/// </summary>
|
||||
public string Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 耗时(毫秒)
|
||||
/// </summary>
|
||||
public long ElapsedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
/// </summary>
|
||||
public DateTime OpTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
public string Account { get; set; }
|
||||
}
|
||||
}
|
||||
10
20220330_Vote/Ewide.Core/Service/Log/Dto/OpLogOutput.cs
Normal file
10
20220330_Vote/Ewide.Core/Service/Log/Dto/OpLogOutput.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 请求日志参数
|
||||
/// </summary>
|
||||
public class OpLogOutput : OpLogInput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
60
20220330_Vote/Ewide.Core/Service/Log/Dto/VisLogInput.cs
Normal file
60
20220330_Vote/Ewide.Core/Service/Log/Dto/VisLogInput.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 访问日志参数
|
||||
/// </summary>
|
||||
public class VisLogInput : PageInputBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否执行成功(Y-是,N-否)
|
||||
/// </summary>
|
||||
public bool? Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 具体消息
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// IP
|
||||
/// </summary>
|
||||
public string Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 地址
|
||||
/// </summary>
|
||||
public string Location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 浏览器
|
||||
/// </summary>
|
||||
public string Browser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作系统
|
||||
/// </summary>
|
||||
public string Os { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问类型(字典 1登入 2登出)
|
||||
/// </summary>
|
||||
public int? VisType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问时间
|
||||
/// </summary>
|
||||
public DateTime VisTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问人
|
||||
/// </summary>
|
||||
public string Account { get; set; }
|
||||
}
|
||||
}
|
||||
10
20220330_Vote/Ewide.Core/Service/Log/Dto/VisLogOutput.cs
Normal file
10
20220330_Vote/Ewide.Core/Service/Log/Dto/VisLogOutput.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 访问日志参数
|
||||
/// </summary>
|
||||
public class VisLogOutput : VisLogInput
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
11
20220330_Vote/Ewide.Core/Service/Log/ISysOpLogService.cs
Normal file
11
20220330_Vote/Ewide.Core/Service/Log/ISysOpLogService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
public interface ISysOpLogService
|
||||
{
|
||||
Task ClearOpLog();
|
||||
Task<dynamic> QueryOpLogPageList([FromQuery] OpLogInput input);
|
||||
}
|
||||
}
|
||||
11
20220330_Vote/Ewide.Core/Service/Log/ISysVisLogService.cs
Normal file
11
20220330_Vote/Ewide.Core/Service/Log/ISysVisLogService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
public interface ISysVisLogService
|
||||
{
|
||||
Task ClearVisLog();
|
||||
Task<dynamic> QueryVisLogPageList([FromQuery] VisLogInput input);
|
||||
}
|
||||
}
|
||||
63
20220330_Vote/Ewide.Core/Service/Log/SysOpLogService.cs
Normal file
63
20220330_Vote/Ewide.Core/Service/Log/SysOpLogService.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Dapper;
|
||||
using Ewide.Core.Extension;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DatabaseAccessor.Extensions;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Dynamic.Core;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作日志服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Name = "OpLog", Order = 100)]
|
||||
public class SysOpLogService : ISysOpLogService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly IRepository<SysLogOp> _sysOpLogRep; // 操作日志表仓储
|
||||
private readonly IDapperRepository<SysLogOp> _dapperRepository;
|
||||
|
||||
public SysOpLogService(IRepository<SysLogOp> sysOpLogRep, IDapperRepository<SysLogOp> dapperRepository)
|
||||
{
|
||||
_sysOpLogRep = sysOpLogRep;
|
||||
_dapperRepository = dapperRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询操作日志
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/sysOpLog/page")]
|
||||
public async Task<dynamic> QueryOpLogPageList([FromBody] OpLogInput input)
|
||||
{
|
||||
var name = !string.IsNullOrEmpty(input.Name?.Trim());
|
||||
var success = input.Success.HasValue;
|
||||
var searchBeginTime = !string.IsNullOrEmpty(input.SearchBeginTime?.Trim());
|
||||
var opLogs = await _sysOpLogRep.DetachedEntities
|
||||
.Where((name, u => EF.Functions.Like(u.Name, $"%{input.Name.Trim()}%")))
|
||||
.Where(input.OpType > 0, u => u.OpType == input.OpType)
|
||||
.Where(success, u => u.Success == input.Success.Value)
|
||||
.Where(searchBeginTime, u => u.OpTime >= DateTime.Parse(input.SearchBeginTime.Trim()) &&
|
||||
u.OpTime <= DateTime.Parse(input.SearchEndTime.Trim()))
|
||||
.ToPageData<SysLogOp, OpLogOutput>(input);
|
||||
return PageDataResult<OpLogOutput>.PageResult(opLogs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空操作日志
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/sysOpLog/delete")]
|
||||
public async Task ClearOpLog()
|
||||
{
|
||||
await _dapperRepository.ExecuteAsync("DELETE FROM sys_log_op");
|
||||
}
|
||||
}
|
||||
}
|
||||
63
20220330_Vote/Ewide.Core/Service/Log/SysVisLogService.cs
Normal file
63
20220330_Vote/Ewide.Core/Service/Log/SysVisLogService.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Ewide.Core.Extension;
|
||||
using Furion.DatabaseAccessor;
|
||||
using Furion.DatabaseAccessor.Extensions;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DynamicApiController;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ewide.Core.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 访问日志服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Name = "VisLog", Order = 100)]
|
||||
public class SysVisLogService : ISysVisLogService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly IRepository<SysLogVis> _sysVisLogRep; // 访问日志表仓储
|
||||
|
||||
public SysVisLogService(IRepository<SysLogVis> sysVisLogRep)
|
||||
{
|
||||
_sysVisLogRep = sysVisLogRep;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询访问日志
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/sysVisLog/page")]
|
||||
public async Task<dynamic> QueryVisLogPageList([FromBody] VisLogInput input)
|
||||
{
|
||||
var name = !string.IsNullOrEmpty(input.Name?.Trim());
|
||||
var success = input.Success.HasValue;
|
||||
var searchBeginTime = !string.IsNullOrEmpty(input.SearchBeginTime?.Trim());
|
||||
var visLogs = await _sysVisLogRep.DetachedEntities
|
||||
.Where((name, u => EF.Functions.Like(u.Name, $"%{input.Name.Trim()}%")))
|
||||
.Where(input.VisType > 0, u => u.VisType == input.VisType)
|
||||
.Where(success, u => u.Success == input.Success.Value)
|
||||
.Where(searchBeginTime, u => u.VisTime >= DateTime.Parse(input.SearchBeginTime.Trim()) &&
|
||||
u.VisTime <= DateTime.Parse(input.SearchEndTime.Trim()))
|
||||
.ToPageData<SysLogVis, VisLogOutput>(input);
|
||||
return PageDataResult<VisLogOutput>.PageResult(visLogs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空访问日志
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("/sysVisLog/delete")]
|
||||
public async Task ClearVisLog()
|
||||
{
|
||||
var visLogs = await _sysVisLogRep.Entities.ToListAsync();
|
||||
visLogs.ForEach(u =>
|
||||
{
|
||||
u.Delete();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user