mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
add map type (#3704)
This commit is contained in:
parent
72dd2736f5
commit
da67ea2300
@ -35,7 +35,7 @@ import '../data/{{with .Service}}{{.Name}}{{end}}.dart';
|
||||
/// {{.Name}}
|
||||
{{range $i, $Route := .Routes}}
|
||||
/// --{{.Path}}--
|
||||
///
|
||||
/// --{{.AtDoc}}--
|
||||
/// request: {{with .RequestType}}{{.Name}}{{end}}
|
||||
/// response: {{with .ResponseType}}{{.Name}}{{end}}
|
||||
Future {{normalizeHandlerName .Handler}}(
|
||||
|
@ -51,6 +51,8 @@ class {{.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 if isMapType .Type.Name}}
|
||||
{{if isNumberType .Type.Name}}num{{else}}{{.Type.Name}}{{end}}.from(m['{{getPropertyFromMember .}}'] ?? {})
|
||||
{{else}}
|
||||
{{.Type.Name}}.fromJson(m['{{getPropertyFromMember .}}']){{end}}
|
||||
,{{end}}
|
||||
@ -61,6 +63,8 @@ class {{.Name}} {
|
||||
'{{getPropertyFromMember .}}':
|
||||
{{if isDirectType .Type.Name}}
|
||||
{{lowCamelCase .Name}}
|
||||
{{else if isMapType .Type.Name}}
|
||||
{{lowCamelCase .Name}}
|
||||
{{else if isClassListType .Type.Name}}
|
||||
{{lowCamelCase .Name}}{{if isNullableType .Type.Name}}?{{end}}.map((i) => i{{if isListItemsNullable .Type.Name}}?{{end}}.toJson())
|
||||
{{else}}
|
||||
|
@ -20,6 +20,7 @@ var funcMap = template.FuncMap{
|
||||
"hasUrlPathParams": hasUrlPathParams,
|
||||
"extractPositionalParamsFromPath": extractPositionalParamsFromPath,
|
||||
"makeDartRequestUrlPath": makeDartRequestUrlPath,
|
||||
"isMapType": isMapType,
|
||||
}
|
||||
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user