From 5a56eb2fe48ae829efbd0176efcfdf0d7522e3c9 Mon Sep 17 00:00:00 2001 From: zzw <1464003642@qq.com> Date: Wed, 16 Sep 2026 16:08:45 +0800 Subject: [PATCH] feat: client items --- rpc/user/pb/user.pb.go | 120 +++++++++++++++----- rpc/user/pb/user_grpc.pb.go | 38 +++++++ rpc/user/user.pb | Bin 16680 -> 16845 bytes rpc/user/user.proto | 12 ++ services/user/internal/logic/clientLogic.go | 58 ++++++++++ services/user/internal/server/userServer.go | 5 + services/user/userClient/user.go | 7 ++ services/user/validator/client.go | 17 +++ 8 files changed, 231 insertions(+), 26 deletions(-) create mode 100644 services/user/internal/logic/clientLogic.go create mode 100644 services/user/validator/client.go diff --git a/rpc/user/pb/user.pb.go b/rpc/user/pb/user.pb.go index 6e2ef4a..0174d7f 100644 --- a/rpc/user/pb/user.pb.go +++ b/rpc/user/pb/user.pb.go @@ -1254,6 +1254,66 @@ func (*InfoReq) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{19} } +type ClientReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"` + SubjectType uint32 `protobuf:"varint,3,opt,name=subject_type,json=subjectType,proto3" json:"subject_type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ClientReq) Reset() { + *x = ClientReq{} + mi := &file_user_user_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ClientReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientReq) ProtoMessage() {} + +func (x *ClientReq) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClientReq.ProtoReflect.Descriptor instead. +func (*ClientReq) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{20} +} + +func (x *ClientReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ClientReq) GetType() string { + if x != nil { + return x.Type + } + return "" +} + +func (x *ClientReq) GetSubjectType() uint32 { + if x != nil { + return x.SubjectType + } + return 0 +} + var File_user_user_proto protoreflect.FileDescriptor const file_user_user_proto_rawDesc = "" + @@ -1353,10 +1413,15 @@ const file_user_user_proto_rawDesc = "" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x16\n" + "\x06mobile\x18\x02 \x01(\tR\x06mobile\x12\x12\n" + "\x04name\x18\x03 \x01(\tR\x04name\"\t\n" + - "\aInfoReq2\xef\x06\n" + + "\aInfoReq\"V\n" + + "\tClientReq\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" + + "\x04type\x18\x02 \x01(\tR\x04type\x12!\n" + + "\fsubject_type\x18\x03 \x01(\rR\vsubjectType2\xbc\a\n" + "\x04User\x12A\n" + "\x05Login\x12\x0e.user.LoginReq\x1a\x0e.user.Response\"\x18\x82\xd3\xe4\x93\x02\x12:\x01*\"\r/api/v3/login\x12C\n" + - "\x04Info\x12\r.user.InfoReq\x1a\x0e.user.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x12\x11/api/v3/user/info\x12P\n" + + "\x04Info\x12\r.user.InfoReq\x1a\x0e.user.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x12\x11/api/v3/user/info\x12K\n" + + "\x06Client\x12\x0f.user.ClientReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/admin/v3/user/client\x12P\n" + "\tUserItems\x12\x12.user.UserItemsReq\x1a\x0e.user.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/user/items\x12S\n" + "\n" + "UserStatus\x12\x13.user.UserStatusReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/admin/v3/user/status\x12C\n" + @@ -1380,7 +1445,7 @@ func file_user_user_proto_rawDescGZIP() []byte { return file_user_user_proto_rawDescData } -var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 20) +var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 21) var file_user_user_proto_goTypes = []any{ (*Response)(nil), // 0: user.Response (*LoginReq)(nil), // 1: user.LoginReq @@ -1402,33 +1467,36 @@ var file_user_user_proto_goTypes = []any{ (*InternalUpdateReq)(nil), // 17: user.InternalUpdateReq (*InternalUpdateData)(nil), // 18: user.InternalUpdateData (*InfoReq)(nil), // 19: user.InfoReq + (*ClientReq)(nil), // 20: user.ClientReq } var file_user_user_proto_depIdxs = []int32{ 7, // 0: user.InternalUsersByIdsData.items:type_name -> user.UserBriefItem 1, // 1: user.User.Login:input_type -> user.LoginReq 19, // 2: user.User.Info:input_type -> user.InfoReq - 2, // 3: user.User.UserItems:input_type -> user.UserItemsReq - 3, // 4: user.User.UserStatus:input_type -> user.UserStatusReq - 4, // 5: user.User.InternalCreate:input_type -> user.InternalCreateReq - 13, // 6: user.User.InternalCheckCreate:input_type -> user.InternalCheckCreateReq - 15, // 7: user.User.InternalCheckUpdate:input_type -> user.InternalCheckUpdateReq - 17, // 8: user.User.InternalUpdate:input_type -> user.InternalUpdateReq - 6, // 9: user.User.InternalUsersByIds:input_type -> user.InternalUsersByIdsReq - 9, // 10: user.User.InternalUpdateMobile:input_type -> user.InternalUpdateMobileReq - 11, // 11: user.User.InternalRevokeBizClient:input_type -> user.InternalRevokeBizClientReq - 0, // 12: user.User.Login:output_type -> user.Response - 0, // 13: user.User.Info:output_type -> user.Response - 0, // 14: user.User.UserItems:output_type -> user.Response - 0, // 15: user.User.UserStatus:output_type -> user.Response - 5, // 16: user.User.InternalCreate:output_type -> user.InternalCreateData - 14, // 17: user.User.InternalCheckCreate:output_type -> user.InternalCheckCreateData - 16, // 18: user.User.InternalCheckUpdate:output_type -> user.InternalCheckUpdateData - 18, // 19: user.User.InternalUpdate:output_type -> user.InternalUpdateData - 8, // 20: user.User.InternalUsersByIds:output_type -> user.InternalUsersByIdsData - 10, // 21: user.User.InternalUpdateMobile:output_type -> user.InternalUpdateMobileData - 12, // 22: user.User.InternalRevokeBizClient:output_type -> user.InternalRevokeBizClientData - 12, // [12:23] is the sub-list for method output_type - 1, // [1:12] is the sub-list for method input_type + 20, // 3: user.User.Client:input_type -> user.ClientReq + 2, // 4: user.User.UserItems:input_type -> user.UserItemsReq + 3, // 5: user.User.UserStatus:input_type -> user.UserStatusReq + 4, // 6: user.User.InternalCreate:input_type -> user.InternalCreateReq + 13, // 7: user.User.InternalCheckCreate:input_type -> user.InternalCheckCreateReq + 15, // 8: user.User.InternalCheckUpdate:input_type -> user.InternalCheckUpdateReq + 17, // 9: user.User.InternalUpdate:input_type -> user.InternalUpdateReq + 6, // 10: user.User.InternalUsersByIds:input_type -> user.InternalUsersByIdsReq + 9, // 11: user.User.InternalUpdateMobile:input_type -> user.InternalUpdateMobileReq + 11, // 12: user.User.InternalRevokeBizClient:input_type -> user.InternalRevokeBizClientReq + 0, // 13: user.User.Login:output_type -> user.Response + 0, // 14: user.User.Info:output_type -> user.Response + 0, // 15: user.User.Client:output_type -> user.Response + 0, // 16: user.User.UserItems:output_type -> user.Response + 0, // 17: user.User.UserStatus:output_type -> user.Response + 5, // 18: user.User.InternalCreate:output_type -> user.InternalCreateData + 14, // 19: user.User.InternalCheckCreate:output_type -> user.InternalCheckCreateData + 16, // 20: user.User.InternalCheckUpdate:output_type -> user.InternalCheckUpdateData + 18, // 21: user.User.InternalUpdate:output_type -> user.InternalUpdateData + 8, // 22: user.User.InternalUsersByIds:output_type -> user.InternalUsersByIdsData + 10, // 23: user.User.InternalUpdateMobile:output_type -> user.InternalUpdateMobileData + 12, // 24: user.User.InternalRevokeBizClient:output_type -> user.InternalRevokeBizClientData + 13, // [13:25] is the sub-list for method output_type + 1, // [1:13] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -1445,7 +1513,7 @@ func file_user_user_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_user_user_proto_rawDesc), len(file_user_user_proto_rawDesc)), NumEnums: 0, - NumMessages: 20, + NumMessages: 21, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/user/pb/user_grpc.pb.go b/rpc/user/pb/user_grpc.pb.go index f87c4ac..88e2424 100644 --- a/rpc/user/pb/user_grpc.pb.go +++ b/rpc/user/pb/user_grpc.pb.go @@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion9 const ( User_Login_FullMethodName = "/user.User/Login" User_Info_FullMethodName = "/user.User/Info" + User_Client_FullMethodName = "/user.User/Client" User_UserItems_FullMethodName = "/user.User/UserItems" User_UserStatus_FullMethodName = "/user.User/UserStatus" User_InternalCreate_FullMethodName = "/user.User/InternalCreate" @@ -38,6 +39,7 @@ const ( type UserClient interface { Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) + Client(ctx context.Context, in *ClientReq, opts ...grpc.CallOption) (*Response, error) UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error) UserStatus(ctx context.Context, in *UserStatusReq, opts ...grpc.CallOption) (*Response, error) InternalCreate(ctx context.Context, in *InternalCreateReq, opts ...grpc.CallOption) (*InternalCreateData, error) @@ -77,6 +79,16 @@ func (c *userClient) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOpt return out, nil } +func (c *userClient) Client(ctx context.Context, in *ClientReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, User_Client_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *userClient) UserItems(ctx context.Context, in *UserItemsReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -173,6 +185,7 @@ func (c *userClient) InternalRevokeBizClient(ctx context.Context, in *InternalRe type UserServer interface { Login(context.Context, *LoginReq) (*Response, error) Info(context.Context, *InfoReq) (*Response, error) + Client(context.Context, *ClientReq) (*Response, error) UserItems(context.Context, *UserItemsReq) (*Response, error) UserStatus(context.Context, *UserStatusReq) (*Response, error) InternalCreate(context.Context, *InternalCreateReq) (*InternalCreateData, error) @@ -198,6 +211,9 @@ func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*Response, err func (UnimplementedUserServer) Info(context.Context, *InfoReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Info not implemented") } +func (UnimplementedUserServer) Client(context.Context, *ClientReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method Client not implemented") +} func (UnimplementedUserServer) UserItems(context.Context, *UserItemsReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method UserItems not implemented") } @@ -282,6 +298,24 @@ func _User_Info_Handler(srv interface{}, ctx context.Context, dec func(interface return interceptor(ctx, in, info, handler) } +func _User_Client_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClientReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServer).Client(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: User_Client_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServer).Client(ctx, req.(*ClientReq)) + } + return interceptor(ctx, in, info, handler) +} + func _User_UserItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UserItemsReq) if err := dec(in); err != nil { @@ -459,6 +493,10 @@ var User_ServiceDesc = grpc.ServiceDesc{ MethodName: "Info", Handler: _User_Info_Handler, }, + { + MethodName: "Client", + Handler: _User_Client_Handler, + }, { MethodName: "UserItems", Handler: _User_UserItems_Handler, diff --git a/rpc/user/user.pb b/rpc/user/user.pb index a838d703e97893f470f42a4c1920619d907592c1..bbcaa4b57f60ec2fe86a57ed50cd8826f95c1120 100644 GIT binary patch delta 176 zcmZ3{#CW!uaf6d7Q>Wx+7t;U^UZpTDPUoD=)Vz|Q)WXSz{GygZTr4G(1*sBD3XB?@ zL14C!A{S3_X;M~da!EW`ju|M&8^jG23jr!O+QUA1x^2IwHy0bkI3a$$(&E%2J-Fdg vd=P=4)Z&8tyy8?Pg{I3-CNoJ1iRve&