From 3ee65a55660c0ce61bd4fae1d34e6912cd42685a Mon Sep 17 00:00:00 2001 From: rogerogers Date: Fri, 14 Jun 2024 14:31:22 +0800 Subject: [PATCH] Useless package names when response type and request type are in different packages Signed-off-by: rogerogers --- tpl/hertz/server/standard/package.yaml | 12 +++++++----- tpl/hertz/server/standard_v2/package.yaml | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tpl/hertz/server/standard/package.yaml b/tpl/hertz/server/standard/package.yaml index 5828464f..09157cf8 100644 --- a/tpl/hertz/server/standard/package.yaml +++ b/tpl/hertz/server/standard/package.yaml @@ -33,13 +33,15 @@ layouts: } {{end}} {{if eq $MethodInfo.OutputDir "" -}} - resp,err := service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) + resp := &{{$MethodInfo.ReturnTypeName}}{} + resp,err = service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) if err != nil { utils.SendErrResponse(ctx, c, consts.StatusOK, err) return } {{else}} - resp,err := {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) + resp := &{{$MethodInfo.ReturnTypeName}}{} + resp,err = {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) if err != nil { utils.SendErrResponse(ctx, c, consts.StatusOK, err) return @@ -133,7 +135,7 @@ layouts: w := ut.PerformRequest(h.Engine, "{{.HTTPMethod}}", path, body,header) resp := w.Result() t.Log(string(resp.Body())) - + // todo edit your unit test. // assert.DeepEqual(t, 200, resp.StatusCode()) // assert.DeepEqual(t, "null", string(resp.Body())) @@ -158,9 +160,9 @@ layouts: w := ut.PerformRequest(h.Engine, "{{$MethodInfo.HTTPMethod}}", path, body,header) resp := w.Result() t.Log(string(resp.Body())) - + // todo edit your unit test. // assert.DeepEqual(t, 200, resp.StatusCode()) // assert.DeepEqual(t, "null", string(resp.Body())) } - {{end}} \ No newline at end of file + {{end}} diff --git a/tpl/hertz/server/standard_v2/package.yaml b/tpl/hertz/server/standard_v2/package.yaml index 052439d5..74a55639 100644 --- a/tpl/hertz/server/standard_v2/package.yaml +++ b/tpl/hertz/server/standard_v2/package.yaml @@ -34,13 +34,15 @@ layouts: } {{end}} {{if eq $MethodInfo.OutputDir "" -}} - resp,err := service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) + resp := &{{$MethodInfo.ReturnTypeName}}{} + resp,err = service.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) if err != nil { utils.SendErrResponse(ctx, c, consts.StatusInternalServerError, err) return } {{else}} - resp,err := {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) + resp := &{{$MethodInfo.ReturnTypeName}}{} + resp,err = {{$MethodInfo.OutputDir}}.New{{$MethodInfo.Name}}Service(ctx, c).Run(&req) if err != nil { utils.SendErrResponse(ctx, c, consts.StatusInternalServerError, err) return @@ -134,7 +136,7 @@ layouts: w := ut.PerformRequest(h.Engine, "{{.HTTPMethod}}", path, body,header) resp := w.Result() t.Log(string(resp.Body())) - + // todo edit your unit test. // assert.DeepEqual(t, 200, resp.StatusCode()) // assert.DeepEqual(t, "null", string(resp.Body())) @@ -159,9 +161,9 @@ layouts: w := ut.PerformRequest(h.Engine, "{{$MethodInfo.HTTPMethod}}", path, body,header) resp := w.Result() t.Log(string(resp.Body())) - + // todo edit your unit test. // assert.DeepEqual(t, 200, resp.StatusCode()) // assert.DeepEqual(t, "null", string(resp.Body())) } - {{end}} \ No newline at end of file + {{end}}