From 440d711e7beedb8c16410e153580f98694e87267 Mon Sep 17 00:00:00 2001 From: wubin48435 Date: Sun, 29 Sep 2024 00:17:45 +0800 Subject: [PATCH] add grpc_gen_cmd flag to go-doudou svc init and go-doudou svc grpc commands to support custom protoc command --- cmd/grpc.go | 8 +- cmd/init.go | 3 +- cmd/internal/svc/codegen/database/common.go | 15 +- cmd/internal/svc/codegen/database/gorm.go | 1 + cmd/internal/svc/codegen/grpc.go | 8 +- cmd/internal/svc/svc.go | 9 +- .../transport/grpc/usersvc.pb.go | 827 ++++++++++++++++++ .../transport/grpc/usersvc.pb.json.go | 84 ++ .../transport/grpc/usersvc_grpc.pb.go | 107 +++ toolkit/protobuf/v3/service.go | 25 +- version/version.go | 2 +- 11 files changed, 1058 insertions(+), 31 deletions(-) create mode 100644 cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.go create mode 100644 cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.json.go create mode 100644 cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc_grpc.pb.go diff --git a/cmd/grpc.go b/cmd/grpc.go index 95c07efd..8efad690 100644 --- a/cmd/grpc.go +++ b/cmd/grpc.go @@ -11,6 +11,7 @@ import ( var naming string var http2grpc bool var annotatedOnly bool +var protocCmd string var grpcCmd = &cobra.Command{ Use: "grpc", @@ -23,7 +24,7 @@ var grpcCmd = &cobra.Command{ fn = strcase.ToSnake } s := svc.NewSvc("", - svc.WithProtoGenerator(v3.NewProtoGenerator(v3.WithFieldNamingFunc(fn), v3.WithAnnotatedOnly(annotatedOnly))), + svc.WithProtoGenerator(v3.NewProtoGenerator(v3.WithFieldNamingFunc(fn), v3.WithAnnotatedOnly(annotatedOnly), v3.WithProtocCmd(protocCmd))), svc.WithHttp2Grpc(http2grpc), svc.WithAllowGetWithReqBody(allowGetWithReqBody), svc.WithCaseConverter(fn), @@ -37,7 +38,8 @@ func init() { svcCmd.AddCommand(grpcCmd) grpcCmd.Flags().BoolVarP(&omitempty, "omitempty", "o", false, `if true, ",omitempty" will be appended to json tag of fields in every generated anonymous struct in handlers`) grpcCmd.Flags().StringVar(&naming, "case", "lowerCamel", `protobuf message field naming strategy, only support "lowerCamel" and "snake"`) + grpcCmd.Flags().StringVar(&protocCmd, "grpc_gen_cmd", "protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative --go-json_out=. --go-json_opt=paths=source_relative", `command to generate grpc service and message code`) grpcCmd.Flags().BoolVar(&http2grpc, "http2grpc", false, `whether need RESTful api for your grpc service`) - grpcCmd.Flags().BoolVar(&allowGetWithReqBody, "allowGetWithReqBody", false, "Whether allow get http request with request body.") - grpcCmd.Flags().BoolVar(&annotatedOnly, "annotatedOnly", false, "Whether generate grpc api only for method annotated with @grpc or not") + grpcCmd.Flags().BoolVar(&allowGetWithReqBody, "allow_get_body", false, "Whether allow get http request with request body.") + grpcCmd.Flags().BoolVar(&annotatedOnly, "annotated_only", false, "Whether generate grpc api only for method annotated with @grpc or not") } diff --git a/cmd/init.go b/cmd/init.go index bde63512..937cdf1e 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -60,7 +60,7 @@ var initCmd = &cobra.Command{ case "snake": fn = strcase.ToSnake } - options = append(options, svc.WithJsonCase(naming), svc.WithCaseConverter(fn), svc.WithProtoGenerator(v3.NewProtoGenerator(v3.WithFieldNamingFunc(fn)))) + options = append(options, svc.WithJsonCase(naming), svc.WithCaseConverter(fn), svc.WithProtoGenerator(v3.NewProtoGenerator(v3.WithFieldNamingFunc(fn), v3.WithProtocCmd(protocCmd)))) s := svc.NewSvc(svcdir, options...) s.Init() }, @@ -77,6 +77,7 @@ func init() { initCmd.Flags().StringVar(&dbDsn, "db_dsn", "", `Specify database connection url`) initCmd.Flags().StringVar(&dbSoft, "db_soft", "deleted_at", `Specify database soft delete column name`) initCmd.Flags().BoolVar(&dbGrpc, "db_grpc", false, `If true, grpc code will also be generated`) + initCmd.Flags().StringVar(&protocCmd, "grpc_gen_cmd", "protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative --go-json_out=. --go-json_opt=paths=source_relative", `command to generate grpc service and message code`) initCmd.Flags().BoolVar(&dbService, "db_service", false, `If false, service will not be generated, and db_grpc will be ignored. Only dao layer code will be generated.`) initCmd.Flags().BoolVar(&dbGenGenGo, "db_gen_gen", false, `whether generate gen.go file`) initCmd.Flags().StringVar(&dbTablePrefix, "db_table_prefix", "", `table prefix or schema name for pg`) diff --git a/cmd/internal/svc/codegen/database/common.go b/cmd/internal/svc/codegen/database/common.go index 5248abac..312d05ed 100644 --- a/cmd/internal/svc/codegen/database/common.go +++ b/cmd/internal/svc/codegen/database/common.go @@ -44,6 +44,7 @@ type OrmGeneratorConfig struct { Dir string Soft string Grpc bool + ProtoGenerator v3.ProtoGenerator Omitempty bool } @@ -71,6 +72,7 @@ type AbstractBaseGenerator struct { Dir string g *gormgen.Generator CaseConverter func(string) string + ProtoGenerator v3.ProtoGenerator Omitempty bool AllowGetWithReqBody bool Client bool @@ -174,19 +176,12 @@ func (b *AbstractBaseGenerator) GenService() { }) if b.Grpc { - p := v3.NewProtoGenerator(v3.WithFieldNamingFunc(b.CaseConverter)) - parser.ParseDtoGrpc(b.Dir, p, "dto") - grpcSvc, protoFile := codegen.GenGrpcProto(b.Dir, ic, p) + parser.ParseDtoGrpc(b.Dir, b.ProtoGenerator, "dto") + grpcSvc, protoFile := codegen.GenGrpcProto(b.Dir, ic, b.ProtoGenerator) protoFile, _ = filepath.Rel(b.Dir, protoFile) wd, _ := os.Getwd() os.Chdir(filepath.Join(b.Dir)) - // protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative transport/grpc/helloworld.proto - if err = b.runner.Run("protoc", "--proto_path=.", - "--go_out=.", - "--go_opt=paths=source_relative", - "--go-grpc_out=.", - "--go-grpc_opt=paths=source_relative", - protoFile); err != nil { + if err := b.ProtoGenerator.Generate(protoFile, b.runner); err != nil { panic(err) } os.Chdir(wd) diff --git a/cmd/internal/svc/codegen/database/gorm.go b/cmd/internal/svc/codegen/database/gorm.go index 83130512..667de123 100644 --- a/cmd/internal/svc/codegen/database/gorm.go +++ b/cmd/internal/svc/codegen/database/gorm.go @@ -97,6 +97,7 @@ func (gg *GormGenerator) Initialize(conf OrmGeneratorConfig) { gg.TableExcludeGlob = conf.TableExcludeGlob gg.GenGenGo = conf.GenGenGo gg.CaseConverter = conf.CaseConverter + gg.ProtoGenerator = conf.ProtoGenerator var db *gorm.DB var err error switch gg.Driver { diff --git a/cmd/internal/svc/codegen/grpc.go b/cmd/internal/svc/codegen/grpc.go index cc0d4088..97a2576b 100644 --- a/cmd/internal/svc/codegen/grpc.go +++ b/cmd/internal/svc/codegen/grpc.go @@ -17,13 +17,7 @@ func genGrpc(dir string, ic astutils.InterfaceCollector, runner executils.Runner oldWd, _ := os.Getwd() os.Chdir(dir) protoFile = strings.TrimPrefix(protoFile, dir+string(filepath.Separator)) - // protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative transport/grpc/helloworld.proto - if err := runner.Run("protoc", "--proto_path=.", - "--go_out=.", - "--go_opt=paths=source_relative", - "--go-grpc_out=.", - "--go-grpc_opt=paths=source_relative", - protoFile); err != nil { + if err := protoGenerator.Generate(protoFile, runner); err != nil { panic(err) } os.Chdir(oldWd) diff --git a/cmd/internal/svc/svc.go b/cmd/internal/svc/svc.go index e5caef51..037d8526 100644 --- a/cmd/internal/svc/svc.go +++ b/cmd/internal/svc/svc.go @@ -199,6 +199,7 @@ func (receiver *Svc) Init() { Dir: receiver.dir, Soft: receiver.DbConfig.Soft, Grpc: receiver.DbConfig.Grpc, + ProtoGenerator: receiver.protoGenerator, Omitempty: receiver.DbConfig.Omitempty, }) if receiver.DbConfig.Service { @@ -536,13 +537,7 @@ func (receiver *Svc) Grpc() { codegen.GenConfig(dir, ic) parser.ParseDtoGrpc(dir, receiver.protoGenerator, "dto") grpcSvc, protoFile := codegen.GenGrpcProto(dir, ic, receiver.protoGenerator) - // protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative transport/grpc/helloworld.proto - if err := receiver.runner.Run("protoc", "--proto_path=.", - "--go_out=.", - "--go_opt=paths=source_relative", - "--go-grpc_out=.", - "--go-grpc_opt=paths=source_relative", - protoFile); err != nil { + if err := receiver.protoGenerator.Generate(protoFile, receiver.runner); err != nil { panic(err) } codegen.GenSvcImplGrpc(dir, ic, grpcSvc) diff --git a/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.go b/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.go new file mode 100644 index 00000000..a3a7000c --- /dev/null +++ b/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.go @@ -0,0 +1,827 @@ +//* +// Generated by go-doudou v2.4.2. +// Don't edit! +// +// Version No.: v20240926 + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.7 +// source: transport/grpc/usersvc.proto + +package grpc + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + structpb "google.golang.org/protobuf/types/known/structpb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type KeyboardLayout int32 + +const ( + KeyboardLayout_UNKNOWN KeyboardLayout = 0 + KeyboardLayout_QWERTZ KeyboardLayout = 1 + KeyboardLayout_AZERTY KeyboardLayout = 2 + KeyboardLayout_QWERTY KeyboardLayout = 3 +) + +// Enum value maps for KeyboardLayout. +var ( + KeyboardLayout_name = map[int32]string{ + 0: "UNKNOWN", + 1: "QWERTZ", + 2: "AZERTY", + 3: "QWERTY", + } + KeyboardLayout_value = map[string]int32{ + "UNKNOWN": 0, + "QWERTZ": 1, + "AZERTY": 2, + "QWERTY": 3, + } +) + +func (x KeyboardLayout) Enum() *KeyboardLayout { + p := new(KeyboardLayout) + *p = x + return p +} + +func (x KeyboardLayout) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (KeyboardLayout) Descriptor() protoreflect.EnumDescriptor { + return file_transport_grpc_usersvc_proto_enumTypes[0].Descriptor() +} + +func (KeyboardLayout) Type() protoreflect.EnumType { + return &file_transport_grpc_usersvc_proto_enumTypes[0] +} + +func (x KeyboardLayout) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use KeyboardLayout.Descriptor instead. +func (KeyboardLayout) EnumDescriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{0} +} + +type Anonystructkfvagz8UXPWVpn5Z9XyjWS struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Label *string `protobuf:"bytes,1,opt,name=label,proto3,oneof" json:"label,omitempty"` + Value *string `protobuf:"bytes,2,opt,name=value,proto3,oneof" json:"value,omitempty"` +} + +func (x *Anonystructkfvagz8UXPWVpn5Z9XyjWS) Reset() { + *x = Anonystructkfvagz8UXPWVpn5Z9XyjWS{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Anonystructkfvagz8UXPWVpn5Z9XyjWS) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Anonystructkfvagz8UXPWVpn5Z9XyjWS) ProtoMessage() {} + +func (x *Anonystructkfvagz8UXPWVpn5Z9XyjWS) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Anonystructkfvagz8UXPWVpn5Z9XyjWS.ProtoReflect.Descriptor instead. +func (*Anonystructkfvagz8UXPWVpn5Z9XyjWS) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{0} +} + +func (x *Anonystructkfvagz8UXPWVpn5Z9XyjWS) GetLabel() string { + if x != nil && x.Label != nil { + return *x.Label + } + return "" +} + +func (x *Anonystructkfvagz8UXPWVpn5Z9XyjWS) GetValue() string { + if x != nil && x.Value != nil { + return *x.Value + } + return "" +} + +// 排序条件 +type Order struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Col *string `protobuf:"bytes,1,opt,name=col,proto3,oneof" json:"col,omitempty"` + Sort *string `protobuf:"bytes,2,opt,name=sort,proto3,oneof" json:"sort,omitempty"` +} + +func (x *Order) Reset() { + *x = Order{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Order) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Order) ProtoMessage() {} + +func (x *Order) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Order.ProtoReflect.Descriptor instead. +func (*Order) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{1} +} + +func (x *Order) GetCol() string { + if x != nil && x.Col != nil { + return *x.Col + } + return "" +} + +func (x *Order) GetSort() string { + if x != nil && x.Sort != nil { + return *x.Sort + } + return "" +} + +type Page struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 排序规则 + Orders []*Order `protobuf:"bytes,1,rep,name=orders,proto3" json:"orders,omitempty"` + // 页码 + PageNo *int32 `protobuf:"varint,2,opt,name=page_no,proto3,oneof" json:"page_no,omitempty"` + // 每页行数 + Size *int32 `protobuf:"varint,3,opt,name=size,json=size,omitempty,proto3,oneof" json:"size,omitempty"` + User *UserVo `protobuf:"bytes,4,opt,name=user,proto3,oneof" json:"user,omitempty"` +} + +func (x *Page) Reset() { + *x = Page{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Page) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Page) ProtoMessage() {} + +func (x *Page) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Page.ProtoReflect.Descriptor instead. +func (*Page) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{2} +} + +func (x *Page) GetOrders() []*Order { + if x != nil { + return x.Orders + } + return nil +} + +func (x *Page) GetPageNo() int32 { + if x != nil && x.PageNo != nil { + return *x.PageNo + } + return 0 +} + +func (x *Page) GetSize() int32 { + if x != nil && x.Size != nil { + return *x.Size + } + return 0 +} + +func (x *Page) GetUser() *UserVo { + if x != nil { + return x.User + } + return nil +} + +// 筛选条件 +type PageFilter struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // 真实姓名,前缀匹配 + Name *string `protobuf:"bytes,1,opt,name=name,proto3,oneof" json:"name,omitempty"` + // 所属部门ID + Dept *int32 `protobuf:"varint,2,opt,name=dept,proto3,oneof" json:"dept,omitempty"` +} + +func (x *PageFilter) Reset() { + *x = PageFilter{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PageFilter) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageFilter) ProtoMessage() {} + +func (x *PageFilter) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PageFilter.ProtoReflect.Descriptor instead. +func (*PageFilter) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{3} +} + +func (x *PageFilter) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *PageFilter) GetDept() int32 { + if x != nil && x.Dept != nil { + return *x.Dept + } + return 0 +} + +// 分页筛选条件 +type PageQuery struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Filter *PageFilter `protobuf:"bytes,1,opt,name=filter,proto3,oneof" json:"filter,omitempty"` + Page *Page `protobuf:"bytes,2,opt,name=page,proto3,oneof" json:"page,omitempty"` + Condtions *structpb.Struct `protobuf:"bytes,3,opt,name=condtions,proto3,oneof" json:"condtions,omitempty"` + ACondtions *structpb.ListValue `protobuf:"bytes,4,opt,name=a_condtions,proto3,oneof" json:"a_condtions,omitempty"` + Id *int64 `protobuf:"varint,5,opt,name=id,json=id,string,proto3,oneof" json:"id,omitempty"` + Options []*Anonystructkfvagz8UXPWVpn5Z9XyjWS `protobuf:"bytes,6,rep,name=options,proto3" json:"options,omitempty"` +} + +func (x *PageQuery) Reset() { + *x = PageQuery{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PageQuery) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageQuery) ProtoMessage() {} + +func (x *PageQuery) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PageQuery.ProtoReflect.Descriptor instead. +func (*PageQuery) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{4} +} + +func (x *PageQuery) GetFilter() *PageFilter { + if x != nil { + return x.Filter + } + return nil +} + +func (x *PageQuery) GetPage() *Page { + if x != nil { + return x.Page + } + return nil +} + +func (x *PageQuery) GetCondtions() *structpb.Struct { + if x != nil { + return x.Condtions + } + return nil +} + +func (x *PageQuery) GetACondtions() *structpb.ListValue { + if x != nil { + return x.ACondtions + } + return nil +} + +func (x *PageQuery) GetId() int64 { + if x != nil && x.Id != nil { + return *x.Id + } + return 0 +} + +func (x *PageQuery) GetOptions() []*Anonystructkfvagz8UXPWVpn5Z9XyjWS { + if x != nil { + return x.Options + } + return nil +} + +type PageRet struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items *structpb.Value `protobuf:"bytes,1,opt,name=items,proto3,oneof" json:"items,omitempty"` + PageNo *int32 `protobuf:"varint,2,opt,name=page_no,proto3,oneof" json:"page_no,omitempty"` + PageSize *int32 `protobuf:"varint,3,opt,name=page_size,proto3,oneof" json:"page_size,omitempty"` + Total *int32 `protobuf:"varint,4,opt,name=total,proto3,oneof" json:"total,omitempty"` + HasNext *bool `protobuf:"varint,5,opt,name=has_next,proto3,oneof" json:"has_next,omitempty"` +} + +func (x *PageRet) Reset() { + *x = PageRet{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PageRet) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PageRet) ProtoMessage() {} + +func (x *PageRet) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PageRet.ProtoReflect.Descriptor instead. +func (*PageRet) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{5} +} + +func (x *PageRet) GetItems() *structpb.Value { + if x != nil { + return x.Items + } + return nil +} + +func (x *PageRet) GetPageNo() int32 { + if x != nil && x.PageNo != nil { + return *x.PageNo + } + return 0 +} + +func (x *PageRet) GetPageSize() int32 { + if x != nil && x.PageSize != nil { + return *x.PageSize + } + return 0 +} + +func (x *PageRet) GetTotal() int32 { + if x != nil && x.Total != nil { + return *x.Total + } + return 0 +} + +func (x *PageRet) GetHasNext() bool { + if x != nil && x.HasNext != nil { + return *x.HasNext + } + return false +} + +type UserVo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *int32 `protobuf:"varint,1,opt,name=id,proto3,oneof" json:"id,omitempty"` + Name *string `protobuf:"bytes,2,opt,name=name,proto3,oneof" json:"name,omitempty"` + Phone *string `protobuf:"bytes,3,opt,name=phone,proto3,oneof" json:"phone,omitempty"` + Dept *string `protobuf:"bytes,4,opt,name=dept,proto3,oneof" json:"dept,omitempty"` +} + +func (x *UserVo) Reset() { + *x = UserVo{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_grpc_usersvc_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UserVo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UserVo) ProtoMessage() {} + +func (x *UserVo) ProtoReflect() protoreflect.Message { + mi := &file_transport_grpc_usersvc_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use UserVo.ProtoReflect.Descriptor instead. +func (*UserVo) Descriptor() ([]byte, []int) { + return file_transport_grpc_usersvc_proto_rawDescGZIP(), []int{6} +} + +func (x *UserVo) GetId() int32 { + if x != nil && x.Id != nil { + return *x.Id + } + return 0 +} + +func (x *UserVo) GetName() string { + if x != nil && x.Name != nil { + return *x.Name + } + return "" +} + +func (x *UserVo) GetPhone() string { + if x != nil && x.Phone != nil { + return *x.Phone + } + return "" +} + +func (x *UserVo) GetDept() string { + if x != nil && x.Dept != nil { + return *x.Dept + } + return "" +} + +var File_transport_grpc_usersvc_proto protoreflect.FileDescriptor + +var file_transport_grpc_usersvc_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, + 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x76, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x76, 0x63, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x6d, 0x0a, 0x21, 0x41, 0x6e, 0x6f, 0x6e, 0x79, 0x73, 0x74, + 0x72, 0x75, 0x63, 0x74, 0x6b, 0x66, 0x76, 0x61, 0x67, 0x7a, 0x38, 0x75, 0x58, 0x50, 0x57, 0x56, + 0x70, 0x6e, 0x35, 0x7a, 0x39, 0x78, 0x79, 0x6a, 0x57, 0x53, 0x12, 0x19, 0x0a, 0x05, 0x6c, 0x61, + 0x62, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x05, 0x6c, 0x61, 0x62, + 0x65, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x19, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x88, 0x01, 0x01, + 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x22, 0x48, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x15, 0x0a, + 0x03, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x63, 0x6f, + 0x6c, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x48, 0x01, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x88, 0x01, 0x01, 0x42, 0x06, 0x0a, + 0x04, 0x5f, 0x63, 0x6f, 0x6c, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x73, 0x6f, 0x72, 0x74, 0x22, 0xb8, + 0x01, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x26, 0x0a, 0x06, 0x6f, 0x72, 0x64, 0x65, 0x72, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x76, + 0x63, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x06, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x12, + 0x1d, 0x0a, 0x07, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x48, 0x00, 0x52, 0x07, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x6f, 0x88, 0x01, 0x01, 0x12, 0x21, + 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, 0x0e, + 0x73, 0x69, 0x7a, 0x65, 0x2c, 0x6f, 0x6d, 0x69, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x88, 0x01, + 0x01, 0x12, 0x28, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x76, 0x63, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x56, 0x6f, + 0x48, 0x02, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, + 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x6f, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x73, 0x69, 0x7a, 0x65, + 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x22, 0x50, 0x0a, 0x0a, 0x50, 0x61, 0x67, + 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, + 0x12, 0x17, 0x0a, 0x04, 0x64, 0x65, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, + 0x52, 0x04, 0x64, 0x65, 0x70, 0x74, 0x88, 0x01, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x64, 0x65, 0x70, 0x74, 0x22, 0xff, 0x02, 0x0a, 0x09, + 0x50, 0x61, 0x67, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x30, 0x0a, 0x06, 0x66, 0x69, 0x6c, + 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x76, 0x63, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x48, 0x00, + 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x88, 0x01, 0x01, 0x12, 0x26, 0x0a, 0x04, 0x70, + 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x76, 0x63, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x48, 0x01, 0x52, 0x04, 0x70, 0x61, 0x67, 0x65, + 0x88, 0x01, 0x01, 0x12, 0x3a, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x48, + 0x02, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x88, 0x01, 0x01, 0x12, + 0x41, 0x0a, 0x0b, 0x61, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x48, 0x03, 0x52, 0x0b, 0x61, 0x5f, 0x63, 0x6f, 0x6e, 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x88, + 0x01, 0x01, 0x12, 0x1a, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x48, 0x04, + 0x52, 0x09, 0x69, 0x64, 0x2c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x88, 0x01, 0x01, 0x12, 0x44, + 0x0a, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x2a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x76, 0x63, 0x2e, 0x41, 0x6e, 0x6f, 0x6e, 0x79, 0x73, + 0x74, 0x72, 0x75, 0x63, 0x74, 0x6b, 0x66, 0x76, 0x61, 0x67, 0x7a, 0x38, 0x75, 0x58, 0x50, 0x57, + 0x56, 0x70, 0x6e, 0x35, 0x7a, 0x39, 0x78, 0x79, 0x6a, 0x57, 0x53, 0x52, 0x07, 0x6f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x42, + 0x07, 0x0a, 0x05, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x63, 0x6f, 0x6e, + 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x0e, 0x0a, 0x0c, 0x5f, 0x61, 0x5f, 0x63, 0x6f, 0x6e, + 0x64, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x69, 0x64, 0x22, 0xf5, 0x01, + 0x0a, 0x07, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x74, 0x12, 0x31, 0x0a, 0x05, 0x69, 0x74, 0x65, + 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x48, 0x00, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x88, 0x01, 0x01, 0x12, 0x1d, 0x0a, 0x07, + 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x48, 0x01, 0x52, + 0x07, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x6f, 0x88, 0x01, 0x01, 0x12, 0x21, 0x0a, 0x09, 0x70, + 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x48, 0x02, + 0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x88, 0x01, 0x01, 0x12, 0x19, + 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x48, 0x03, 0x52, + 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x1f, 0x0a, 0x08, 0x68, 0x61, 0x73, + 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, 0x04, 0x52, 0x08, 0x68, + 0x61, 0x73, 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x88, 0x01, 0x01, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x6f, + 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x42, 0x08, + 0x0a, 0x06, 0x5f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x68, 0x61, 0x73, + 0x5f, 0x6e, 0x65, 0x78, 0x74, 0x22, 0x8d, 0x01, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x56, 0x6f, + 0x12, 0x13, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x02, + 0x69, 0x64, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x88, 0x01, 0x01, 0x12, 0x19, + 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x48, 0x02, 0x52, + 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x88, 0x01, 0x01, 0x12, 0x17, 0x0a, 0x04, 0x64, 0x65, 0x70, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x48, 0x03, 0x52, 0x04, 0x64, 0x65, 0x70, 0x74, 0x88, + 0x01, 0x01, 0x42, 0x05, 0x0a, 0x03, 0x5f, 0x69, 0x64, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x6e, 0x61, + 0x6d, 0x65, 0x42, 0x08, 0x0a, 0x06, 0x5f, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x42, 0x07, 0x0a, 0x05, + 0x5f, 0x64, 0x65, 0x70, 0x74, 0x2a, 0x41, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x62, 0x6f, 0x61, 0x72, + 0x64, 0x4c, 0x61, 0x79, 0x6f, 0x75, 0x74, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, + 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x51, 0x57, 0x45, 0x52, 0x54, 0x5a, 0x10, 0x01, + 0x12, 0x0a, 0x0a, 0x06, 0x41, 0x5a, 0x45, 0x52, 0x54, 0x59, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, + 0x51, 0x57, 0x45, 0x52, 0x54, 0x59, 0x10, 0x03, 0x32, 0x43, 0x0a, 0x0e, 0x55, 0x73, 0x65, 0x72, + 0x73, 0x76, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x31, 0x0a, 0x0c, 0x50, 0x61, + 0x67, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x70, 0x63, 0x12, 0x12, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x73, 0x76, 0x63, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x1a, 0x0d, + 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x76, 0x63, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x42, 0x61, 0x5a, + 0x5f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x6f, + 0x6e, 0x6a, 0x2d, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x67, 0x6f, 0x2d, 0x64, 0x6f, 0x75, 0x64, + 0x6f, 0x75, 0x2f, 0x76, 0x32, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x73, 0x76, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, + 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x61, 0x6e, 0x6f, 0x6e, 0x79, 0x73, 0x74, 0x72, 0x75, 0x63, + 0x74, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_transport_grpc_usersvc_proto_rawDescOnce sync.Once + file_transport_grpc_usersvc_proto_rawDescData = file_transport_grpc_usersvc_proto_rawDesc +) + +func file_transport_grpc_usersvc_proto_rawDescGZIP() []byte { + file_transport_grpc_usersvc_proto_rawDescOnce.Do(func() { + file_transport_grpc_usersvc_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_grpc_usersvc_proto_rawDescData) + }) + return file_transport_grpc_usersvc_proto_rawDescData +} + +var file_transport_grpc_usersvc_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_transport_grpc_usersvc_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_transport_grpc_usersvc_proto_goTypes = []interface{}{ + (KeyboardLayout)(0), // 0: usersvc.KeyboardLayout + (*Anonystructkfvagz8UXPWVpn5Z9XyjWS)(nil), // 1: usersvc.Anonystructkfvagz8uXPWVpn5z9xyjWS + (*Order)(nil), // 2: usersvc.Order + (*Page)(nil), // 3: usersvc.Page + (*PageFilter)(nil), // 4: usersvc.PageFilter + (*PageQuery)(nil), // 5: usersvc.PageQuery + (*PageRet)(nil), // 6: usersvc.PageRet + (*UserVo)(nil), // 7: usersvc.UserVo + (*structpb.Struct)(nil), // 8: google.protobuf.Struct + (*structpb.ListValue)(nil), // 9: google.protobuf.ListValue + (*structpb.Value)(nil), // 10: google.protobuf.Value +} +var file_transport_grpc_usersvc_proto_depIdxs = []int32{ + 2, // 0: usersvc.Page.orders:type_name -> usersvc.Order + 7, // 1: usersvc.Page.user:type_name -> usersvc.UserVo + 4, // 2: usersvc.PageQuery.filter:type_name -> usersvc.PageFilter + 3, // 3: usersvc.PageQuery.page:type_name -> usersvc.Page + 8, // 4: usersvc.PageQuery.condtions:type_name -> google.protobuf.Struct + 9, // 5: usersvc.PageQuery.a_condtions:type_name -> google.protobuf.ListValue + 1, // 6: usersvc.PageQuery.options:type_name -> usersvc.Anonystructkfvagz8uXPWVpn5z9xyjWS + 10, // 7: usersvc.PageRet.items:type_name -> google.protobuf.Value + 5, // 8: usersvc.UsersvcService.PageUsersRpc:input_type -> usersvc.PageQuery + 3, // 9: usersvc.UsersvcService.PageUsersRpc:output_type -> usersvc.Page + 9, // [9:10] is the sub-list for method output_type + 8, // [8:9] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name +} + +func init() { file_transport_grpc_usersvc_proto_init() } +func file_transport_grpc_usersvc_proto_init() { + if File_transport_grpc_usersvc_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_transport_grpc_usersvc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Anonystructkfvagz8UXPWVpn5Z9XyjWS); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_transport_grpc_usersvc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Order); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_transport_grpc_usersvc_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Page); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_transport_grpc_usersvc_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PageFilter); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_transport_grpc_usersvc_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PageQuery); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_transport_grpc_usersvc_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PageRet); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_transport_grpc_usersvc_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UserVo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + file_transport_grpc_usersvc_proto_msgTypes[0].OneofWrappers = []interface{}{} + file_transport_grpc_usersvc_proto_msgTypes[1].OneofWrappers = []interface{}{} + file_transport_grpc_usersvc_proto_msgTypes[2].OneofWrappers = []interface{}{} + file_transport_grpc_usersvc_proto_msgTypes[3].OneofWrappers = []interface{}{} + file_transport_grpc_usersvc_proto_msgTypes[4].OneofWrappers = []interface{}{} + file_transport_grpc_usersvc_proto_msgTypes[5].OneofWrappers = []interface{}{} + file_transport_grpc_usersvc_proto_msgTypes[6].OneofWrappers = []interface{}{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_transport_grpc_usersvc_proto_rawDesc, + NumEnums: 1, + NumMessages: 7, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_transport_grpc_usersvc_proto_goTypes, + DependencyIndexes: file_transport_grpc_usersvc_proto_depIdxs, + EnumInfos: file_transport_grpc_usersvc_proto_enumTypes, + MessageInfos: file_transport_grpc_usersvc_proto_msgTypes, + }.Build() + File_transport_grpc_usersvc_proto = out.File + file_transport_grpc_usersvc_proto_rawDesc = nil + file_transport_grpc_usersvc_proto_goTypes = nil + file_transport_grpc_usersvc_proto_depIdxs = nil +} diff --git a/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.json.go b/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.json.go new file mode 100644 index 00000000..b95d8f1d --- /dev/null +++ b/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.pb.json.go @@ -0,0 +1,84 @@ +//* +// Generated by go-doudou v2.4.2. +// Don't edit! +// +// Version No.: v20240926 + +// Code generated by protoc-gen-go-json. DO NOT EDIT. +// source: transport/grpc/usersvc.proto + +package grpc + +import ( + "google.golang.org/protobuf/encoding/protojson" +) + +// MarshalJSON implements json.Marshaler +func (msg *Anonystructkfvagz8UXPWVpn5Z9XyjWS) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *Anonystructkfvagz8UXPWVpn5Z9XyjWS) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *Order) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *Order) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *Page) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *Page) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *PageFilter) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *PageFilter) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *PageQuery) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *PageQuery) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *PageRet) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *PageRet) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} + +// MarshalJSON implements json.Marshaler +func (msg *UserVo) MarshalJSON() ([]byte, error) { + return protojson.MarshalOptions{}.Marshal(msg) +} + +// UnmarshalJSON implements json.Unmarshaler +func (msg *UserVo) UnmarshalJSON(b []byte) error { + return protojson.UnmarshalOptions{}.Unmarshal(b, msg) +} diff --git a/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc_grpc.pb.go b/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc_grpc.pb.go new file mode 100644 index 00000000..0b6efa65 --- /dev/null +++ b/cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.7 +// source: transport/grpc/usersvc.proto + +package grpc + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// UsersvcServiceClient is the client API for UsersvcService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type UsersvcServiceClient interface { + // You can define your service methods as your need. Below is an example. + PageUsersRpc(ctx context.Context, in *PageQuery, opts ...grpc.CallOption) (*Page, error) +} + +type usersvcServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUsersvcServiceClient(cc grpc.ClientConnInterface) UsersvcServiceClient { + return &usersvcServiceClient{cc} +} + +func (c *usersvcServiceClient) PageUsersRpc(ctx context.Context, in *PageQuery, opts ...grpc.CallOption) (*Page, error) { + out := new(Page) + err := c.cc.Invoke(ctx, "/usersvc.UsersvcService/PageUsersRpc", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// UsersvcServiceServer is the server API for UsersvcService service. +// All implementations must embed UnimplementedUsersvcServiceServer +// for forward compatibility +type UsersvcServiceServer interface { + // You can define your service methods as your need. Below is an example. + PageUsersRpc(context.Context, *PageQuery) (*Page, error) + mustEmbedUnimplementedUsersvcServiceServer() +} + +// UnimplementedUsersvcServiceServer must be embedded to have forward compatible implementations. +type UnimplementedUsersvcServiceServer struct { +} + +func (UnimplementedUsersvcServiceServer) PageUsersRpc(context.Context, *PageQuery) (*Page, error) { + return nil, status.Errorf(codes.Unimplemented, "method PageUsersRpc not implemented") +} +func (UnimplementedUsersvcServiceServer) mustEmbedUnimplementedUsersvcServiceServer() {} + +// UnsafeUsersvcServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to UsersvcServiceServer will +// result in compilation errors. +type UnsafeUsersvcServiceServer interface { + mustEmbedUnimplementedUsersvcServiceServer() +} + +func RegisterUsersvcServiceServer(s grpc.ServiceRegistrar, srv UsersvcServiceServer) { + s.RegisterService(&UsersvcService_ServiceDesc, srv) +} + +func _UsersvcService_PageUsersRpc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PageQuery) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UsersvcServiceServer).PageUsersRpc(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/usersvc.UsersvcService/PageUsersRpc", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UsersvcServiceServer).PageUsersRpc(ctx, req.(*PageQuery)) + } + return interceptor(ctx, in, info, handler) +} + +// UsersvcService_ServiceDesc is the grpc.ServiceDesc for UsersvcService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var UsersvcService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "usersvc.UsersvcService", + HandlerType: (*UsersvcServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "PageUsersRpc", + Handler: _UsersvcService_PageUsersRpc_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "transport/grpc/usersvc.proto", +} diff --git a/toolkit/protobuf/v3/service.go b/toolkit/protobuf/v3/service.go index 3531229a..bb52a9f1 100644 --- a/toolkit/protobuf/v3/service.go +++ b/toolkit/protobuf/v3/service.go @@ -3,7 +3,10 @@ package v3 import ( "fmt" "github.com/goccy/go-reflect" + "github.com/pkg/errors" "github.com/samber/lo" + "github.com/unionj-cloud/go-doudou/v2/toolkit/executils" + "github.com/unionj-cloud/go-doudou/v2/toolkit/stringutils" "strings" "time" @@ -15,12 +18,19 @@ import ( type ProtoGenerator struct { fieldNamingFunc func(string) string - Structs []astutils.StructMeta - annotatedOnly bool + Structs []astutils.StructMeta + annotatedOnly bool + protocCmd string } type ProtoGeneratorOption func(*ProtoGenerator) +func WithProtocCmd(cmd string) ProtoGeneratorOption { + return func(p *ProtoGenerator) { + p.protocCmd = cmd + } +} + func WithFieldNamingFunc(fn func(string) string) ProtoGeneratorOption { return func(p *ProtoGenerator) { p.fieldNamingFunc = fn @@ -187,3 +197,14 @@ func (receiver ProtoGenerator) newResponse(rpcName string, params []astutils.Fie IsTopLevel: true, } } + +// Generate depends on protoc-gen-go-json plugin, so run go install github.com/mfridman/protoc-gen-go-json@v1.4.0 first. +func (receiver ProtoGenerator) Generate(protoFile string, runner executils.Runner) error { + if stringutils.IsEmpty(receiver.protocCmd) { + return errors.New("Command cannot be empty") + } + // default: protoc --proto_path=. --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative --go-json_out=. --go-json_opt=paths=source_relative transport/grpc/usersvc.proto + args := strings.Split(receiver.protocCmd, " ") + args = append(args, protoFile) + return runner.Run(args[0], args[1:]...) +} diff --git a/version/version.go b/version/version.go index a3e54bfb..01f74c1b 100644 --- a/version/version.go +++ b/version/version.go @@ -1,3 +1,3 @@ package version -const Release = "v2.4.2" +const Release = "v2.4.3"