mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-02 16:28:39 +08:00
optimized (#392)
This commit is contained in:
parent
6887fb22de
commit
4db20677f7
@ -69,6 +69,7 @@ func getParentPackage(dir string) (string, error) {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return filepath.ToSlash(filepath.Join(projectCtx.Path, strings.TrimPrefix(projectCtx.WorkDir, projectCtx.Dir))), nil
|
||||
}
|
||||
|
||||
@ -82,6 +83,7 @@ func writeProperty(writer io.Writer, name, tag, comment string, tp spec.Type, in
|
||||
} else {
|
||||
_, err = fmt.Fprintf(writer, "%s %s %s\n", strings.Title(name), tp.Name(), tag)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@ -110,6 +112,7 @@ func getMiddleware(api *spec.ApiSpec) []string {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.KeysStr()
|
||||
}
|
||||
|
||||
@ -127,7 +130,15 @@ func responseGoTypeName(r spec.Route, pkg ...string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
return golangExpr(r.ResponseType, pkg...)
|
||||
resp := golangExpr(r.ResponseType, pkg...)
|
||||
switch r.ResponseType.(type) {
|
||||
case spec.DefineStruct:
|
||||
if !strings.HasPrefix(resp, "*") {
|
||||
return "*" + resp
|
||||
}
|
||||
}
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
func requestGoTypeName(r spec.Route, pkg ...string) string {
|
||||
|
@ -339,5 +339,6 @@ func formatSource(source string) string {
|
||||
if err := scanner.Err(); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
}
|
||||
|
@ -128,6 +128,7 @@ func getImports(api *spec.ApiSpec, packetName string) string {
|
||||
if len(allTypes) > 0 {
|
||||
fmt.Fprintf(&builder, "import com.xhb.logic.http.packet.%s.model.*;\n", packetName)
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ func (p parser) convert2Spec() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return p.fillService()
|
||||
}
|
||||
|
||||
@ -188,6 +189,7 @@ func (p parser) astTypeToSpec(in ast.DataType) spec.Type {
|
||||
return spec.PointerType{RawName: v.PointerExpr.Text(), Type: spec.DefineStruct{RawName: raw}}
|
||||
}
|
||||
}
|
||||
|
||||
panic(fmt.Sprintf("unspported type %+v", in))
|
||||
}
|
||||
|
||||
@ -203,6 +205,7 @@ func (p parser) commentExprs(comment ast.Expr) string {
|
||||
if comment == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return comment.Text()
|
||||
}
|
||||
|
||||
@ -310,5 +313,6 @@ func (p parser) fillRouteType(route *spec.Route) error {
|
||||
route.ResponseType = *tp
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ func (r Route) GetAnnotation(key string) string {
|
||||
if r.Annotation.Properties == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return r.Annotation.Properties[key]
|
||||
}
|
||||
|
||||
@ -177,6 +178,7 @@ func (g Group) GetAnnotation(key string) string {
|
||||
if g.Annotation.Properties == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return g.Annotation.Properties[key]
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
BuildVersion = "1.1.3"
|
||||
BuildVersion = "1.1.4"
|
||||
commands = []cli.Command{
|
||||
{
|
||||
Name: "upgrade",
|
||||
|
Loading…
Reference in New Issue
Block a user