mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
[dart-gen] Fix nullable list item issue (#3192)
This commit is contained in:
parent
b028ed058d
commit
3a66fc038f
@ -60,7 +60,7 @@ class {{.Name}} {
|
|||||||
{{if isDirectType .Type.Name}}
|
{{if isDirectType .Type.Name}}
|
||||||
{{lowCamelCase .Name}}
|
{{lowCamelCase .Name}}
|
||||||
{{else if isClassListType .Type.Name}}
|
{{else if isClassListType .Type.Name}}
|
||||||
{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.map((i) => i.toJson())
|
{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.map((i) => i{{if isListItemsNullable .Type.Name}}?{{end}}.toJson())
|
||||||
{{else}}
|
{{else}}
|
||||||
{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.toJson()
|
{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.toJson()
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -74,6 +74,10 @@ func isClassListType(s string) bool {
|
|||||||
return strings.HasPrefix(s, "List<") && !isAtomicType(getCoreType(s))
|
return strings.HasPrefix(s, "List<") && !isAtomicType(getCoreType(s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isListItemsNullable(s string) bool {
|
||||||
|
return isListType(s) && isNullableType(getCoreType(s))
|
||||||
|
}
|
||||||
|
|
||||||
func isMapType(s string) bool {
|
func isMapType(s string) bool {
|
||||||
return strings.HasPrefix(s, "Map<")
|
return strings.HasPrefix(s, "Map<")
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ var funcMap = template.FuncMap{
|
|||||||
"isDirectType": isDirectType,
|
"isDirectType": isDirectType,
|
||||||
"isNumberType": isNumberType,
|
"isNumberType": isNumberType,
|
||||||
"isClassListType": isClassListType,
|
"isClassListType": isClassListType,
|
||||||
|
"isListItemsNullable": isListItemsNullable,
|
||||||
"isNullableType": isNullableType,
|
"isNullableType": isNullableType,
|
||||||
"appendNullCoalescing": appendNullCoalescing,
|
"appendNullCoalescing": appendNullCoalescing,
|
||||||
"appendDefaultEmptyValue": appendDefaultEmptyValue,
|
"appendDefaultEmptyValue": appendDefaultEmptyValue,
|
||||||
|
Loading…
Reference in New Issue
Block a user