anstns 1 سال پیش
والد
کامیت
da67ea2300
3فایلهای تغییر یافته به همراه6 افزوده شده و 1 حذف شده
  1. 1 1
      tools/goctl/api/dartgen/genapi.go
  2. 4 0
      tools/goctl/api/dartgen/gendata.go
  3. 1 0
      tools/goctl/api/dartgen/vars.go

+ 1 - 1
tools/goctl/api/dartgen/genapi.go

@@ -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}}(

+ 4 - 0
tools/goctl/api/dartgen/gendata.go

@@ -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}}

+ 1 - 0
tools/goctl/api/dartgen/vars.go

@@ -20,6 +20,7 @@ var funcMap = template.FuncMap{
 	"hasUrlPathParams":                hasUrlPathParams,
 	"extractPositionalParamsFromPath": extractPositionalParamsFromPath,
 	"makeDartRequestUrlPath":          makeDartRequestUrlPath,
+	"isMapType":                       isMapType,
 }
 
 const (