52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
using Common;
|
|||
|
|
using Domain.Admin.Admin;
|
||
|
|
using Domain.Admin.Admin.Param;
|
||
|
|
using MongoRepository;
|
||
|
|
using MongoRepository.Config;
|
||
|
|
|
||
|
|
namespace AdminService.Admin
|
||
|
|
{
|
||
|
|
public class AdminOperationLogService : IAdminOperationLogService
|
||
|
|
{
|
||
|
|
private readonly IMongoBaseRepository<AdminOperationLog> _logRepo;
|
||
|
|
|
||
|
|
public AdminOperationLogService(IMongoBaseRepository<AdminOperationLog> logRepo)
|
||
|
|
{
|
||
|
|
_logRepo = logRepo;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<bool> AddLog(AdminOperationLog log)
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
await _logRepo.InsertOneAsync(log);
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
catch
|
||
|
|
{
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<(List<AdminOperationLog> list, long count)> QueryPage(OperationLogQueryParam param)
|
||
|
|
{
|
||
|
|
var result = await _logRepo.QueryPageAsync(
|
||
|
|
filterExpression: x =>
|
||
|
|
(string.IsNullOrEmpty(param.AdminId) || x.AdminId == param.AdminId) &&
|
||
|
|
(string.IsNullOrEmpty(param.AdminName) || (x.AdminName != null && x.AdminName.Contains(param.AdminName))) &&
|
||
|
|
(!param.Module.HasValue || x.Module == param.Module) &&
|
||
|
|
(!param.StartTime.HasValue || x.OperateTime >= param.StartTime) &&
|
||
|
|
(!param.EndTime.HasValue || x.OperateTime <= param.EndTime) &&
|
||
|
|
(!param.Status.HasValue || x.Status == param.Status) &&
|
||
|
|
x.HttpMethod != "GET",
|
||
|
|
orderExpression: x => x.OperateTime,
|
||
|
|
desc: true,
|
||
|
|
pageSize: param.PageSize,
|
||
|
|
pageIndex: param.PageIndex
|
||
|
|
);
|
||
|
|
|
||
|
|
return (result.list.ToList(), result.count);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|