diff --git a/tools/goctl/api/gogen/genlogic.go b/tools/goctl/api/gogen/genlogic.go index 9aa75ea4..e6284487 100644 --- a/tools/goctl/api/gogen/genlogic.go +++ b/tools/goctl/api/gogen/genlogic.go @@ -57,6 +57,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error { if !ok { return fmt.Errorf("missing handler annotation for %q", route.Path) } + handler = strings.TrimSuffix(handler, "handler") handler = strings.TrimSuffix(handler, "Handler") filename := strings.ToLower(handler) @@ -65,6 +66,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error { if err != nil { return err } + if !created { return nil } @@ -74,11 +76,11 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error { if err != nil { return err } - imports := genLogicImports(route, parentPkg) - responseString := "" - returnString := "" - requestString := "" + imports := genLogicImports(route, parentPkg) + var responseString string + var returnString string + var requestString string if len(route.ResponseType.Name) > 0 { resp := strings.Title(route.ResponseType.Name) responseString = "(*types." + resp + ", error)" @@ -104,6 +106,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error { if err != nil { return err } + formatCode := formatCode(buffer.String()) _, err = fp.WriteString(formatCode) return err diff --git a/tools/goctl/model/sql/parser/parser.go b/tools/goctl/model/sql/parser/parser.go index dda7e0cf..1f1ff2cf 100644 --- a/tools/goctl/model/sql/parser/parser.go +++ b/tools/goctl/model/sql/parser/parser.go @@ -16,9 +16,7 @@ const ( spatial ) -const ( - timeImport = "time.Time" -) +const timeImport = "time.Time" type ( Table struct { @@ -26,10 +24,12 @@ type ( PrimaryKey Primary Fields []Field } + Primary struct { Field AutoIncrement bool } + Field struct { Name stringx.String DataBaseType string @@ -38,6 +38,7 @@ type ( IsPrimaryKey bool Comment string } + KeyType int )