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; /// /// 访问日志服务 /// [ApiDescriptionSettings(Name = "VisLog", Order = 100)] public class SysVisLogService : ISysVisLogService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _sysVisLogRep; // 访问日志表仓储 public SysVisLogService(SqlSugarRepository sysVisLogRep) { _sysVisLogRep = sysVisLogRep; } /// /// 分页查询访问日志 /// /// /// [HttpGet("/sysVisLog/page")] public async Task QueryVisLogPageList([FromQuery] VisLogInput input) { var visLogs = await _sysVisLogRep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name)) .WhereIF(input.VisType > 0, u => u.VisType == input.VisType) .WhereIF(input.Success != null && Enum.IsDefined(typeof(YesOrNot), input.Success), u => u.Success == input.Success) .WhereIF(!string.IsNullOrWhiteSpace(input.SearchBeginTime), u => u.VisTime >= DateTime.Parse(input.SearchBeginTime.Trim()) && u.VisTime <= DateTime.Parse(input.SearchEndTime.Trim())) .OrderBy(u => u.Id, OrderByType.Desc) .Select() .ToPagedListAsync(input.PageNo, input.PageSize); return visLogs.XnPagedResult(); } /// /// 清空访问日志 /// /// [HttpPost("/sysVisLog/delete")] public async Task ClearVisLog() { await _sysVisLogRep.DeleteAsync(m => true); } }