using Furion.DependencyInjection; using Furion.DynamicApiController; using Magic.Core.Entity; using Microsoft.AspNetCore.Mvc; using SqlSugar; using System; using System.Threading.Tasks; namespace Magic.Core.Service; /// /// 操作日志服务 /// [ApiDescriptionSettings(Name = "OpLog", Order = 100)] public class SysOpLogService : ISysOpLogService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _sysOpLogRep; // 操作日志表仓储 public SysOpLogService(SqlSugarRepository sysOpLogRep) { _sysOpLogRep = sysOpLogRep; } /// /// 分页查询操作日志 /// /// /// [HttpGet("/sysOpLog/page")] public async Task QueryOpLogPageList([FromQuery] OpLogInput input) { var opLogs = await _sysOpLogRep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name.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() .ToPagedListAsync(input.PageNo, input.PageSize); return opLogs.XnPagedResult(); } /// /// 清空操作日志 /// /// [HttpPost("/sysOpLog/delete")] public async Task ClearOpLog() { await _sysOpLogRep.DeleteAsync(m => true); } }