fix format (#23)

* fir format

* fix bug

Co-authored-by: kingxt <dream4kingxt@163.com>
master
kingxt 4 years ago committed by GitHub
parent 9b8595a85e
commit 73b61e09ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,7 +29,6 @@ func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) {{.logic}} {
ctx: ctx, ctx: ctx,
Logger: logx.WithContext(ctx), Logger: logx.WithContext(ctx),
} }
// TODO need set model here from svc
} }
func (l *{{.logic}}) {{.function}}({{.request}}) {{.responseType}} { func (l *{{.logic}}) {{.function}}({{.request}}) {{.responseType}} {
@ -98,7 +97,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
"request": requestString, "request": requestString,
}) })
if err != nil { if err != nil {
return nil return err
} }
formatCode := formatCode(buffer.String()) formatCode := formatCode(buffer.String())
_, err = fp.WriteString(formatCode) _, err = fp.WriteString(formatCode)
@ -120,8 +119,7 @@ func getLogicFolderPath(group spec.Group, route spec.Route) string {
func genLogicImports(route spec.Route, parentPkg string) string { func genLogicImports(route spec.Route, parentPkg string) string {
var imports []string var imports []string
imports = append(imports, `"context"`) imports = append(imports, `"context"`+"\n")
imports = append(imports, "\n")
imports = append(imports, fmt.Sprintf("\"%s/core/logx\"", vars.ProjectOpenSourceUrl)) imports = append(imports, fmt.Sprintf("\"%s/core/logx\"", vars.ProjectOpenSourceUrl))
if len(route.ResponseType.Name) > 0 || len(route.RequestType.Name) > 0 { if len(route.ResponseType.Name) > 0 || len(route.RequestType.Name) > 0 {
imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, typesDir))) imports = append(imports, fmt.Sprintf("\"%s\"", ctlutil.JoinPackages(parentPkg, typesDir)))

Loading…
Cancel
Save