| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Web.Mvc;
- using Abp.Application.Services.Dto;
- using Abp.Auditing;
- using Abp.Authorization;
- using Abp.Domain.Repositories;
- using Abp.Runtime.Caching;
- using WePlatform.Authorization;
- using WePlatform.BaseSystem.AuditLog.Dto;
- using IwbZero.AppServiceBase;
- using IwbZero.Auditing;
- using IwbZero.Authorization.Base.SystemInfo;
- using IwbZero.ToolCommon.Lambda;
- using IwbZero.ToolCommon.StringModel;
- using WePlatform.Configuration;
- namespace WePlatform.BaseSystem.AuditLog
- {
- [AbpAuthorize, AuditLog("系统日志", "日志")]
- public class AuditLogsAppService : IwbAsyncCrudAppService<SysLog, SysLogDto, long, IwbPagedRequestDto>, IAuditLogsAppService
- {
- public AuditLogsAppService(ICacheManager cacheManager, IRepository<SysLog, long> repository) : base(repository)
- {
- CacheManager = cacheManager;
- }
- protected override string GetPermissionName { get; set; } = PermissionNames.PagesSystemMgLogMg;
- protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesSystemMgLogMg;
- //protected override string CreatePermissionName { get; set; } = PermissionNames.PagesSystemMgLogMgCreate;
- //protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesSystemMgLogMgUpdate;
- //protected override string DeletePermissionName { get; set; } = PermissionNames.PagesSystemMgLogMgDelete;
- #region GetSelectList
- [DisableAuditing, AbpAllowAnonymous]
- public List<SelectListItem> GetLogServiceSelectLists()
- {
- var sList = new List<SelectListItem>();
- var list = Repository.GetAll().Where(a => a.LogType != 0).GroupBy(a => a.ServiceName).Select(a => a.Key);
- foreach (var l in list)
- {
- sList.Add(new SelectListItem { Text = l, Value = l });
- }
- return sList;
- }
- [DisableAuditing, AbpAllowAnonymous]
- public string GetLogServiceSelectListStrs()
- {
- var options = "";
- var list = Repository.GetAll().Where(a => a.LogType != 0).GroupBy(a => a.ServiceName).Select(a => a.Key);
- foreach (var l in list)
- {
- options += $"<option value='{l}' >{l}</option>";
- }
- return options;
- }
- [DisableAuditing, AbpAllowAnonymous]
- public List<SelectListItem> GetLogMethodSelectLists(QueryMethodName input)
- {
- var sList = new List<SelectListItem>();
- var list = Repository.GetAll().Where(a =>
- a.LogType != 0 && (string.IsNullOrEmpty(input.ServiceName) || a.ServiceName == input.ServiceName)).GroupBy(a => a.MethodName).Select(a => a.Key);
- foreach (var l in list)
- {
- sList.Add(new SelectListItem { Text = l, Value = l });
- }
- return sList;
- }
- [DisableAuditing, AbpAllowAnonymous]
- public string GetLogMethodSelectListStrs(QueryMethodName input)
- {
- string options = "";
- var list = Repository.GetAll().Where(a =>
- a.LogType != 0 && (string.IsNullOrEmpty(input.ServiceName) || a.ServiceName == input.ServiceName)).GroupBy(a => a.MethodName).Select(a => a.Key);
- foreach (var l in list)
- {
- options += $"<option value='{l}' >{l}</option>";
- }
- return options;
- }
- #endregion
- [DisableAuditing]
- public override async Task<PagedResultDto<SysLogDto>> GetAll(IwbPagedRequestDto input)
- {
- CheckGetAllPermission();
- var query = CreateFilteredQuery(input).Where(a => a.LogType != 0);
- if (input.SearchList != null && input.SearchList.Count > 0)
- {
- List<LambdaObject> objList = new List<LambdaObject>();
- foreach (var o in input.SearchList)
- {
- if (o.KeyWords.IsEmpty())
- continue;
- object keyWords = o.KeyWords;
- objList.Add(new LambdaObject
- {
- FieldType = (LambdaFieldType)o.FieldType,
- FieldName = o.KeyField,
- FieldValue = keyWords,
- ExpType = (LambdaExpType)o.ExpType
- });
- }
- var exp = objList.GetExp<SysLog>();
- query = query.Where(exp);
- }
- var totalCount = await AsyncQueryableExecuter.CountAsync(query);
- query = query.OrderByDescending(a => a.Id);
- query = ApplyPaging(query, input);
- var entities = await AsyncQueryableExecuter.ToListAsync(query);
- var dtos = new PagedResultDto<SysLogDto>(
- totalCount,
- entities.Select(MapToEntityDto).ToList()
- );
- return dtos;
- }
- }
- }
|