|
@@ -169,6 +169,11 @@ func parseName(val reflect.Value) (res *Field, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func StructTypeName(val reflect.Value) string {
|
|
|
+ t := val.Type()
|
|
|
+ return t.PkgPath() + "." + t.Name()
|
|
|
+}
|
|
|
+
|
|
|
func fieldVal(val reflect.Value, fieldName string, files RequestFiles, names FieldList) (res reflect.Value, err IErrorArgs) {
|
|
|
switch val.Kind() {
|
|
|
case reflect.Ptr, reflect.Interface:
|
|
@@ -193,6 +198,11 @@ func fieldVal(val reflect.Value, fieldName string, files RequestFiles, names Fie
|
|
|
return reflect.ValueOf(rVal), nil
|
|
|
}
|
|
|
}
|
|
|
+ // check public fields exists
|
|
|
+ if val.NumField() == 0 {
|
|
|
+ res = reflect.ValueOf(fmt.Sprint(val.Interface()))
|
|
|
+ return
|
|
|
+ }
|
|
|
// parse struct public fields
|
|
|
if len(names) == 0 {
|
|
|
names = fieldsDefault(val.Type())
|
|
@@ -225,7 +235,13 @@ func fieldVal(val reflect.Value, fieldName string, files RequestFiles, names Fie
|
|
|
return false
|
|
|
}
|
|
|
if fVal.IsValid() {
|
|
|
- jm[name.Name] = fVal.Interface()
|
|
|
+ stn := StructTypeName(field)
|
|
|
+ con, check := fieldConverters[stn]
|
|
|
+ if check {
|
|
|
+ jm[name.Name] = con.Pack(field.Interface())
|
|
|
+ } else {
|
|
|
+ jm[name.Name] = fVal.Interface()
|
|
|
+ }
|
|
|
} else {
|
|
|
jm[name.Name] = nil
|
|
|
}
|
|
@@ -360,12 +376,3 @@ func OutFields(req IRequestIn, obj any, files RequestFiles, names FieldList) IRe
|
|
|
}
|
|
|
return req.OutSuccess(m, files)
|
|
|
}
|
|
|
-
|
|
|
-/*
|
|
|
-func OutFieldsReq(req IRequestIn, obj any, files RequestFiles, names FieldList) IRequestOut {
|
|
|
- if len(names) == 0 {
|
|
|
- names = req.Fields()
|
|
|
- }
|
|
|
- return OutFields(req, obj, files, names)
|
|
|
-}
|
|
|
-*/
|