using Furion.DependencyInjection; using Nirvana.Common; using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using YBDevice.Entity; namespace YBDevice.Application.Logger { /// /// 日志管理 /// public class NoticeLoggerService : INoticeLoggerService, ITransient { private readonly ISqlSugarRepository repository; private readonly SqlSugarClient dbClient; public NoticeLoggerService(ISqlSugarRepository sqlSugarRepository) { repository = sqlSugarRepository; dbClient = repository.Context; } /// /// 操作日志列表 /// /// /// public async Task> GetAuditListAsync(QueryParams param) { RefAsync totalnum = 0; var temquery = dbClient.Queryable(); if (param.queryParam != null && param.queryParam.Count > 0) { List conModels = new List(); param.queryParam.ForEach(x => { if (!string.IsNullOrEmpty(x.Value)) { conModels.Add(new ConditionalModel() { FieldName = x.Name, ConditionalType = (ConditionalType)x.Type, FieldValue = x.Value.ToStr() }); } }); if (conModels.Count > 0) { temquery = temquery.Where(conModels); } } var query = await temquery.OrderBy(x => x.CreatTime, OrderByType.Desc) .Select(x => new AuditListS2CDto { CreatTime = x.CreatTime, ColumnName = x.ColumnName, NewValue = x.NewValue, OldValue = x.OldValue, TableName = x.TableName, Title = x.Title, UserName = x.UserName }) .ToPageListAsync(param.offset, param.limit, totalnum); return new PageParms { page = param.offset, Items = query, totalnum = totalnum, limit = param.limit }; } /// /// 通知日志 /// /// /// public async Task> GetListAsync(QueryParams param) { RefAsync totalnum = 0; var temquery = dbClient.Queryable(); if (param.queryParam != null && param.queryParam.Count > 0) { List conModels = new List(); param.queryParam.ForEach(x => { if (!string.IsNullOrEmpty(x.Value)) { conModels.Add(new ConditionalModel() { FieldName = x.Name, ConditionalType = (ConditionalType)x.Type, FieldValue = x.Value.ToStr() }); } }); if (conModels.Count > 0) { temquery = temquery.Where(conModels); } } string sorts = string.Format("{0} {1}", param.sort, param.order); var query = await temquery.OrderBy(sorts) .Select(x => new YB_NoticeLogger { Id = x.Id, CreateTime = x.CreateTime, FromInfo = x.FromInfo, Info = x.Info, UA = x.UA, UserInfo = x.UserInfo }) .ToPageListAsync(param.offset, param.limit, totalnum); return new PageParms { page = param.offset, Items = query, totalnum = totalnum, limit = param.limit }; } } }