sunpengfei
2025-06-13 67fc39c356d8b480b7005cb2fa4769a0a6c6cfb1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
 
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<LogService> logger;
        private readonly IHttpContextAccessor httpContextAccessor;
        private readonly IRepository<LogFrontRecord, Guid> logFrontRepository;
 
        public LogService(
            ILogger<LogService> logger,
            IHttpContextAccessor httpContextAccessor,
            IRepository<LogFrontRecord, Guid> logFrontRepository)
        {
            this.logger = logger;
            this.httpContextAccessor = httpContextAccessor;
            this.logFrontRepository = logFrontRepository;
        }
 
        /// <summary>
        /// 记录前端日志
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        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($"前端日志:{input.UserId}-{input.Url}-{input.RequestTime}-{input.Message}");
 
            //await logFrontRepository.InsertAsync(log);
        }
    }
}