LEIYI 3 kuukautta sitten
vanhempi
commit
8f84c56156

+ 10 - 4
OASystem/OASystem.Api/Middlewares/RecordAPIOperationMiddleware.cs

@@ -13,6 +13,7 @@ using UAParser;
 using System.Collections.Generic;
 using XAct;
 using NPOI.SS.Formula.Functions;
+using QuzrtzJob.Factory;
 
 namespace OASystem.API.Middlewares
 {
@@ -25,8 +26,9 @@ namespace OASystem.API.Middlewares
         private readonly HttpClient _httpClient;
         private readonly IConfiguration _config;
         private readonly SqlSugarClient _sqlSugar;
+        private readonly ILogger<RecordAPIOperationMiddleware> _logger;
 
-        public RecordAPIOperationMiddleware(RequestDelegate next, IConfiguration config, HttpClient httpClient, SqlSugarClient sqlSugar)
+        public RecordAPIOperationMiddleware(RequestDelegate next, IConfiguration config, ILogger<RecordAPIOperationMiddleware> logger, HttpClient httpClient, SqlSugarClient sqlSugar)
         {
             _next = next;
             _httpClient = httpClient;
@@ -71,7 +73,6 @@ namespace OASystem.API.Middlewares
                         //用户Id处理
                         if (userId < 1)
                         {
-
                             if (apiLogAttribute.OperationEnum == OperationEnum.Login)
                             {
                                 var number = requestBodyJson?["number"].ToString();
@@ -136,16 +137,21 @@ namespace OASystem.API.Middlewares
                     //  id > 0 修改 
                     if (id > 0) updateBefData = await TableInfoToJson(apiLogAttribute.TableName, id);
                 }
-                string remoteIp = context.Connection.RemoteIpAddress?.ToString(), 
+                string remoteIp = string.Empty, 
                        location = string.Empty;
 
                 // 检查请求头中的X-Forwarded-For,以获取真实的客户端IP地址
                 if (context.Request.Headers.ContainsKey("X-Forwarded-For"))
                 {
                     remoteIp = context.Request.Headers["X-Forwarded-For"].ToString().Split(',', StringSplitOptions.RemoveEmptyEntries)[0];
+                    _logger.LogInformation($"IP:{remoteIp}");
+                }
+                else
+                {
+                    remoteIp = context.Connection.RemoteIpAddress?.ToString();
                 }
 
-                (remoteIp, location) = await GetIpInfo();
+                //(remoteIp, location) = await GetIpInfo();
                 //remoteIp = await GetExternalIp();
                 //location = await GetIpLocation(remoteIp);
 

+ 1 - 1
OASystem/OASystem.Domain/Dtos/CRM/NewClientDataQueryDto.cs

@@ -119,7 +119,7 @@ namespace OASystem.Domain.Dtos.CRM
         /// <summary>
         /// 护照日期
         /// </summary>
-        public string PassportDate { get; set; }
+        public DateTime PassportDate { get; set; }
 
         /// <summary>
         /// 职位

+ 16 - 14
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -1003,14 +1003,16 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 BirthdayStr = isParse ? Birthday.ToString("yyyy-MM-dd") : "";
             }
 
-            if (string.IsNullOrWhiteSpace(dto.PassportDate))
-            {
-                dto.PassportDate = string.Empty;
-            }
+            //if (string.IsNullOrWhiteSpace(dto.PassportDate))
+            //{
+            //    dto.PassportDate = string.Empty;
+            //}
 
             var newClientDataUnEncrypted = _mapper.Map<Crm_NewClientData>(dto);
             newClientDataUnEncrypted.Birthday = BirthdayStr;
-            
+            if (newClientDataUnEncrypted.PassportDate == DateTime.MinValue) newClientDataUnEncrypted.PassportDate = null;
+
+
             var newClientDataEncrypted = newClientDataUnEncrypted; 
             EncryptionProcessor.EncryptProperties(newClientDataEncrypted); //加密
 
@@ -1044,15 +1046,15 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 }
                 else if (dto.Status == 2)//修改
                 {
-                    DateTime? PassportDate = null;
-                    try
-                    {
-                        PassportDate = DateTime.Parse(dto.PassportDate);
-                    }
-                    catch (Exception)
-                    {
-                        PassportDate = null;
-                    }
+                    //DateTime? PassportDate = null;
+                    //try
+                    //{
+                    //    PassportDate = DateTime.Parse(dto.PassportDate);
+                    //}
+                    //catch (Exception)
+                    //{
+                    //    PassportDate = null;
+                    //}
 
                     var res = await _sqlSugar.Updateable(newClientDataEncrypted).IgnoreColumns(x => new { x.DeleteTime, x.DeleteUserId, x.CreateTime, x.CreateUserId }).ExecuteCommandAsync();