From e6458e66dffe0fa78ad0d27c9e8d9136f03502dc Mon Sep 17 00:00:00 2001 From: hang <87227557@qq.com> Date: Mon, 19 Jan 2026 20:52:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E6=A0=BC?= =?UTF-8?q?=E5=BC=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NewtonsoftJson/JSONTimeZoneConverter.cs | 5 +-- .../LegacyController/ModelActionFilter .cs | 35 ------------------- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs index 9b289e8a4..87fda8456 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/NewtonsoftJson/JSONTimeZoneConverter.cs @@ -89,7 +89,9 @@ namespace IRaCIS.Core.API { if (DateTime.TryParse((string)reader.Value, out dateTime) == false) { - return null; + + throw new JsonSerializationException($"Could not convert string to DateTime: {reader.Value} Path {reader.Path}"); + //return null; } } @@ -113,7 +115,6 @@ namespace IRaCIS.Core.API //第一个参数默认使用系统本地时区 也就是应用服务器的时区 DateTime clientZoneTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone); - //writer.WriteValue(clientZoneTime); writer.WriteValue(clientZoneTime.ToString(_dateFormat)); } diff --git a/IRaCIS.Core.Application/BusinessFilter/LegacyController/ModelActionFilter .cs b/IRaCIS.Core.Application/BusinessFilter/LegacyController/ModelActionFilter .cs index 7d7c885a3..ee1d392cf 100644 --- a/IRaCIS.Core.Application/BusinessFilter/LegacyController/ModelActionFilter .cs +++ b/IRaCIS.Core.Application/BusinessFilter/LegacyController/ModelActionFilter .cs @@ -36,38 +36,3 @@ public class ModelActionFilter(IStringLocalizer _localizer) : ActionFilterAttrib - -public class SpecificNullableBinderProvider : IModelBinderProvider -{ - public IModelBinder? GetBinder(ModelBinderProviderContext context) - { - var type = context.Metadata.ModelType; - - // 只处理 Guid? 和 int? - if (type == typeof(Guid?) || type == typeof(int?)) - { - return new SpecificNullableBinder(); - } - - return null; - } -} - -public class SpecificNullableBinder : IModelBinder -{ - public Task BindModelAsync(ModelBindingContext context) - { - var value = context.ValueProvider.GetValue(context.ModelName).FirstValue; - - if (string.IsNullOrWhiteSpace(value)) - { - context.Result = ModelBindingResult.Success(null); - } - else - { - context.Result = ModelBindingResult.Success(value); - } - - return Task.CompletedTask; - } -} \ No newline at end of file