mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
[dart-gen] Fix lists containing atomic types (#3210)
This commit is contained in:
parent
1853428011
commit
c22bc1c8ea
@ -45,8 +45,10 @@ class {{.Name}} {
|
||||
return {{.Name}}(
|
||||
{{range .Members}}
|
||||
{{lowCamelCase .Name}}: {{appendNullCoalescing .}}
|
||||
{{if isDirectType .Type.Name}}
|
||||
{{if isAtomicType .Type.Name}}
|
||||
m['{{getPropertyFromMember .}}'] {{appendDefaultEmptyValue .Type.Name}}
|
||||
{{else if isAtomicListType .Type.Name}}
|
||||
m['{{getPropertyFromMember .}}']?.cast<{{getCoreType .Type.Name}}>() {{appendDefaultEmptyValue .Type.Name}}
|
||||
{{else if isClassListType .Type.Name}}
|
||||
((m['{{getPropertyFromMember .}}'] {{appendDefaultEmptyValue .Type.Name}}) as List<dynamic>).map((i) => {{getCoreType .Type.Name}}.fromJson(i)).toList()
|
||||
{{else}}
|
||||
|
@ -71,7 +71,11 @@ func isListType(s string) bool {
|
||||
}
|
||||
|
||||
func isClassListType(s string) bool {
|
||||
return strings.HasPrefix(s, "List<") && !isAtomicType(getCoreType(s))
|
||||
return isListType(s) && !isAtomicType(getCoreType(s))
|
||||
}
|
||||
|
||||
func isAtomicListType(s string) bool {
|
||||
return isListType(s) && isAtomicType(getCoreType(s))
|
||||
}
|
||||
|
||||
func isListItemsNullable(s string) bool {
|
||||
|
@ -6,8 +6,10 @@ var funcMap = template.FuncMap{
|
||||
"getBaseName": getBaseName,
|
||||
"getPropertyFromMember": getPropertyFromMember,
|
||||
"isDirectType": isDirectType,
|
||||
"isAtomicType": isAtomicType,
|
||||
"isNumberType": isNumberType,
|
||||
"isClassListType": isClassListType,
|
||||
"isAtomicListType": isAtomicListType,
|
||||
"isListItemsNullable": isListItemsNullable,
|
||||
"isNullableType": isNullableType,
|
||||
"appendNullCoalescing": appendNullCoalescing,
|
||||
|
Loading…
Reference in New Issue
Block a user