1
hutongqing
2024-10-18 e2a05a6c91f1b94bef8ecea7de7bf149d7e77c89
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_Core/Utilities/ModelValidate.cs
@@ -32,6 +32,12 @@
            return SimpleValidate(propertyInfos, data);
        }
        /// <summary>
        /// éªŒè¯å®žä½“参数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        public static (bool, string, object?) ValidateModelData<T>(List<T> datas) where T : class, new()
        {
            Type modelType = typeof(T);
@@ -162,15 +168,19 @@
                                Type[] types = propertyInfo.PropertyType.GenericTypeArguments;
                                if (types.Length == 1)
                                {
                                    string str = value.Serialize();
                                    if (str == "[]")
                                    if (tempValue.ChangeType(property.PropertyType).ToString() == propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1].ChangeType(property.PropertyType).ToString())
                                    {
                                        return (false, $"【{property.Name}】属性的值为【{propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1]}】时【{propertyInfo.Name}】属性的值不可为空", data);
                                        string str = value.Serialize();
                                        if (str == "[]")
                                        {
                                            return (false, $"【{property.Name}】属性的值为【{propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1]}】时【{propertyInfo.Name}】属性的值不可为空", data);
                                        }
                                    }
                                }
                                else if (types.Length == 0)
                                {
                                    if (tempValue.ChangeType(property.PropertyType) != propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1].ChangeType(property.PropertyType) && value == null && string.IsNullOrEmpty(value.ToString()))
                                    if (tempValue.ChangeType(property.PropertyType).ToString() == propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1].ChangeType(property.PropertyType).ToString() && value == null && string.IsNullOrEmpty(value.ToString()))
                                    {
                                        return (false, $"【{property.Name}】属性的值为【{propertyAttribute.NotNullAndEmptyWithPropertyAndValue[1]}】时【{propertyInfo.Name}】属性的值不可为空", data);
                                    }