diff --git a/goctl_template/api/handler.tpl b/goctl_template/api/handler.tpl index 4810ce25..987750da 100644 --- a/goctl_template/api/handler.tpl +++ b/goctl_template/api/handler.tpl @@ -50,7 +50,7 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc { } // 创建一个业务逻辑层实例 {{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx) - {{if .HasResp}}resp{{end}} := l.{{.Call}}({{if .HasRequest}}&req, userinfo{{end}}) + {{if .HasResp}}resp{{end}} := l.{{.Call}}({{if .HasRequest}}&req, {{end}}userinfo) // 如果响应不为nil,则使用httpx.OkJsonCtx方法返回JSON响应; // 否则,发送500内部服务器错误的JSON响应并记录错误消息logx.Error。 if resp != nil { diff --git a/server_api/basic.api b/server_api/basic.api index d979d3be..d3eba6ea 100644 --- a/server_api/basic.api +++ b/server_api/basic.api @@ -6,7 +6,9 @@ info ( author: "" email: "" ) +type request { +} // response 统一返回码 type response { Code int `json:"code"`