From 090cdaf2e4bd523cd901840539f4c45e20ece1bd Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 14 May 2024 14:29:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E5=A2=9E=E5=8A=A0=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Triggers/UserLogTrigger.cs | 6 ++++-- IRaCIS.Core.Domain/Management/UserLog.cs | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Triggers/UserLogTrigger.cs b/IRaCIS.Core.Application/Triggers/UserLogTrigger.cs index da93ea09e..eb94e0e15 100644 --- a/IRaCIS.Core.Application/Triggers/UserLogTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/UserLogTrigger.cs @@ -23,6 +23,7 @@ namespace IRaCIS.Core.Application.Triggers //国家|区域|省份|城市|ISP 缺省的地域信息默认是0 //0|0|0|内网IP|内网IP + // 中国|0|湖北省|武汉市|电信 public async Task BeforeSave(ITriggerContext context, CancellationToken cancellationToken) { var userLog = context.Entity; @@ -30,9 +31,10 @@ namespace IRaCIS.Core.Application.Triggers if (context.ChangeType == ChangeType.Added) { - var dd = _searcher.Search(userLog.IP); + var ipinfo = _searcher.Search(userLog.IP); - _logger.LogWarning(dd); + userLog.IPRegion = string.Join('|', ipinfo.Split('|').TakeLast(3)); + } } diff --git a/IRaCIS.Core.Domain/Management/UserLog.cs b/IRaCIS.Core.Domain/Management/UserLog.cs index 6aeb2c909..631eb51d2 100644 --- a/IRaCIS.Core.Domain/Management/UserLog.cs +++ b/IRaCIS.Core.Domain/Management/UserLog.cs @@ -47,6 +47,8 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public User OptUser { get; set; } + public string IPRegion { get; set; } + } ///