类型解析增加MAP 与 SLICE

This commit is contained in:
白茶清欢 2023-02-02 12:30:25 +08:00
parent b22753fbbb
commit 9b3600643b

View File

@ -104,6 +104,10 @@ func (rt *ReflectType) fillFieldType(field *StructField, dataType reflect.Type)
field.Type = reflect.String
case reflect.Struct:
field.Type = reflect.Struct
case reflect.Slice:
field.Type = reflect.Slice
case reflect.Map:
field.Type = reflect.Map
case reflect.Ptr:
field.IsPtr = true
// 指针再次判断基础类型
@ -285,6 +289,28 @@ func (rv *ReflectValue) isZeroInputFieldValue(reflectValue reflect.Value, fieldI
}
return true
}
case reflect.Map:
if nil == inputVal {
return true
}
var m map[interface{}]interface{}
if err := util.ConvertAssign(&m, inputVal); nil == err {
if len(m) != 0 {
return false
}
return true
}
case reflect.Slice:
if nil == inputVal {
return true
}
var sl []interface{}
if err := util.ConvertAssign(&sl, inputVal); nil == err {
if len(sl) != 0 {
return false
}
return true
}
case reflect.Interface:
if inputVal == nil {
return true