日志增加区域
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-05-14 14:29:38 +08:00
parent 7c257f261c
commit 090cdaf2e4
2 changed files with 6 additions and 2 deletions

View File

@ -23,6 +23,7 @@ namespace IRaCIS.Core.Application.Triggers
//国家|区域|省份|城市|ISP 缺省的地域信息默认是0 //国家|区域|省份|城市|ISP 缺省的地域信息默认是0
//0|0|0|内网IP|内网IP //0|0|0|内网IP|内网IP
// 中国|0|湖北省|武汉市|电信
public async Task BeforeSave(ITriggerContext<UserLog> context, CancellationToken cancellationToken) public async Task BeforeSave(ITriggerContext<UserLog> context, CancellationToken cancellationToken)
{ {
var userLog = context.Entity; var userLog = context.Entity;
@ -30,9 +31,10 @@ namespace IRaCIS.Core.Application.Triggers
if (context.ChangeType == ChangeType.Added) 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));
} }
} }

View File

@ -47,6 +47,8 @@ namespace IRaCIS.Core.Domain.Models
[JsonIgnore] [JsonIgnore]
public User OptUser { get; set; } public User OptUser { get; set; }
public string IPRegion { get; set; }
} }
/// <summary> /// <summary>