修复时间格式bug
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
0ef7fd85d4
commit
e6458e66df
|
|
@ -89,7 +89,9 @@ namespace IRaCIS.Core.API
|
||||||
{
|
{
|
||||||
if (DateTime.TryParse((string)reader.Value, out dateTime) == false)
|
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);
|
DateTime clientZoneTime = TimeZoneInfo.ConvertTime(nullableDateTime.Value, _clientTimeZone);
|
||||||
|
|
||||||
//writer.WriteValue(clientZoneTime);
|
|
||||||
|
|
||||||
writer.WriteValue(clientZoneTime.ToString(_dateFormat));
|
writer.WriteValue(clientZoneTime.ToString(_dateFormat));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue