refactor code

master v1.0.10
kevin 4 years ago
parent 3a4e1cbb33
commit 8dd93d59a0

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

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

Loading…
Cancel
Save