You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB
C#


using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Myshipping.Core.Entity;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System;
using System.Threading.Tasks;
namespace Myshipping.Core.Service;
/// <summary>
/// 操作日志服务
/// </summary>
[ApiDescriptionSettings(Name = "OpLog", Order = 100)]
public class SysOpLogService : ISysOpLogService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<SysLogOp> _sysOpLogRep; // 操作日志表仓储
public SysOpLogService(SqlSugarRepository<SysLogOp> sysOpLogRep)
{
_sysOpLogRep = sysOpLogRep;
}
/// <summary>
/// 分页查询操作日志
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/sysOpLog/page")]
public async Task<dynamic> QueryOpLogPageList([FromQuery] OpLogInput input)
{
var opLogs = await _sysOpLogRep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.Account), u => u.Account == input.Account.Trim())
.WhereIF(!string.IsNullOrWhiteSpace(input.Ip), u => u.Ip == input.Ip.Trim())
.WhereIF(!string.IsNullOrWhiteSpace(input.Url), u => u.Name.Contains(input.Url.Trim()))
.WhereIF(Enum.IsDefined(typeof(YesOrNot), input.Success), u => u.Success == input.Success)
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchBeginTime), u => u.OpTime >= DateTime.Parse(input.SearchBeginTime.Trim()) && u.OpTime <= DateTime.Parse(input.SearchEndTime.Trim()))
.OrderBy(u => u.Id, OrderByType.Desc)
.Select<OpLogOutput>()
.ToPagedListAsync(input.PageNo, input.PageSize);
return opLogs.XnPagedResult();
}
/// <summary>
/// 清空操作日志
/// </summary>
/// <returns></returns>
[HttpPost("/sysOpLog/delete")]
public async Task ClearOpLog()
{
await _sysOpLogRep.DeleteAsync(m => true);
}
}