Skip to content

Commit

Permalink
refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Sep 3, 2020
1 parent 3a4e1cb commit 8dd93d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions tools/goctl/api/gogen/genlogic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -65,6 +66,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
if err != nil {
return err
}

if !created {
return nil
}
Expand All @@ -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)"
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tools/goctl/model/sql/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ const (
spatial
)

const (
timeImport = "time.Time"
)
const timeImport = "time.Time"

type (
Table struct {
Name stringx.String
PrimaryKey Primary
Fields []Field
}

Primary struct {
Field
AutoIncrement bool
}

Field struct {
Name stringx.String
DataBaseType string
Expand All @@ -38,6 +38,7 @@ type (
IsPrimaryKey bool
Comment string
}

KeyType int
)

Expand Down

0 comments on commit 8dd93d5

Please sign in to comment.