From c562fb6b596a366ccdd98c1170e58938e61f6001 Mon Sep 17 00:00:00 2001 From: GuangyuFan <97507466+FGYFFFF@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:15:54 +0800 Subject: [PATCH] fix(hz): client cookie (#1144) --- cmd/hz/protobuf/ast.go | 4 ++++ cmd/hz/thrift/ast.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cmd/hz/protobuf/ast.go b/cmd/hz/protobuf/ast.go index 3b4759a2c..3ccfc9b51 100644 --- a/cmd/hz/protobuf/ast.go +++ b/cmd/hz/protobuf/ast.go @@ -353,6 +353,10 @@ func parseAnnotationToClient(clientMethod *generator.ClientMethod, gen *protogen val := fileAnnos.(string) clientMethod.FormFileCode += fmt.Sprintf("%q: req.Get%s(),\n", val, f.GoName) } + if proto.HasExtension(f.Desc.Options(), api.E_Cookie) { + hasAnnotation = true + // cookie do nothing + } if !hasAnnotation && strings.EqualFold(clientMethod.HTTPMethod, "get") { clientMethod.QueryParamsCode += fmt.Sprintf("%q: req.Get%s(),\n", checkSnakeName(string(f.Desc.Name())), f.GoName) } diff --git a/cmd/hz/thrift/ast.go b/cmd/hz/thrift/ast.go index d577b95db..83b27fd7f 100644 --- a/cmd/hz/thrift/ast.go +++ b/cmd/hz/thrift/ast.go @@ -321,6 +321,10 @@ func parseAnnotationToClient(clientMethod *generator.ClientMethod, p *parser.Typ hasFormAnnotation = true clientMethod.FormFileCode += fmt.Sprintf("%q: req.Get%s(),\n", fileName, field.GoName().String()) } + if anno := getAnnotation(field.Annotations, AnnotationCookie); len(anno) > 0 { + hasAnnotation = true + // cookie do nothing + } if !hasAnnotation && strings.EqualFold(clientMethod.HTTPMethod, "get") { clientMethod.QueryParamsCode += fmt.Sprintf("%q: req.Get%s(),\n", checkSnakeName(field.GetName()), field.GoName().String()) }