修改模型绑定逻辑
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
296ecfa9d2
commit
2bf47515e7
|
|
@ -102,33 +102,39 @@ namespace IRaCIS.Core.API
|
|||
{
|
||||
|
||||
|
||||
#region 前端针对 string 类型的变量,如果传递null 会报错必传
|
||||
|
||||
//// 会影响 string? 传递null 变为""
|
||||
|
||||
var isNullable1 = _memberInfo.CustomAttributes.Any(a => a.AttributeType.Name == "NullableAttribute");
|
||||
|
||||
|
||||
if (_memberInfo.PropertyType == typeof(string) && isNullable1 == false)
|
||||
if (_memberInfo.PropertyType == typeof(string))
|
||||
{
|
||||
//如果不处理 前段传递null string不会接收,说前段没传递会验证报错
|
||||
_memberInfo.SetValue(target, value == null ? string.Empty : value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_memberInfo.SetValue(target, value);
|
||||
|
||||
}
|
||||
|
||||
//if ()
|
||||
#endregion
|
||||
|
||||
#region 处理模型验证区分 string string?
|
||||
|
||||
//var isNullable1 = _memberInfo.CustomAttributes.Any(a => a.AttributeType.Name == "NullableAttribute");
|
||||
|
||||
////不影响 string? 传递null 变为""
|
||||
//if (_memberInfo.PropertyType == typeof(string) && isNullable1 == false)
|
||||
//{
|
||||
// //去掉前后空格
|
||||
// _memberInfo.SetValue(target, value == null ? string.Empty : value.ToString() == string.Empty ? value : value/*.ToString().Trim()*/);
|
||||
// //如果不处理 前段传递null string不会接收,说前段没传递会验证报错
|
||||
// _memberInfo.SetValue(target, value == null ? string.Empty : value);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
|
||||
// _memberInfo.SetValue(target, value);
|
||||
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue