using LifePayment.Application.Contracts; using LifePayment.Domain; using LifePayment.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using System; using System.Threading.Tasks; using Volo.Abp.Application.Services; using Volo.Abp.Domain.Repositories; namespace LifePayment.Application { public class LogService : ApplicationService, ILogService { private readonly ILogger logger; private readonly IHttpContextAccessor httpContextAccessor; private readonly IRepository logFrontRepository; public LogService( ILogger logger, IHttpContextAccessor httpContextAccessor, IRepository logFrontRepository) { this.logger = logger; this.httpContextAccessor = httpContextAccessor; this.logFrontRepository = logFrontRepository; } /// /// 记录前端日志 /// /// /// public async Task LogFront(LogFrontInput input) { var log = new LogFrontRecord(); ObjectMapper.Map(input, log); if (log.UserId == null) { log.UserId = CurrentUser?.Id; } log.IpAddress = httpContextAccessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(); logger.LogInformation($"前端日志:{log.IpAddress}-{log.UserId}-{log.Url}-{log.RequestTime}-{log.Message}"); //await logFrontRepository.InsertAsync(log); } } }