diff --git a/rpc/chore/chore.pb b/rpc/chore/chore.pb index 003ac0f..eecb0e8 100644 Binary files a/rpc/chore/chore.pb and b/rpc/chore/chore.pb differ diff --git a/rpc/chore/chore.proto b/rpc/chore/chore.proto index a90cc69..17983ea 100644 --- a/rpc/chore/chore.proto +++ b/rpc/chore/chore.proto @@ -4,7 +4,6 @@ package chore; option go_package = "lone-services/rpc/chore"; import "google/api/annotations.proto"; -// 应放到pkg service Chore { rpc Policy(PolicyReq) returns (Response) { option (google.api.http) = { @@ -28,6 +27,12 @@ service Chore { get: "/api/v3/chore/regions" }; } + rpc SendSms(SendSmsReq) returns (Response) { + option (google.api.http) = { + post: "/api/v3/sms/send" + body: "*" + }; + } rpc AnswerItems(EmptyReq) returns (Response) { option (google.api.http) = { get: "/admin/v3/chore/answer/items" @@ -118,6 +123,7 @@ message TestReq { int32 id = 1; repeated int64 ids = 2; uint32 number = 3; + string char = 4; } message DecryptMobileReq { @@ -139,4 +145,9 @@ message RegionItem { message RegionsByIdsData { repeated RegionItem items = 1; +} + +message SendSmsReq { + string mobile = 1; + int32 scene = 2; } \ No newline at end of file diff --git a/rpc/chore/pb/chore.pb.go b/rpc/chore/pb/chore.pb.go index 1ae2a5d..56fd514 100644 --- a/rpc/chore/pb/chore.pb.go +++ b/rpc/chore/pb/chore.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.11 -// protoc v4.25.8 +// protoc v3.19.4 // source: chore/chore.proto package chore @@ -399,6 +399,7 @@ type TestReq struct { Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Ids []int64 `protobuf:"varint,2,rep,packed,name=ids,proto3" json:"ids,omitempty"` Number uint32 `protobuf:"varint,3,opt,name=number,proto3" json:"number,omitempty"` + Char string `protobuf:"bytes,4,opt,name=char,proto3" json:"char,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -454,6 +455,13 @@ func (x *TestReq) GetNumber() uint32 { return 0 } +func (x *TestReq) GetChar() string { + if x != nil { + return x.Char + } + return "" +} + type DecryptMobileReq struct { state protoimpl.MessageState `protogen:"open.v1"` OriginMobile string `protobuf:"bytes,1,opt,name=origin_mobile,json=originMobile,proto3" json:"origin_mobile,omitempty"` @@ -682,6 +690,58 @@ func (x *RegionsByIdsData) GetItems() []*RegionItem { return nil } +type SendSmsReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"` + Scene int32 `protobuf:"varint,2,opt,name=scene,proto3" json:"scene,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SendSmsReq) Reset() { + *x = SendSmsReq{} + mi := &file_chore_chore_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SendSmsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendSmsReq) ProtoMessage() {} + +func (x *SendSmsReq) ProtoReflect() protoreflect.Message { + mi := &file_chore_chore_proto_msgTypes[13] + 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 SendSmsReq.ProtoReflect.Descriptor instead. +func (*SendSmsReq) Descriptor() ([]byte, []int) { + return file_chore_chore_proto_rawDescGZIP(), []int{13} +} + +func (x *SendSmsReq) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +func (x *SendSmsReq) GetScene() int32 { + if x != nil { + return x.Scene + } + return 0 +} + var File_chore_chore_proto protoreflect.FileDescriptor const file_chore_chore_proto_rawDesc = "" + @@ -709,11 +769,12 @@ const file_chore_chore_proto_rawDesc = "" + "\x04type\x18\x01 \x01(\x05R\x04type\x12\x18\n" + "\acontent\x18\x02 \x01(\tR\acontent\"\x1d\n" + "\tPolicyReq\x12\x10\n" + - "\x03key\x18\x01 \x01(\tR\x03key\"C\n" + + "\x03key\x18\x01 \x01(\tR\x03key\"W\n" + "\aTestReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x10\n" + "\x03ids\x18\x02 \x03(\x03R\x03ids\x12\x16\n" + - "\x06number\x18\x03 \x01(\rR\x06number\"7\n" + + "\x06number\x18\x03 \x01(\rR\x06number\x12\x12\n" + + "\x04char\x18\x04 \x01(\tR\x04char\"7\n" + "\x10DecryptMobileReq\x12#\n" + "\rorigin_mobile\x18\x01 \x01(\tR\foriginMobile\")\n" + "\n" + @@ -726,12 +787,17 @@ const file_chore_chore_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\";\n" + "\x10RegionsByIdsData\x12'\n" + - "\x05items\x18\x01 \x03(\v2\x11.chore.RegionItemR\x05items2\x9d\t\n" + + "\x05items\x18\x01 \x03(\v2\x11.chore.RegionItemR\x05items\":\n" + + "\n" + + "SendSmsReq\x12\x16\n" + + "\x06mobile\x18\x01 \x01(\tR\x06mobile\x12\x14\n" + + "\x05scene\x18\x02 \x01(\x05R\x05scene2\xe9\t\n" + "\x05Chore\x12P\n" + "\x06Policy\x12\x10.chore.PolicyReq\x1a\x0f.chore.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x12\x18/api/v3/chore/oss/policy\x12F\n" + "\x04Test\x12\x0e.chore.TestReq\x1a\x0f.chore.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v3/chore/test\x12_\n" + "\rDecryptMobile\x12\x17.chore.DecryptMobileReq\x1a\x0f.chore.Response\"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/api/v3/chore/decrypt/mobile\x12L\n" + - "\aRegions\x12\x11.chore.RegionsReq\x1a\x0f.chore.Response\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/api/v3/chore/regions\x12U\n" + + "\aRegions\x12\x11.chore.RegionsReq\x1a\x0f.chore.Response\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/api/v3/chore/regions\x12J\n" + + "\aSendSms\x12\x11.chore.SendSmsReq\x1a\x0f.chore.Response\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/api/v3/sms/send\x12U\n" + "\vAnswerItems\x12\x0f.chore.EmptyReq\x1a\x0f.chore.Response\"$\x82\xd3\xe4\x93\x02\x1e\x12\x1c/admin/v3/chore/answer/items\x12X\n" + "\fAnswerStatus\x12\x10.chore.StatusReq\x1a\x0f.chore.Response\"%\x82\xd3\xe4\x93\x02\x1f\"\x1d/admin/v3/chore/answer/status\x12P\n" + "\n" + @@ -759,7 +825,7 @@ func file_chore_chore_proto_rawDescGZIP() []byte { return file_chore_chore_proto_rawDescData } -var file_chore_chore_proto_msgTypes = make([]protoimpl.MessageInfo, 13) +var file_chore_chore_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_chore_chore_proto_goTypes = []any{ (*Response)(nil), // 0: chore.Response (*EmptyReq)(nil), // 1: chore.EmptyReq @@ -774,6 +840,7 @@ var file_chore_chore_proto_goTypes = []any{ (*RegionsByIdsReq)(nil), // 10: chore.RegionsByIdsReq (*RegionItem)(nil), // 11: chore.RegionItem (*RegionsByIdsData)(nil), // 12: chore.RegionsByIdsData + (*SendSmsReq)(nil), // 13: chore.SendSmsReq } var file_chore_chore_proto_depIdxs = []int32{ 11, // 0: chore.RegionsByIdsData.items:type_name -> chore.RegionItem @@ -781,32 +848,34 @@ var file_chore_chore_proto_depIdxs = []int32{ 7, // 2: chore.Chore.Test:input_type -> chore.TestReq 8, // 3: chore.Chore.DecryptMobile:input_type -> chore.DecryptMobileReq 9, // 4: chore.Chore.Regions:input_type -> chore.RegionsReq - 1, // 5: chore.Chore.AnswerItems:input_type -> chore.EmptyReq - 3, // 6: chore.Chore.AnswerStatus:input_type -> chore.StatusReq - 2, // 7: chore.Chore.AnswerInfo:input_type -> chore.IdReq - 4, // 8: chore.Chore.AnswerCreate:input_type -> chore.EditReq - 4, // 9: chore.Chore.AnswerEdit:input_type -> chore.EditReq - 5, // 10: chore.Chore.SystemEdit:input_type -> chore.SystemEditReq - 3, // 11: chore.Chore.SystemStatus:input_type -> chore.StatusReq - 2, // 12: chore.Chore.SystemInfo:input_type -> chore.IdReq - 1, // 13: chore.Chore.SystemItems:input_type -> chore.EmptyReq - 10, // 14: chore.Chore.RegionsByIds:input_type -> chore.RegionsByIdsReq - 0, // 15: chore.Chore.Policy:output_type -> chore.Response - 0, // 16: chore.Chore.Test:output_type -> chore.Response - 0, // 17: chore.Chore.DecryptMobile:output_type -> chore.Response - 0, // 18: chore.Chore.Regions:output_type -> chore.Response - 0, // 19: chore.Chore.AnswerItems:output_type -> chore.Response - 0, // 20: chore.Chore.AnswerStatus:output_type -> chore.Response - 0, // 21: chore.Chore.AnswerInfo:output_type -> chore.Response - 0, // 22: chore.Chore.AnswerCreate:output_type -> chore.Response - 0, // 23: chore.Chore.AnswerEdit:output_type -> chore.Response - 0, // 24: chore.Chore.SystemEdit:output_type -> chore.Response - 0, // 25: chore.Chore.SystemStatus:output_type -> chore.Response - 0, // 26: chore.Chore.SystemInfo:output_type -> chore.Response - 0, // 27: chore.Chore.SystemItems:output_type -> chore.Response - 12, // 28: chore.Chore.RegionsByIds:output_type -> chore.RegionsByIdsData - 15, // [15:29] is the sub-list for method output_type - 1, // [1:15] is the sub-list for method input_type + 13, // 5: chore.Chore.SendSms:input_type -> chore.SendSmsReq + 1, // 6: chore.Chore.AnswerItems:input_type -> chore.EmptyReq + 3, // 7: chore.Chore.AnswerStatus:input_type -> chore.StatusReq + 2, // 8: chore.Chore.AnswerInfo:input_type -> chore.IdReq + 4, // 9: chore.Chore.AnswerCreate:input_type -> chore.EditReq + 4, // 10: chore.Chore.AnswerEdit:input_type -> chore.EditReq + 5, // 11: chore.Chore.SystemEdit:input_type -> chore.SystemEditReq + 3, // 12: chore.Chore.SystemStatus:input_type -> chore.StatusReq + 2, // 13: chore.Chore.SystemInfo:input_type -> chore.IdReq + 1, // 14: chore.Chore.SystemItems:input_type -> chore.EmptyReq + 10, // 15: chore.Chore.RegionsByIds:input_type -> chore.RegionsByIdsReq + 0, // 16: chore.Chore.Policy:output_type -> chore.Response + 0, // 17: chore.Chore.Test:output_type -> chore.Response + 0, // 18: chore.Chore.DecryptMobile:output_type -> chore.Response + 0, // 19: chore.Chore.Regions:output_type -> chore.Response + 0, // 20: chore.Chore.SendSms:output_type -> chore.Response + 0, // 21: chore.Chore.AnswerItems:output_type -> chore.Response + 0, // 22: chore.Chore.AnswerStatus:output_type -> chore.Response + 0, // 23: chore.Chore.AnswerInfo:output_type -> chore.Response + 0, // 24: chore.Chore.AnswerCreate:output_type -> chore.Response + 0, // 25: chore.Chore.AnswerEdit:output_type -> chore.Response + 0, // 26: chore.Chore.SystemEdit:output_type -> chore.Response + 0, // 27: chore.Chore.SystemStatus:output_type -> chore.Response + 0, // 28: chore.Chore.SystemInfo:output_type -> chore.Response + 0, // 29: chore.Chore.SystemItems:output_type -> chore.Response + 12, // 30: chore.Chore.RegionsByIds:output_type -> chore.RegionsByIdsData + 16, // [16:31] is the sub-list for method output_type + 1, // [1:16] 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 @@ -823,7 +892,7 @@ func file_chore_chore_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_chore_chore_proto_rawDesc), len(file_chore_chore_proto_rawDesc)), NumEnums: 0, - NumMessages: 13, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/chore/pb/chore_grpc.pb.go b/rpc/chore/pb/chore_grpc.pb.go index c6a37b2..7c86c7e 100644 --- a/rpc/chore/pb/chore_grpc.pb.go +++ b/rpc/chore/pb/chore_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.6.2 -// - protoc v4.25.8 +// - protoc v3.19.4 // source: chore/chore.proto package chore @@ -23,6 +23,7 @@ const ( Chore_Test_FullMethodName = "/chore.Chore/Test" Chore_DecryptMobile_FullMethodName = "/chore.Chore/DecryptMobile" Chore_Regions_FullMethodName = "/chore.Chore/Regions" + Chore_SendSms_FullMethodName = "/chore.Chore/SendSms" Chore_AnswerItems_FullMethodName = "/chore.Chore/AnswerItems" Chore_AnswerStatus_FullMethodName = "/chore.Chore/AnswerStatus" Chore_AnswerInfo_FullMethodName = "/chore.Chore/AnswerInfo" @@ -38,13 +39,12 @@ const ( // ChoreClient is the client API for Chore 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. -// -// 应放到pkg type ChoreClient interface { Policy(ctx context.Context, in *PolicyReq, opts ...grpc.CallOption) (*Response, error) Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) DecryptMobile(ctx context.Context, in *DecryptMobileReq, opts ...grpc.CallOption) (*Response, error) Regions(ctx context.Context, in *RegionsReq, opts ...grpc.CallOption) (*Response, error) + SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) AnswerItems(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) AnswerStatus(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) AnswerInfo(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*Response, error) @@ -106,6 +106,16 @@ func (c *choreClient) Regions(ctx context.Context, in *RegionsReq, opts ...grpc. return out, nil } +func (c *choreClient) SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Chore_SendSms_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *choreClient) AnswerItems(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -209,13 +219,12 @@ func (c *choreClient) RegionsByIds(ctx context.Context, in *RegionsByIdsReq, opt // ChoreServer is the server API for Chore service. // All implementations must embed UnimplementedChoreServer // for forward compatibility. -// -// 应放到pkg type ChoreServer interface { Policy(context.Context, *PolicyReq) (*Response, error) Test(context.Context, *TestReq) (*Response, error) DecryptMobile(context.Context, *DecryptMobileReq) (*Response, error) Regions(context.Context, *RegionsReq) (*Response, error) + SendSms(context.Context, *SendSmsReq) (*Response, error) AnswerItems(context.Context, *EmptyReq) (*Response, error) AnswerStatus(context.Context, *StatusReq) (*Response, error) AnswerInfo(context.Context, *IdReq) (*Response, error) @@ -249,6 +258,9 @@ func (UnimplementedChoreServer) DecryptMobile(context.Context, *DecryptMobileReq func (UnimplementedChoreServer) Regions(context.Context, *RegionsReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Regions not implemented") } +func (UnimplementedChoreServer) SendSms(context.Context, *SendSmsReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method SendSms not implemented") +} func (UnimplementedChoreServer) AnswerItems(context.Context, *EmptyReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method AnswerItems not implemented") } @@ -372,6 +384,24 @@ func _Chore_Regions_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Chore_SendSms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendSmsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChoreServer).SendSms(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Chore_SendSms_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChoreServer).SendSms(ctx, req.(*SendSmsReq)) + } + return interceptor(ctx, in, info, handler) +} + func _Chore_AnswerItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(EmptyReq) if err := dec(in); err != nil { @@ -575,6 +605,10 @@ var Chore_ServiceDesc = grpc.ServiceDesc{ MethodName: "Regions", Handler: _Chore_Regions_Handler, }, + { + MethodName: "SendSms", + Handler: _Chore_SendSms_Handler, + }, { MethodName: "AnswerItems", Handler: _Chore_AnswerItems_Handler, diff --git a/rpc/user/pb/user.pb.go b/rpc/user/pb/user.pb.go index 1228cd1..6894390 100644 --- a/rpc/user/pb/user.pb.go +++ b/rpc/user/pb/user.pb.go @@ -278,35 +278,35 @@ func (x *UserStatusReq) GetStatus() int32 { return 0 } -type EnsureBizIdentityReq struct { +type InternalCreateReq struct { state protoimpl.MessageState `protogen:"open.v1"` Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Avatar string `protobuf:"bytes,3,opt,name=avatar,proto3" json:"avatar,omitempty"` Gender uint32 `protobuf:"varint,4,opt,name=gender,proto3" json:"gender,omitempty"` Birthday string `protobuf:"bytes,5,opt,name=birthday,proto3" json:"birthday,omitempty"` - ClientCode string `protobuf:"bytes,6,opt,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` - CredentialType string `protobuf:"bytes,7,opt,name=credential_type,json=credentialType,proto3" json:"credential_type,omitempty"` + ClientCode []string `protobuf:"bytes,6,rep,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` + CredentialType []string `protobuf:"bytes,7,rep,name=credential_type,json=credentialType,proto3" json:"credential_type,omitempty"` Identifier string `protobuf:"bytes,8,opt,name=identifier,proto3" json:"identifier,omitempty"` Secret string `protobuf:"bytes,9,opt,name=secret,proto3" json:"secret,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *EnsureBizIdentityReq) Reset() { - *x = EnsureBizIdentityReq{} +func (x *InternalCreateReq) Reset() { + *x = InternalCreateReq{} mi := &file_user_user_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *EnsureBizIdentityReq) String() string { +func (x *InternalCreateReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*EnsureBizIdentityReq) ProtoMessage() {} +func (*InternalCreateReq) ProtoMessage() {} -func (x *EnsureBizIdentityReq) ProtoReflect() protoreflect.Message { +func (x *InternalCreateReq) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -318,75 +318,75 @@ func (x *EnsureBizIdentityReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use EnsureBizIdentityReq.ProtoReflect.Descriptor instead. -func (*EnsureBizIdentityReq) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalCreateReq.ProtoReflect.Descriptor instead. +func (*InternalCreateReq) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{4} } -func (x *EnsureBizIdentityReq) GetMobile() string { +func (x *InternalCreateReq) GetMobile() string { if x != nil { return x.Mobile } return "" } -func (x *EnsureBizIdentityReq) GetName() string { +func (x *InternalCreateReq) GetName() string { if x != nil { return x.Name } return "" } -func (x *EnsureBizIdentityReq) GetAvatar() string { +func (x *InternalCreateReq) GetAvatar() string { if x != nil { return x.Avatar } return "" } -func (x *EnsureBizIdentityReq) GetGender() uint32 { +func (x *InternalCreateReq) GetGender() uint32 { if x != nil { return x.Gender } return 0 } -func (x *EnsureBizIdentityReq) GetBirthday() string { +func (x *InternalCreateReq) GetBirthday() string { if x != nil { return x.Birthday } return "" } -func (x *EnsureBizIdentityReq) GetClientCode() string { +func (x *InternalCreateReq) GetClientCode() []string { if x != nil { return x.ClientCode } - return "" + return nil } -func (x *EnsureBizIdentityReq) GetCredentialType() string { +func (x *InternalCreateReq) GetCredentialType() []string { if x != nil { return x.CredentialType } - return "" + return nil } -func (x *EnsureBizIdentityReq) GetIdentifier() string { +func (x *InternalCreateReq) GetIdentifier() string { if x != nil { return x.Identifier } return "" } -func (x *EnsureBizIdentityReq) GetSecret() string { +func (x *InternalCreateReq) GetSecret() string { if x != nil { return x.Secret } return "" } -type EnsureBizIdentityData struct { +type InternalCreateData struct { state protoimpl.MessageState `protogen:"open.v1"` UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` Created bool `protobuf:"varint,2,opt,name=created,proto3" json:"created,omitempty"` @@ -396,20 +396,20 @@ type EnsureBizIdentityData struct { sizeCache protoimpl.SizeCache } -func (x *EnsureBizIdentityData) Reset() { - *x = EnsureBizIdentityData{} +func (x *InternalCreateData) Reset() { + *x = InternalCreateData{} mi := &file_user_user_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *EnsureBizIdentityData) String() string { +func (x *InternalCreateData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*EnsureBizIdentityData) ProtoMessage() {} +func (*InternalCreateData) ProtoMessage() {} -func (x *EnsureBizIdentityData) ProtoReflect() protoreflect.Message { +func (x *InternalCreateData) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -421,60 +421,60 @@ func (x *EnsureBizIdentityData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use EnsureBizIdentityData.ProtoReflect.Descriptor instead. -func (*EnsureBizIdentityData) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalCreateData.ProtoReflect.Descriptor instead. +func (*InternalCreateData) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{5} } -func (x *EnsureBizIdentityData) GetUserId() int64 { +func (x *InternalCreateData) GetUserId() int64 { if x != nil { return x.UserId } return 0 } -func (x *EnsureBizIdentityData) GetCreated() bool { +func (x *InternalCreateData) GetCreated() bool { if x != nil { return x.Created } return false } -func (x *EnsureBizIdentityData) GetMobile() string { +func (x *InternalCreateData) GetMobile() string { if x != nil { return x.Mobile } return "" } -func (x *EnsureBizIdentityData) GetName() string { +func (x *InternalCreateData) GetName() string { if x != nil { return x.Name } return "" } -type UsersByIdsReq struct { +type InternalUsersByIdsReq struct { state protoimpl.MessageState `protogen:"open.v1"` Ids []int64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *UsersByIdsReq) Reset() { - *x = UsersByIdsReq{} +func (x *InternalUsersByIdsReq) Reset() { + *x = InternalUsersByIdsReq{} mi := &file_user_user_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UsersByIdsReq) String() string { +func (x *InternalUsersByIdsReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UsersByIdsReq) ProtoMessage() {} +func (*InternalUsersByIdsReq) ProtoMessage() {} -func (x *UsersByIdsReq) ProtoReflect() protoreflect.Message { +func (x *InternalUsersByIdsReq) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -486,12 +486,12 @@ func (x *UsersByIdsReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UsersByIdsReq.ProtoReflect.Descriptor instead. -func (*UsersByIdsReq) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalUsersByIdsReq.ProtoReflect.Descriptor instead. +func (*InternalUsersByIdsReq) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{6} } -func (x *UsersByIdsReq) GetIds() []int64 { +func (x *InternalUsersByIdsReq) GetIds() []int64 { if x != nil { return x.Ids } @@ -590,27 +590,27 @@ func (x *UserBriefItem) GetStatus() uint32 { return 0 } -type UsersByIdsData struct { +type InternalUsersByIdsData struct { state protoimpl.MessageState `protogen:"open.v1"` Items []*UserBriefItem `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *UsersByIdsData) Reset() { - *x = UsersByIdsData{} +func (x *InternalUsersByIdsData) Reset() { + *x = InternalUsersByIdsData{} mi := &file_user_user_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UsersByIdsData) String() string { +func (x *InternalUsersByIdsData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UsersByIdsData) ProtoMessage() {} +func (*InternalUsersByIdsData) ProtoMessage() {} -func (x *UsersByIdsData) ProtoReflect() protoreflect.Message { +func (x *InternalUsersByIdsData) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -622,19 +622,19 @@ func (x *UsersByIdsData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UsersByIdsData.ProtoReflect.Descriptor instead. -func (*UsersByIdsData) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalUsersByIdsData.ProtoReflect.Descriptor instead. +func (*InternalUsersByIdsData) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{8} } -func (x *UsersByIdsData) GetItems() []*UserBriefItem { +func (x *InternalUsersByIdsData) GetItems() []*UserBriefItem { if x != nil { return x.Items } return nil } -type UpdateMobileReq struct { +type InternalUpdateMobileReq struct { state protoimpl.MessageState `protogen:"open.v1"` UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` Mobile string `protobuf:"bytes,2,opt,name=mobile,proto3" json:"mobile,omitempty"` @@ -642,20 +642,20 @@ type UpdateMobileReq struct { sizeCache protoimpl.SizeCache } -func (x *UpdateMobileReq) Reset() { - *x = UpdateMobileReq{} +func (x *InternalUpdateMobileReq) Reset() { + *x = InternalUpdateMobileReq{} mi := &file_user_user_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UpdateMobileReq) String() string { +func (x *InternalUpdateMobileReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateMobileReq) ProtoMessage() {} +func (*InternalUpdateMobileReq) ProtoMessage() {} -func (x *UpdateMobileReq) ProtoReflect() protoreflect.Message { +func (x *InternalUpdateMobileReq) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -667,26 +667,26 @@ func (x *UpdateMobileReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateMobileReq.ProtoReflect.Descriptor instead. -func (*UpdateMobileReq) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalUpdateMobileReq.ProtoReflect.Descriptor instead. +func (*InternalUpdateMobileReq) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{9} } -func (x *UpdateMobileReq) GetUserId() int64 { +func (x *InternalUpdateMobileReq) GetUserId() int64 { if x != nil { return x.UserId } return 0 } -func (x *UpdateMobileReq) GetMobile() string { +func (x *InternalUpdateMobileReq) GetMobile() string { if x != nil { return x.Mobile } return "" } -type UpdateMobileData struct { +type InternalUpdateMobileData struct { state protoimpl.MessageState `protogen:"open.v1"` UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` Mobile string `protobuf:"bytes,2,opt,name=mobile,proto3" json:"mobile,omitempty"` @@ -694,20 +694,20 @@ type UpdateMobileData struct { sizeCache protoimpl.SizeCache } -func (x *UpdateMobileData) Reset() { - *x = UpdateMobileData{} +func (x *InternalUpdateMobileData) Reset() { + *x = InternalUpdateMobileData{} mi := &file_user_user_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *UpdateMobileData) String() string { +func (x *InternalUpdateMobileData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*UpdateMobileData) ProtoMessage() {} +func (*InternalUpdateMobileData) ProtoMessage() {} -func (x *UpdateMobileData) ProtoReflect() protoreflect.Message { +func (x *InternalUpdateMobileData) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -719,26 +719,26 @@ func (x *UpdateMobileData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use UpdateMobileData.ProtoReflect.Descriptor instead. -func (*UpdateMobileData) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalUpdateMobileData.ProtoReflect.Descriptor instead. +func (*InternalUpdateMobileData) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{10} } -func (x *UpdateMobileData) GetUserId() int64 { +func (x *InternalUpdateMobileData) GetUserId() int64 { if x != nil { return x.UserId } return 0 } -func (x *UpdateMobileData) GetMobile() string { +func (x *InternalUpdateMobileData) GetMobile() string { if x != nil { return x.Mobile } return "" } -type RevokeBizClientReq struct { +type InternalRevokeBizClientReq struct { state protoimpl.MessageState `protogen:"open.v1"` UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` ClientCode string `protobuf:"bytes,2,opt,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` @@ -746,20 +746,20 @@ type RevokeBizClientReq struct { sizeCache protoimpl.SizeCache } -func (x *RevokeBizClientReq) Reset() { - *x = RevokeBizClientReq{} +func (x *InternalRevokeBizClientReq) Reset() { + *x = InternalRevokeBizClientReq{} mi := &file_user_user_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *RevokeBizClientReq) String() string { +func (x *InternalRevokeBizClientReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RevokeBizClientReq) ProtoMessage() {} +func (*InternalRevokeBizClientReq) ProtoMessage() {} -func (x *RevokeBizClientReq) ProtoReflect() protoreflect.Message { +func (x *InternalRevokeBizClientReq) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -771,46 +771,46 @@ func (x *RevokeBizClientReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RevokeBizClientReq.ProtoReflect.Descriptor instead. -func (*RevokeBizClientReq) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalRevokeBizClientReq.ProtoReflect.Descriptor instead. +func (*InternalRevokeBizClientReq) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{11} } -func (x *RevokeBizClientReq) GetUserId() int64 { +func (x *InternalRevokeBizClientReq) GetUserId() int64 { if x != nil { return x.UserId } return 0 } -func (x *RevokeBizClientReq) GetClientCode() string { +func (x *InternalRevokeBizClientReq) GetClientCode() string { if x != nil { return x.ClientCode } return "" } -type RevokeBizClientData struct { +type InternalRevokeBizClientData struct { state protoimpl.MessageState `protogen:"open.v1"` Revoked bool `protobuf:"varint,1,opt,name=revoked,proto3" json:"revoked,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *RevokeBizClientData) Reset() { - *x = RevokeBizClientData{} +func (x *InternalRevokeBizClientData) Reset() { + *x = InternalRevokeBizClientData{} mi := &file_user_user_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *RevokeBizClientData) String() string { +func (x *InternalRevokeBizClientData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RevokeBizClientData) ProtoMessage() {} +func (*InternalRevokeBizClientData) ProtoMessage() {} -func (x *RevokeBizClientData) ProtoReflect() protoreflect.Message { +func (x *InternalRevokeBizClientData) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -822,40 +822,39 @@ func (x *RevokeBizClientData) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RevokeBizClientData.ProtoReflect.Descriptor instead. -func (*RevokeBizClientData) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalRevokeBizClientData.ProtoReflect.Descriptor instead. +func (*InternalRevokeBizClientData) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{12} } -func (x *RevokeBizClientData) GetRevoked() bool { +func (x *InternalRevokeBizClientData) GetRevoked() bool { if x != nil { return x.Revoked } return false } -type SendSmsReq struct { +type InternalCheckCreateReq struct { state protoimpl.MessageState `protogen:"open.v1"` Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"` - Scene int32 `protobuf:"varint,2,opt,name=scene,proto3" json:"scene,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *SendSmsReq) Reset() { - *x = SendSmsReq{} +func (x *InternalCheckCreateReq) Reset() { + *x = InternalCheckCreateReq{} mi := &file_user_user_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *SendSmsReq) String() string { +func (x *InternalCheckCreateReq) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SendSmsReq) ProtoMessage() {} +func (*InternalCheckCreateReq) ProtoMessage() {} -func (x *SendSmsReq) ProtoReflect() protoreflect.Message { +func (x *InternalCheckCreateReq) ProtoReflect() protoreflect.Message { mi := &file_user_user_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -867,25 +866,334 @@ func (x *SendSmsReq) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SendSmsReq.ProtoReflect.Descriptor instead. -func (*SendSmsReq) Descriptor() ([]byte, []int) { +// Deprecated: Use InternalCheckCreateReq.ProtoReflect.Descriptor instead. +func (*InternalCheckCreateReq) Descriptor() ([]byte, []int) { return file_user_user_proto_rawDescGZIP(), []int{13} } -func (x *SendSmsReq) GetMobile() string { +func (x *InternalCheckCreateReq) GetMobile() string { if x != nil { return x.Mobile } return "" } -func (x *SendSmsReq) GetScene() int32 { +type InternalCheckCreateData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Result bool `protobuf:"varint,1,opt,name=result,proto3" json:"result,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalCheckCreateData) Reset() { + *x = InternalCheckCreateData{} + mi := &file_user_user_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalCheckCreateData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalCheckCreateData) ProtoMessage() {} + +func (x *InternalCheckCreateData) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[14] if x != nil { - return x.Scene + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InternalCheckCreateData.ProtoReflect.Descriptor instead. +func (*InternalCheckCreateData) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{14} +} + +func (x *InternalCheckCreateData) GetResult() bool { + if x != nil { + return x.Result + } + return false +} + +type InternalCheckUpdateReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Mobile string `protobuf:"bytes,2,opt,name=mobile,proto3" json:"mobile,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalCheckUpdateReq) Reset() { + *x = InternalCheckUpdateReq{} + mi := &file_user_user_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalCheckUpdateReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalCheckUpdateReq) ProtoMessage() {} + +func (x *InternalCheckUpdateReq) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[15] + 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 InternalCheckUpdateReq.ProtoReflect.Descriptor instead. +func (*InternalCheckUpdateReq) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{15} +} + +func (x *InternalCheckUpdateReq) GetUserId() int64 { + if x != nil { + return x.UserId } return 0 } +func (x *InternalCheckUpdateReq) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +type InternalCheckUpdateData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Result bool `protobuf:"varint,1,opt,name=result,proto3" json:"result,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalCheckUpdateData) Reset() { + *x = InternalCheckUpdateData{} + mi := &file_user_user_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalCheckUpdateData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalCheckUpdateData) ProtoMessage() {} + +func (x *InternalCheckUpdateData) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[16] + 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 InternalCheckUpdateData.ProtoReflect.Descriptor instead. +func (*InternalCheckUpdateData) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{16} +} + +func (x *InternalCheckUpdateData) GetResult() bool { + if x != nil { + return x.Result + } + return false +} + +type InternalUpdateReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Mobile string `protobuf:"bytes,2,opt,name=mobile,proto3" json:"mobile,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Avatar string `protobuf:"bytes,4,opt,name=avatar,proto3" json:"avatar,omitempty"` + Gender uint32 `protobuf:"varint,5,opt,name=gender,proto3" json:"gender,omitempty"` + Birthday string `protobuf:"bytes,6,opt,name=birthday,proto3" json:"birthday,omitempty"` + ClientCode []string `protobuf:"bytes,7,rep,name=client_code,json=clientCode,proto3" json:"client_code,omitempty"` + CredentialType []string `protobuf:"bytes,8,rep,name=credential_type,json=credentialType,proto3" json:"credential_type,omitempty"` + Identifier string `protobuf:"bytes,9,opt,name=identifier,proto3" json:"identifier,omitempty"` + Secret string `protobuf:"bytes,10,opt,name=secret,proto3" json:"secret,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalUpdateReq) Reset() { + *x = InternalUpdateReq{} + mi := &file_user_user_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalUpdateReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalUpdateReq) ProtoMessage() {} + +func (x *InternalUpdateReq) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[17] + 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 InternalUpdateReq.ProtoReflect.Descriptor instead. +func (*InternalUpdateReq) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{17} +} + +func (x *InternalUpdateReq) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *InternalUpdateReq) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +func (x *InternalUpdateReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *InternalUpdateReq) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *InternalUpdateReq) GetGender() uint32 { + if x != nil { + return x.Gender + } + return 0 +} + +func (x *InternalUpdateReq) GetBirthday() string { + if x != nil { + return x.Birthday + } + return "" +} + +func (x *InternalUpdateReq) GetClientCode() []string { + if x != nil { + return x.ClientCode + } + return nil +} + +func (x *InternalUpdateReq) GetCredentialType() []string { + if x != nil { + return x.CredentialType + } + return nil +} + +func (x *InternalUpdateReq) GetIdentifier() string { + if x != nil { + return x.Identifier + } + return "" +} + +func (x *InternalUpdateReq) GetSecret() string { + if x != nil { + return x.Secret + } + return "" +} + +type InternalUpdateData struct { + state protoimpl.MessageState `protogen:"open.v1"` + UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` + Mobile string `protobuf:"bytes,2,opt,name=mobile,proto3" json:"mobile,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InternalUpdateData) Reset() { + *x = InternalUpdateData{} + mi := &file_user_user_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InternalUpdateData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InternalUpdateData) ProtoMessage() {} + +func (x *InternalUpdateData) ProtoReflect() protoreflect.Message { + mi := &file_user_user_proto_msgTypes[18] + 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 InternalUpdateData.ProtoReflect.Descriptor instead. +func (*InternalUpdateData) Descriptor() ([]byte, []int) { + return file_user_user_proto_rawDescGZIP(), []int{18} +} + +func (x *InternalUpdateData) GetUserId() int64 { + if x != nil { + return x.UserId + } + return 0 +} + +func (x *InternalUpdateData) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +func (x *InternalUpdateData) GetName() string { + if x != nil { + return x.Name + } + return "" +} + type InfoReq struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -894,7 +1202,7 @@ type InfoReq struct { func (x *InfoReq) Reset() { *x = InfoReq{} - mi := &file_user_user_proto_msgTypes[14] + mi := &file_user_user_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -906,7 +1214,7 @@ func (x *InfoReq) String() string { func (*InfoReq) ProtoMessage() {} func (x *InfoReq) ProtoReflect() protoreflect.Message { - mi := &file_user_user_proto_msgTypes[14] + mi := &file_user_user_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -919,7 +1227,7 @@ func (x *InfoReq) ProtoReflect() protoreflect.Message { // Deprecated: Use InfoReq.ProtoReflect.Descriptor instead. func (*InfoReq) Descriptor() ([]byte, []int) { - return file_user_user_proto_rawDescGZIP(), []int{14} + return file_user_user_proto_rawDescGZIP(), []int{19} } var File_user_user_proto protoreflect.FileDescriptor @@ -946,26 +1254,26 @@ const file_user_user_proto_rawDesc = "" + "\x04size\x18\x03 \x01(\x05R\x04size\"7\n" + "\rUserStatusReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + - "\x06status\x18\x02 \x01(\x05R\x06status\"\x90\x02\n" + - "\x14EnsureBizIdentityReq\x12\x16\n" + + "\x06status\x18\x02 \x01(\x05R\x06status\"\x8d\x02\n" + + "\x11InternalCreateReq\x12\x16\n" + "\x06mobile\x18\x01 \x01(\tR\x06mobile\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x16\n" + "\x06avatar\x18\x03 \x01(\tR\x06avatar\x12\x16\n" + "\x06gender\x18\x04 \x01(\rR\x06gender\x12\x1a\n" + "\bbirthday\x18\x05 \x01(\tR\bbirthday\x12\x1f\n" + - "\vclient_code\x18\x06 \x01(\tR\n" + + "\vclient_code\x18\x06 \x03(\tR\n" + "clientCode\x12'\n" + - "\x0fcredential_type\x18\a \x01(\tR\x0ecredentialType\x12\x1e\n" + + "\x0fcredential_type\x18\a \x03(\tR\x0ecredentialType\x12\x1e\n" + "\n" + "identifier\x18\b \x01(\tR\n" + "identifier\x12\x16\n" + - "\x06secret\x18\t \x01(\tR\x06secret\"v\n" + - "\x15EnsureBizIdentityData\x12\x17\n" + + "\x06secret\x18\t \x01(\tR\x06secret\"s\n" + + "\x12InternalCreateData\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x18\n" + "\acreated\x18\x02 \x01(\bR\acreated\x12\x16\n" + "\x06mobile\x18\x03 \x01(\tR\x06mobile\x12\x12\n" + - "\x04name\x18\x04 \x01(\tR\x04name\"!\n" + - "\rUsersByIdsReq\x12\x10\n" + + "\x04name\x18\x04 \x01(\tR\x04name\")\n" + + "\x15InternalUsersByIdsReq\x12\x10\n" + "\x03ids\x18\x01 \x03(\x03R\x03ids\"\xaf\x01\n" + "\rUserBriefItem\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + @@ -974,38 +1282,63 @@ const file_user_user_proto_rawDesc = "" + "\x06avatar\x18\x04 \x01(\tR\x06avatar\x12\x16\n" + "\x06gender\x18\x05 \x01(\rR\x06gender\x12\x1a\n" + "\bbirthday\x18\x06 \x01(\tR\bbirthday\x12\x16\n" + - "\x06status\x18\a \x01(\rR\x06status\";\n" + - "\x0eUsersByIdsData\x12)\n" + - "\x05items\x18\x01 \x03(\v2\x13.user.UserBriefItemR\x05items\"B\n" + - "\x0fUpdateMobileReq\x12\x17\n" + + "\x06status\x18\a \x01(\rR\x06status\"C\n" + + "\x16InternalUsersByIdsData\x12)\n" + + "\x05items\x18\x01 \x03(\v2\x13.user.UserBriefItemR\x05items\"J\n" + + "\x17InternalUpdateMobileReq\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x16\n" + - "\x06mobile\x18\x02 \x01(\tR\x06mobile\"C\n" + - "\x10UpdateMobileData\x12\x17\n" + + "\x06mobile\x18\x02 \x01(\tR\x06mobile\"K\n" + + "\x18InternalUpdateMobileData\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x16\n" + - "\x06mobile\x18\x02 \x01(\tR\x06mobile\"N\n" + - "\x12RevokeBizClientReq\x12\x17\n" + + "\x06mobile\x18\x02 \x01(\tR\x06mobile\"V\n" + + "\x1aInternalRevokeBizClientReq\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x1f\n" + "\vclient_code\x18\x02 \x01(\tR\n" + - "clientCode\"/\n" + - "\x13RevokeBizClientData\x12\x18\n" + - "\arevoked\x18\x01 \x01(\bR\arevoked\":\n" + + "clientCode\"7\n" + + "\x1bInternalRevokeBizClientData\x12\x18\n" + + "\arevoked\x18\x01 \x01(\bR\arevoked\"0\n" + + "\x16InternalCheckCreateReq\x12\x16\n" + + "\x06mobile\x18\x01 \x01(\tR\x06mobile\"1\n" + + "\x17InternalCheckCreateData\x12\x16\n" + + "\x06result\x18\x01 \x01(\bR\x06result\"I\n" + + "\x16InternalCheckUpdateReq\x12\x17\n" + + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x16\n" + + "\x06mobile\x18\x02 \x01(\tR\x06mobile\"1\n" + + "\x17InternalCheckUpdateData\x12\x16\n" + + "\x06result\x18\x01 \x01(\bR\x06result\"\xa6\x02\n" + + "\x11InternalUpdateReq\x12\x17\n" + + "\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\x12\x16\n" + + "\x06avatar\x18\x04 \x01(\tR\x06avatar\x12\x16\n" + + "\x06gender\x18\x05 \x01(\rR\x06gender\x12\x1a\n" + + "\bbirthday\x18\x06 \x01(\tR\bbirthday\x12\x1f\n" + + "\vclient_code\x18\a \x03(\tR\n" + + "clientCode\x12'\n" + + "\x0fcredential_type\x18\b \x03(\tR\x0ecredentialType\x12\x1e\n" + "\n" + - "SendSmsReq\x12\x16\n" + - "\x06mobile\x18\x01 \x01(\tR\x06mobile\x12\x14\n" + - "\x05scene\x18\x02 \x01(\x05R\x05scene\"\t\n" + - "\aInfoReq2\x8d\x05\n" + - "\x04User\x12H\n" + - "\aSendSms\x12\x10.user.SendSmsReq\x1a\x0e.user.Response\"\x1b\x82\xd3\xe4\x93\x02\x15:\x01*\"\x10/api/v3/sms/send\x12A\n" + + "identifier\x18\t \x01(\tR\n" + + "identifier\x12\x16\n" + + "\x06secret\x18\n" + + " \x01(\tR\x06secret\"Y\n" + + "\x12InternalUpdateData\x12\x17\n" + + "\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" + + "\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" + "\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\x12L\n" + - "\x11EnsureBizIdentity\x12\x1a.user.EnsureBizIdentityReq\x1a\x1b.user.EnsureBizIdentityData\x127\n" + - "\n" + - "UsersByIds\x12\x13.user.UsersByIdsReq\x1a\x14.user.UsersByIdsData\x12=\n" + - "\fUpdateMobile\x12\x15.user.UpdateMobileReq\x1a\x16.user.UpdateMobileData\x12F\n" + - "\x0fRevokeBizClient\x12\x18.user.RevokeBizClientReq\x1a\x19.user.RevokeBizClientDataB\x18Z\x16lone-services/rpc/userb\x06proto3" + "UserStatus\x12\x13.user.UserStatusReq\x1a\x0e.user.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x1a\x15/admin/v3/user/status\x12C\n" + + "\x0eInternalCreate\x12\x17.user.InternalCreateReq\x1a\x18.user.InternalCreateData\x12R\n" + + "\x13InternalCheckCreate\x12\x1c.user.InternalCheckCreateReq\x1a\x1d.user.InternalCheckCreateData\x12R\n" + + "\x13InternalCheckUpdate\x12\x1c.user.InternalCheckUpdateReq\x1a\x1d.user.InternalCheckUpdateData\x12C\n" + + "\x0eInternalUpdate\x12\x17.user.InternalUpdateReq\x1a\x18.user.InternalUpdateData\x12O\n" + + "\x12InternalUsersByIds\x12\x1b.user.InternalUsersByIdsReq\x1a\x1c.user.InternalUsersByIdsData\x12U\n" + + "\x14InternalUpdateMobile\x12\x1d.user.InternalUpdateMobileReq\x1a\x1e.user.InternalUpdateMobileData\x12^\n" + + "\x17InternalRevokeBizClient\x12 .user.InternalRevokeBizClientReq\x1a!.user.InternalRevokeBizClientDataB\x18Z\x16lone-services/rpc/userb\x06proto3" var ( file_user_user_proto_rawDescOnce sync.Once @@ -1019,46 +1352,55 @@ func file_user_user_proto_rawDescGZIP() []byte { return file_user_user_proto_rawDescData } -var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 20) var file_user_user_proto_goTypes = []any{ - (*Response)(nil), // 0: user.Response - (*LoginReq)(nil), // 1: user.LoginReq - (*UserItemsReq)(nil), // 2: user.UserItemsReq - (*UserStatusReq)(nil), // 3: user.UserStatusReq - (*EnsureBizIdentityReq)(nil), // 4: user.EnsureBizIdentityReq - (*EnsureBizIdentityData)(nil), // 5: user.EnsureBizIdentityData - (*UsersByIdsReq)(nil), // 6: user.UsersByIdsReq - (*UserBriefItem)(nil), // 7: user.UserBriefItem - (*UsersByIdsData)(nil), // 8: user.UsersByIdsData - (*UpdateMobileReq)(nil), // 9: user.UpdateMobileReq - (*UpdateMobileData)(nil), // 10: user.UpdateMobileData - (*RevokeBizClientReq)(nil), // 11: user.RevokeBizClientReq - (*RevokeBizClientData)(nil), // 12: user.RevokeBizClientData - (*SendSmsReq)(nil), // 13: user.SendSmsReq - (*InfoReq)(nil), // 14: user.InfoReq + (*Response)(nil), // 0: user.Response + (*LoginReq)(nil), // 1: user.LoginReq + (*UserItemsReq)(nil), // 2: user.UserItemsReq + (*UserStatusReq)(nil), // 3: user.UserStatusReq + (*InternalCreateReq)(nil), // 4: user.InternalCreateReq + (*InternalCreateData)(nil), // 5: user.InternalCreateData + (*InternalUsersByIdsReq)(nil), // 6: user.InternalUsersByIdsReq + (*UserBriefItem)(nil), // 7: user.UserBriefItem + (*InternalUsersByIdsData)(nil), // 8: user.InternalUsersByIdsData + (*InternalUpdateMobileReq)(nil), // 9: user.InternalUpdateMobileReq + (*InternalUpdateMobileData)(nil), // 10: user.InternalUpdateMobileData + (*InternalRevokeBizClientReq)(nil), // 11: user.InternalRevokeBizClientReq + (*InternalRevokeBizClientData)(nil), // 12: user.InternalRevokeBizClientData + (*InternalCheckCreateReq)(nil), // 13: user.InternalCheckCreateReq + (*InternalCheckCreateData)(nil), // 14: user.InternalCheckCreateData + (*InternalCheckUpdateReq)(nil), // 15: user.InternalCheckUpdateReq + (*InternalCheckUpdateData)(nil), // 16: user.InternalCheckUpdateData + (*InternalUpdateReq)(nil), // 17: user.InternalUpdateReq + (*InternalUpdateData)(nil), // 18: user.InternalUpdateData + (*InfoReq)(nil), // 19: user.InfoReq } var file_user_user_proto_depIdxs = []int32{ - 7, // 0: user.UsersByIdsData.items:type_name -> user.UserBriefItem - 13, // 1: user.User.SendSms:input_type -> user.SendSmsReq - 1, // 2: user.User.Login:input_type -> user.LoginReq - 14, // 3: user.User.Info:input_type -> user.InfoReq - 2, // 4: user.User.UserItems:input_type -> user.UserItemsReq - 3, // 5: user.User.UserStatus:input_type -> user.UserStatusReq - 4, // 6: user.User.EnsureBizIdentity:input_type -> user.EnsureBizIdentityReq - 6, // 7: user.User.UsersByIds:input_type -> user.UsersByIdsReq - 9, // 8: user.User.UpdateMobile:input_type -> user.UpdateMobileReq - 11, // 9: user.User.RevokeBizClient:input_type -> user.RevokeBizClientReq - 0, // 10: user.User.SendSms:output_type -> user.Response - 0, // 11: user.User.Login:output_type -> user.Response - 0, // 12: user.User.Info:output_type -> user.Response - 0, // 13: user.User.UserItems:output_type -> user.Response - 0, // 14: user.User.UserStatus:output_type -> user.Response - 5, // 15: user.User.EnsureBizIdentity:output_type -> user.EnsureBizIdentityData - 8, // 16: user.User.UsersByIds:output_type -> user.UsersByIdsData - 10, // 17: user.User.UpdateMobile:output_type -> user.UpdateMobileData - 12, // 18: user.User.RevokeBizClient:output_type -> user.RevokeBizClientData - 10, // [10:19] is the sub-list for method output_type - 1, // [1:10] is the sub-list for method input_type + 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 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 @@ -1075,7 +1417,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: 15, + NumMessages: 20, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/user/pb/user_grpc.pb.go b/rpc/user/pb/user_grpc.pb.go index 227a6d0..f87c4ac 100644 --- a/rpc/user/pb/user_grpc.pb.go +++ b/rpc/user/pb/user_grpc.pb.go @@ -19,30 +19,34 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - User_SendSms_FullMethodName = "/user.User/SendSms" - User_Login_FullMethodName = "/user.User/Login" - User_Info_FullMethodName = "/user.User/Info" - User_UserItems_FullMethodName = "/user.User/UserItems" - User_UserStatus_FullMethodName = "/user.User/UserStatus" - User_EnsureBizIdentity_FullMethodName = "/user.User/EnsureBizIdentity" - User_UsersByIds_FullMethodName = "/user.User/UsersByIds" - User_UpdateMobile_FullMethodName = "/user.User/UpdateMobile" - User_RevokeBizClient_FullMethodName = "/user.User/RevokeBizClient" + User_Login_FullMethodName = "/user.User/Login" + User_Info_FullMethodName = "/user.User/Info" + User_UserItems_FullMethodName = "/user.User/UserItems" + User_UserStatus_FullMethodName = "/user.User/UserStatus" + User_InternalCreate_FullMethodName = "/user.User/InternalCreate" + User_InternalCheckCreate_FullMethodName = "/user.User/InternalCheckCreate" + User_InternalCheckUpdate_FullMethodName = "/user.User/InternalCheckUpdate" + User_InternalUpdate_FullMethodName = "/user.User/InternalUpdate" + User_InternalUsersByIds_FullMethodName = "/user.User/InternalUsersByIds" + User_InternalUpdateMobile_FullMethodName = "/user.User/InternalUpdateMobile" + User_InternalRevokeBizClient_FullMethodName = "/user.User/InternalRevokeBizClient" ) // UserClient is the client API for User 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 UserClient interface { - SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, 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) - EnsureBizIdentity(ctx context.Context, in *EnsureBizIdentityReq, opts ...grpc.CallOption) (*EnsureBizIdentityData, error) - UsersByIds(ctx context.Context, in *UsersByIdsReq, opts ...grpc.CallOption) (*UsersByIdsData, error) - UpdateMobile(ctx context.Context, in *UpdateMobileReq, opts ...grpc.CallOption) (*UpdateMobileData, error) - RevokeBizClient(ctx context.Context, in *RevokeBizClientReq, opts ...grpc.CallOption) (*RevokeBizClientData, error) + InternalCreate(ctx context.Context, in *InternalCreateReq, opts ...grpc.CallOption) (*InternalCreateData, error) + InternalCheckCreate(ctx context.Context, in *InternalCheckCreateReq, opts ...grpc.CallOption) (*InternalCheckCreateData, error) + InternalCheckUpdate(ctx context.Context, in *InternalCheckUpdateReq, opts ...grpc.CallOption) (*InternalCheckUpdateData, error) + InternalUpdate(ctx context.Context, in *InternalUpdateReq, opts ...grpc.CallOption) (*InternalUpdateData, error) + InternalUsersByIds(ctx context.Context, in *InternalUsersByIdsReq, opts ...grpc.CallOption) (*InternalUsersByIdsData, error) + InternalUpdateMobile(ctx context.Context, in *InternalUpdateMobileReq, opts ...grpc.CallOption) (*InternalUpdateMobileData, error) + InternalRevokeBizClient(ctx context.Context, in *InternalRevokeBizClientReq, opts ...grpc.CallOption) (*InternalRevokeBizClientData, error) } type userClient struct { @@ -53,16 +57,6 @@ func NewUserClient(cc grpc.ClientConnInterface) UserClient { return &userClient{cc} } -func (c *userClient) SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, User_SendSms_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *userClient) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -103,40 +97,70 @@ func (c *userClient) UserStatus(ctx context.Context, in *UserStatusReq, opts ... return out, nil } -func (c *userClient) EnsureBizIdentity(ctx context.Context, in *EnsureBizIdentityReq, opts ...grpc.CallOption) (*EnsureBizIdentityData, error) { +func (c *userClient) InternalCreate(ctx context.Context, in *InternalCreateReq, opts ...grpc.CallOption) (*InternalCreateData, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(EnsureBizIdentityData) - err := c.cc.Invoke(ctx, User_EnsureBizIdentity_FullMethodName, in, out, cOpts...) + out := new(InternalCreateData) + err := c.cc.Invoke(ctx, User_InternalCreate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *userClient) UsersByIds(ctx context.Context, in *UsersByIdsReq, opts ...grpc.CallOption) (*UsersByIdsData, error) { +func (c *userClient) InternalCheckCreate(ctx context.Context, in *InternalCheckCreateReq, opts ...grpc.CallOption) (*InternalCheckCreateData, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UsersByIdsData) - err := c.cc.Invoke(ctx, User_UsersByIds_FullMethodName, in, out, cOpts...) + out := new(InternalCheckCreateData) + err := c.cc.Invoke(ctx, User_InternalCheckCreate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *userClient) UpdateMobile(ctx context.Context, in *UpdateMobileReq, opts ...grpc.CallOption) (*UpdateMobileData, error) { +func (c *userClient) InternalCheckUpdate(ctx context.Context, in *InternalCheckUpdateReq, opts ...grpc.CallOption) (*InternalCheckUpdateData, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(UpdateMobileData) - err := c.cc.Invoke(ctx, User_UpdateMobile_FullMethodName, in, out, cOpts...) + out := new(InternalCheckUpdateData) + err := c.cc.Invoke(ctx, User_InternalCheckUpdate_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *userClient) RevokeBizClient(ctx context.Context, in *RevokeBizClientReq, opts ...grpc.CallOption) (*RevokeBizClientData, error) { +func (c *userClient) InternalUpdate(ctx context.Context, in *InternalUpdateReq, opts ...grpc.CallOption) (*InternalUpdateData, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(RevokeBizClientData) - err := c.cc.Invoke(ctx, User_RevokeBizClient_FullMethodName, in, out, cOpts...) + out := new(InternalUpdateData) + err := c.cc.Invoke(ctx, User_InternalUpdate_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userClient) InternalUsersByIds(ctx context.Context, in *InternalUsersByIdsReq, opts ...grpc.CallOption) (*InternalUsersByIdsData, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InternalUsersByIdsData) + err := c.cc.Invoke(ctx, User_InternalUsersByIds_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userClient) InternalUpdateMobile(ctx context.Context, in *InternalUpdateMobileReq, opts ...grpc.CallOption) (*InternalUpdateMobileData, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InternalUpdateMobileData) + err := c.cc.Invoke(ctx, User_InternalUpdateMobile_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userClient) InternalRevokeBizClient(ctx context.Context, in *InternalRevokeBizClientReq, opts ...grpc.CallOption) (*InternalRevokeBizClientData, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InternalRevokeBizClientData) + err := c.cc.Invoke(ctx, User_InternalRevokeBizClient_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -147,15 +171,17 @@ func (c *userClient) RevokeBizClient(ctx context.Context, in *RevokeBizClientReq // All implementations must embed UnimplementedUserServer // for forward compatibility. type UserServer interface { - SendSms(context.Context, *SendSmsReq) (*Response, error) Login(context.Context, *LoginReq) (*Response, error) Info(context.Context, *InfoReq) (*Response, error) UserItems(context.Context, *UserItemsReq) (*Response, error) UserStatus(context.Context, *UserStatusReq) (*Response, error) - EnsureBizIdentity(context.Context, *EnsureBizIdentityReq) (*EnsureBizIdentityData, error) - UsersByIds(context.Context, *UsersByIdsReq) (*UsersByIdsData, error) - UpdateMobile(context.Context, *UpdateMobileReq) (*UpdateMobileData, error) - RevokeBizClient(context.Context, *RevokeBizClientReq) (*RevokeBizClientData, error) + InternalCreate(context.Context, *InternalCreateReq) (*InternalCreateData, error) + InternalCheckCreate(context.Context, *InternalCheckCreateReq) (*InternalCheckCreateData, error) + InternalCheckUpdate(context.Context, *InternalCheckUpdateReq) (*InternalCheckUpdateData, error) + InternalUpdate(context.Context, *InternalUpdateReq) (*InternalUpdateData, error) + InternalUsersByIds(context.Context, *InternalUsersByIdsReq) (*InternalUsersByIdsData, error) + InternalUpdateMobile(context.Context, *InternalUpdateMobileReq) (*InternalUpdateMobileData, error) + InternalRevokeBizClient(context.Context, *InternalRevokeBizClientReq) (*InternalRevokeBizClientData, error) mustEmbedUnimplementedUserServer() } @@ -166,9 +192,6 @@ type UserServer interface { // pointer dereference when methods are called. type UnimplementedUserServer struct{} -func (UnimplementedUserServer) SendSms(context.Context, *SendSmsReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method SendSms not implemented") -} func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Login not implemented") } @@ -181,17 +204,26 @@ func (UnimplementedUserServer) UserItems(context.Context, *UserItemsReq) (*Respo func (UnimplementedUserServer) UserStatus(context.Context, *UserStatusReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method UserStatus not implemented") } -func (UnimplementedUserServer) EnsureBizIdentity(context.Context, *EnsureBizIdentityReq) (*EnsureBizIdentityData, error) { - return nil, status.Error(codes.Unimplemented, "method EnsureBizIdentity not implemented") +func (UnimplementedUserServer) InternalCreate(context.Context, *InternalCreateReq) (*InternalCreateData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalCreate not implemented") } -func (UnimplementedUserServer) UsersByIds(context.Context, *UsersByIdsReq) (*UsersByIdsData, error) { - return nil, status.Error(codes.Unimplemented, "method UsersByIds not implemented") +func (UnimplementedUserServer) InternalCheckCreate(context.Context, *InternalCheckCreateReq) (*InternalCheckCreateData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalCheckCreate not implemented") } -func (UnimplementedUserServer) UpdateMobile(context.Context, *UpdateMobileReq) (*UpdateMobileData, error) { - return nil, status.Error(codes.Unimplemented, "method UpdateMobile not implemented") +func (UnimplementedUserServer) InternalCheckUpdate(context.Context, *InternalCheckUpdateReq) (*InternalCheckUpdateData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalCheckUpdate not implemented") } -func (UnimplementedUserServer) RevokeBizClient(context.Context, *RevokeBizClientReq) (*RevokeBizClientData, error) { - return nil, status.Error(codes.Unimplemented, "method RevokeBizClient not implemented") +func (UnimplementedUserServer) InternalUpdate(context.Context, *InternalUpdateReq) (*InternalUpdateData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalUpdate not implemented") +} +func (UnimplementedUserServer) InternalUsersByIds(context.Context, *InternalUsersByIdsReq) (*InternalUsersByIdsData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalUsersByIds not implemented") +} +func (UnimplementedUserServer) InternalUpdateMobile(context.Context, *InternalUpdateMobileReq) (*InternalUpdateMobileData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalUpdateMobile not implemented") +} +func (UnimplementedUserServer) InternalRevokeBizClient(context.Context, *InternalRevokeBizClientReq) (*InternalRevokeBizClientData, error) { + return nil, status.Error(codes.Unimplemented, "method InternalRevokeBizClient not implemented") } func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {} func (UnimplementedUserServer) testEmbeddedByValue() {} @@ -214,24 +246,6 @@ func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) { s.RegisterService(&User_ServiceDesc, srv) } -func _User_SendSms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SendSmsReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).SendSms(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_SendSms_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).SendSms(ctx, req.(*SendSmsReq)) - } - return interceptor(ctx, in, info, handler) -} - func _User_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(LoginReq) if err := dec(in); err != nil { @@ -304,74 +318,128 @@ func _User_UserStatus_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _User_EnsureBizIdentity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EnsureBizIdentityReq) +func _User_InternalCreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalCreateReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(UserServer).EnsureBizIdentity(ctx, in) + return srv.(UserServer).InternalCreate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: User_EnsureBizIdentity_FullMethodName, + FullMethod: User_InternalCreate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).EnsureBizIdentity(ctx, req.(*EnsureBizIdentityReq)) + return srv.(UserServer).InternalCreate(ctx, req.(*InternalCreateReq)) } return interceptor(ctx, in, info, handler) } -func _User_UsersByIds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UsersByIdsReq) +func _User_InternalCheckCreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalCheckCreateReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(UserServer).UsersByIds(ctx, in) + return srv.(UserServer).InternalCheckCreate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: User_UsersByIds_FullMethodName, + FullMethod: User_InternalCheckCreate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).UsersByIds(ctx, req.(*UsersByIdsReq)) + return srv.(UserServer).InternalCheckCreate(ctx, req.(*InternalCheckCreateReq)) } return interceptor(ctx, in, info, handler) } -func _User_UpdateMobile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UpdateMobileReq) +func _User_InternalCheckUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalCheckUpdateReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(UserServer).UpdateMobile(ctx, in) + return srv.(UserServer).InternalCheckUpdate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: User_UpdateMobile_FullMethodName, + FullMethod: User_InternalCheckUpdate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).UpdateMobile(ctx, req.(*UpdateMobileReq)) + return srv.(UserServer).InternalCheckUpdate(ctx, req.(*InternalCheckUpdateReq)) } return interceptor(ctx, in, info, handler) } -func _User_RevokeBizClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RevokeBizClientReq) +func _User_InternalUpdate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalUpdateReq) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(UserServer).RevokeBizClient(ctx, in) + return srv.(UserServer).InternalUpdate(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: User_RevokeBizClient_FullMethodName, + FullMethod: User_InternalUpdate_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).RevokeBizClient(ctx, req.(*RevokeBizClientReq)) + return srv.(UserServer).InternalUpdate(ctx, req.(*InternalUpdateReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _User_InternalUsersByIds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalUsersByIdsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServer).InternalUsersByIds(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: User_InternalUsersByIds_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServer).InternalUsersByIds(ctx, req.(*InternalUsersByIdsReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _User_InternalUpdateMobile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalUpdateMobileReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServer).InternalUpdateMobile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: User_InternalUpdateMobile_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServer).InternalUpdateMobile(ctx, req.(*InternalUpdateMobileReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _User_InternalRevokeBizClient_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InternalRevokeBizClientReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServer).InternalRevokeBizClient(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: User_InternalRevokeBizClient_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServer).InternalRevokeBizClient(ctx, req.(*InternalRevokeBizClientReq)) } return interceptor(ctx, in, info, handler) } @@ -383,10 +451,6 @@ var User_ServiceDesc = grpc.ServiceDesc{ ServiceName: "user.User", HandlerType: (*UserServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "SendSms", - Handler: _User_SendSms_Handler, - }, { MethodName: "Login", Handler: _User_Login_Handler, @@ -404,20 +468,32 @@ var User_ServiceDesc = grpc.ServiceDesc{ Handler: _User_UserStatus_Handler, }, { - MethodName: "EnsureBizIdentity", - Handler: _User_EnsureBizIdentity_Handler, + MethodName: "InternalCreate", + Handler: _User_InternalCreate_Handler, }, { - MethodName: "UsersByIds", - Handler: _User_UsersByIds_Handler, + MethodName: "InternalCheckCreate", + Handler: _User_InternalCheckCreate_Handler, }, { - MethodName: "UpdateMobile", - Handler: _User_UpdateMobile_Handler, + MethodName: "InternalCheckUpdate", + Handler: _User_InternalCheckUpdate_Handler, }, { - MethodName: "RevokeBizClient", - Handler: _User_RevokeBizClient_Handler, + MethodName: "InternalUpdate", + Handler: _User_InternalUpdate_Handler, + }, + { + MethodName: "InternalUsersByIds", + Handler: _User_InternalUsersByIds_Handler, + }, + { + MethodName: "InternalUpdateMobile", + Handler: _User_InternalUpdateMobile_Handler, + }, + { + MethodName: "InternalRevokeBizClient", + Handler: _User_InternalRevokeBizClient_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/rpc/user/user.pb b/rpc/user/user.pb index 808ebac..517645c 100644 Binary files a/rpc/user/user.pb and b/rpc/user/user.pb differ diff --git a/rpc/user/user.proto b/rpc/user/user.proto index 1bed338..bbee50a 100644 --- a/rpc/user/user.proto +++ b/rpc/user/user.proto @@ -31,26 +31,26 @@ message UserStatusReq { int32 status = 2; } -message EnsureBizIdentityReq { +message InternalCreateReq { string mobile = 1; string name = 2; string avatar = 3; uint32 gender = 4; string birthday = 5; - string client_code = 6; - string credential_type = 7; + repeated string client_code = 6; + repeated string credential_type = 7; string identifier = 8; string secret = 9; } -message EnsureBizIdentityData { +message InternalCreateData { int64 user_id = 1; bool created = 2; string mobile = 3; string name = 4; } -message UsersByIdsReq { +message InternalUsersByIdsReq { repeated int64 ids = 1; } @@ -64,43 +64,68 @@ message UserBriefItem { uint32 status = 7; } -message UsersByIdsData { +message InternalUsersByIdsData { repeated UserBriefItem items = 1; } -message UpdateMobileReq { +message InternalUpdateMobileReq { int64 user_id = 1; string mobile = 2; } -message UpdateMobileData { +message InternalUpdateMobileData { int64 user_id = 1; string mobile = 2; } -message RevokeBizClientReq { +message InternalRevokeBizClientReq { int64 user_id = 1; string client_code = 2; } -message RevokeBizClientData { +message InternalRevokeBizClientData { bool revoked = 1; } -message SendSmsReq { +message InternalCheckCreateReq { string mobile = 1; - int32 scene = 2; +} + +message InternalCheckCreateData { + bool result = 1; +} + +message InternalCheckUpdateReq { + int64 user_id = 1; + string mobile = 2; +} + +message InternalCheckUpdateData { + bool result = 1; +} + +message InternalUpdateReq { + int64 user_id = 1; + string mobile = 2; + string name = 3; + string avatar = 4; + uint32 gender = 5; + string birthday = 6; + repeated string client_code = 7; + repeated string credential_type = 8; + string identifier = 9; + string secret = 10; +} + +message InternalUpdateData { + int64 user_id = 1; + string mobile = 2; + string name = 3; } message InfoReq {} service User { - rpc SendSms(SendSmsReq) returns (Response) { - option (google.api.http) = { - post: "/api/v3/sms/send" - body: "*" - }; - } rpc Login(LoginReq) returns (Response) { option (google.api.http) = { post: "/api/v3/login" @@ -126,8 +151,11 @@ service User { }; } - rpc EnsureBizIdentity(EnsureBizIdentityReq) returns (EnsureBizIdentityData); - rpc UsersByIds(UsersByIdsReq) returns (UsersByIdsData); - rpc UpdateMobile(UpdateMobileReq) returns (UpdateMobileData); - rpc RevokeBizClient(RevokeBizClientReq) returns (RevokeBizClientData); + rpc InternalCreate(InternalCreateReq) returns (InternalCreateData); + rpc InternalCheckCreate(InternalCheckCreateReq) returns (InternalCheckCreateData); + rpc InternalCheckUpdate(InternalCheckUpdateReq) returns (InternalCheckUpdateData); + rpc InternalUpdate(InternalUpdateReq) returns (InternalUpdateData); + rpc InternalUsersByIds(InternalUsersByIdsReq) returns (InternalUsersByIdsData); + rpc InternalUpdateMobile(InternalUpdateMobileReq) returns (InternalUpdateMobileData); + rpc InternalRevokeBizClient(InternalRevokeBizClientReq) returns (InternalRevokeBizClientData); } diff --git a/services/chore/choreclient/chore.go b/services/chore/choreclient/chore.go index 0398727..992495d 100644 --- a/services/chore/choreclient/chore.go +++ b/services/chore/choreclient/chore.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: chore.proto package choreClient @@ -24,6 +24,7 @@ type ( RegionsByIdsReq = chore.RegionsByIdsReq RegionsReq = chore.RegionsReq Response = chore.Response + SendSmsReq = chore.SendSmsReq StatusReq = chore.StatusReq SystemEditReq = chore.SystemEditReq TestReq = chore.TestReq @@ -33,6 +34,7 @@ type ( Test(ctx context.Context, in *TestReq, opts ...grpc.CallOption) (*Response, error) DecryptMobile(ctx context.Context, in *DecryptMobileReq, opts ...grpc.CallOption) (*Response, error) Regions(ctx context.Context, in *RegionsReq, opts ...grpc.CallOption) (*Response, error) + SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) AnswerItems(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) AnswerStatus(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) AnswerInfo(ctx context.Context, in *IdReq, opts ...grpc.CallOption) (*Response, error) @@ -77,6 +79,11 @@ func (m *defaultChore) Regions(ctx context.Context, in *RegionsReq, opts ...grpc return client.Regions(ctx, in, opts...) } +func (m *defaultChore) SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) { + client := chore.NewChoreClient(m.cli.Conn()) + return client.SendSms(ctx, in, opts...) +} + func (m *defaultChore) AnswerItems(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) { client := chore.NewChoreClient(m.cli.Conn()) return client.AnswerItems(ctx, in, opts...) diff --git a/services/user/internal/config/sms.go b/services/chore/internal/config/sms.go similarity index 99% rename from services/user/internal/config/sms.go rename to services/chore/internal/config/sms.go index 359e5b4..e6fc932 100644 --- a/services/user/internal/config/sms.go +++ b/services/chore/internal/config/sms.go @@ -6,7 +6,6 @@ import ( ) func NewSMS() (sms.SMS, error) { - return sms.New(sms.Config{ AccessKeyId: utils.GetConfigString("sms.accessKeyId"), AccessKeySecret: utils.GetConfigString("sms.accessKeySecret"), diff --git a/services/chore/internal/dao/sms.go b/services/chore/internal/dao/sms.go new file mode 100644 index 0000000..f0d1e36 --- /dev/null +++ b/services/chore/internal/dao/sms.go @@ -0,0 +1,9 @@ +package dao + +const ( + SmsSceneLogin int32 = 1 + SmsSceneResetPassword int32 = 2 + + SmsRateLimitSeconds = 60 + SmsCodeLength = 6 +) diff --git a/services/chore/internal/logic/response.go b/services/chore/internal/logic/response.go index 6100dec..407aeb9 100644 --- a/services/chore/internal/logic/response.go +++ b/services/chore/internal/logic/response.go @@ -22,3 +22,10 @@ func failResponse(status utils.Status) *chore.Response { Msg: status.Msg, } } + +func outResponse(status utils.Status, msg string) *chore.Response { + return &chore.Response{ + Code: status.Code, + Msg: msg, + } +} diff --git a/services/user/internal/logic/sendSmsLogic.go b/services/chore/internal/logic/sendSmsLogic.go similarity index 79% rename from services/user/internal/logic/sendSmsLogic.go rename to services/chore/internal/logic/sendSmsLogic.go index ec65892..ad8b6a8 100644 --- a/services/user/internal/logic/sendSmsLogic.go +++ b/services/chore/internal/logic/sendSmsLogic.go @@ -12,10 +12,10 @@ import ( "lone-services/pkg/sms" "lone-services/pkg/utils" "lone-services/pkg/validate" - user "lone-services/rpc/user/pb" - "lone-services/services/user/internal/dao" - "lone-services/services/user/internal/svc" - "lone-services/services/user/validator" + chore "lone-services/rpc/chore/pb" + "lone-services/services/chore/internal/dao" + "lone-services/services/chore/internal/svc" + "lone-services/services/chore/validator" "github.com/zeromicro/go-zero/core/logx" ) @@ -34,7 +34,7 @@ func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLo } } -func (l *SendSmsLogic) SendSms(in *user.SendSmsReq) (*user.Response, error) { +func (l *SendSmsLogic) SendSms(in *chore.SendSmsReq) (*chore.Response, error) { var req validator.SendSmsValidator if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { return outResponse(utils.ErrorParams, msg), nil @@ -104,27 +104,6 @@ func smsFreqRedisKey(scene int32, mobile string) string { return "sms:freq:" + strconv.Itoa(int(scene)) + ":" + mobile } -func verifyAndConsumeSmsCode(ctx context.Context, scene int32, mobile, code string) (bool, error) { - if code == utils.StringEmpty { - return false, nil - } - codeKey := smsCodeRedisKey(scene, mobile) - cached, err := redis.Client.Get(ctx, codeKey).Result() - if err == redis.Nil { - return false, nil - } - if err != nil { - return false, err - } - if cached != code { - return false, nil - } - if delErr := redis.Client.Del(ctx, codeKey).Err(); delErr != nil { - return false, delErr - } - return true, nil -} - func genDigitCode(length int) (string, error) { if length <= utils.NumberZero { return utils.StringEmpty, fmt.Errorf("invalid code length") diff --git a/services/chore/internal/logic/testLogic.go b/services/chore/internal/logic/testLogic.go index 5c2f961..c2934b5 100644 --- a/services/chore/internal/logic/testLogic.go +++ b/services/chore/internal/logic/testLogic.go @@ -2,11 +2,12 @@ package logic import ( "context" + "fmt" "lone-services/pkg/rpcclient" "lone-services/pkg/utils" chore "lone-services/rpc/chore/pb" - sale "lone-services/rpc/sale/pb" + user "lone-services/rpc/user/pb" "lone-services/services/chore/internal/svc" "github.com/zeromicro/go-zero/core/logx" @@ -32,7 +33,8 @@ func NewTestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestLogic { func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) { // cli, err := rpcclient.Get(l.svcCtx.ProductSvcName) - cli, err := rpcclient.Get(l.svcCtx.SaleSvcName) + // cli, err := rpcclient.Get(l.svcCtx.SaleSvcName) + cli, err := rpcclient.Get(l.svcCtx.UserSvcName) if err != nil { l.Errorf("get rpc: %v", err) @@ -103,10 +105,29 @@ func (l *TestLogic) Test(in *chore.TestReq) (*chore.Response, error) { // }) // ——————————————————————————————销售详情—————————————————————————————— - res, err := sale.NewSaleClient(cli.Conn()).InfoInternal(l.ctx, &sale.InfoReq{ - Id: int64(in.GetId()), - }) + // res, err := sale.NewSaleClient(cli.Conn()).InfoInternal(l.ctx, &sale.InfoReq{ + // Id: int64(in.GetId()), + // }) + // ——————————————————————————————用户创建—————————————————————————————— + // res, err := user.NewUserClient(cli.Conn()).InternalCheckCreate(l.ctx, &user.InternalCheckCreateReq{ + // Mobile: in.GetChar(), + // }) + + // res, err := user.NewUserClient(cli.Conn()).InternalCheckUpdate(l.ctx, &user.InternalCheckUpdateReq{ + // UserId: int64(in.GetId()), + // Mobile: in.GetChar(), + // }) + // fmt.Println(res.GetResult()) + + res, err := user.NewUserClient(cli.Conn()).InternalCreate(l.ctx, &user.InternalCreateReq{ + Mobile: in.GetChar(), + ClientCode: []string{"user_skin", "user_o2"}, + CredentialType: []string{"password", "sms"}, + Identifier: in.GetChar(), + Secret: "123123", + }) + fmt.Println(res) if err != nil { l.Errorf("XXXXXX: %v", err) return failResponse(utils.ErrorInternalServer), nil diff --git a/services/chore/internal/server/choreServer.go b/services/chore/internal/server/choreServer.go index e32e8f9..5a7d6e0 100644 --- a/services/chore/internal/server/choreServer.go +++ b/services/chore/internal/server/choreServer.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: chore.proto package server @@ -43,6 +43,11 @@ func (s *ChoreServer) Regions(ctx context.Context, in *chore.RegionsReq) (*chore return l.Regions(in) } +func (s *ChoreServer) SendSms(ctx context.Context, in *chore.SendSmsReq) (*chore.Response, error) { + l := logic.NewSendSmsLogic(ctx, s.svcCtx) + return l.SendSms(in) +} + func (s *ChoreServer) AnswerItems(ctx context.Context, in *chore.EmptyReq) (*chore.Response, error) { l := logic.NewAnswerItemsLogic(ctx, s.svcCtx) return l.AnswerItems(in) diff --git a/services/chore/internal/svc/servicecontext.go b/services/chore/internal/svc/servicecontext.go index 0f198b7..887631e 100644 --- a/services/chore/internal/svc/servicecontext.go +++ b/services/chore/internal/svc/servicecontext.go @@ -1,6 +1,7 @@ package svc import ( + "lone-services/pkg/sms" "lone-services/pkg/utils" "lone-services/services/chore/internal/config" @@ -13,6 +14,8 @@ type ServiceContext struct { DB *gorm.DB ProductSvcName string SaleSvcName string + UserSvcName string + SMS sms.SMS } func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext { @@ -24,11 +27,22 @@ func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext { if saleSvc == utils.StringEmpty { logx.Error("config services.sale empty") } + userSvc := utils.GetConfigString("services.user") + if userSvc == utils.StringEmpty { + logx.Error("config services.user empty") + } + + smsClient, err := config.NewSMS() + if err != nil { + logx.Errorf("sms init: %v", err) + } return &ServiceContext{ Config: c, DB: db, ProductSvcName: productSvc, SaleSvcName: saleSvc, + UserSvcName: userSvc, + SMS: smsClient, } } diff --git a/services/chore/validator/sms.go b/services/chore/validator/sms.go new file mode 100644 index 0000000..d319c04 --- /dev/null +++ b/services/chore/validator/sms.go @@ -0,0 +1,17 @@ +package validator + +import "lone-services/pkg/validate" + +type SendSmsValidator struct { + Mobile string `validate:"required,len=11"` + Scene int32 `validate:"required,oneof=1 2"` +} + +func (p SendSmsValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Mobile.required": "手机号不能为空", + "Mobile.len": "手机号格式错误", + "Scene.required": "短信场景不能为空", + "Scene.oneof": "短信场景不正确", + } +} diff --git a/services/payment/internal/logic/orderRpc.go b/services/payment/internal/logic/orderRpc.go index 52ffb21..f446493 100644 --- a/services/payment/internal/logic/orderRpc.go +++ b/services/payment/internal/logic/orderRpc.go @@ -45,12 +45,12 @@ func updateOrderPayStatus(ctx context.Context, orderSvcName, orderSn string, sta return err } client := orderpb.NewOrderClient(cli.Conn()) - _, err = client.UpdateOrderDPayStatus(ctx, &orderpb.UpdateOrderPayStatusRequest{ + _, err = client.UpdateOrderPayStatus(ctx, &orderpb.UpdateOrderPayStatusRequest{ OrderSn: orderSn, Status: int32(status), PayPrice: payPrice, RemitNo: remitNo, - Type: int32(typ), + PayType: int32(typ), }) return err } diff --git a/services/sale/internal/logic/userIdentity.go b/services/sale/internal/logic/userIdentity.go index 784970d..0c58bac 100644 --- a/services/sale/internal/logic/userIdentity.go +++ b/services/sale/internal/logic/userIdentity.go @@ -12,42 +12,42 @@ import ( const saleClientCode = "sale_beauty" -func ensureSaleIdentity(ctx context.Context, userSvcName, mobile, password string) (*userpb.EnsureBizIdentityData, error) { +func ensureSaleIdentity(ctx context.Context, userSvcName, mobile, password string) (*userpb.InternalCreateData, error) { cli, err := rpcclient.Get(userSvcName) if err != nil { return nil, err } - return userpb.NewUserClient(cli.Conn()).EnsureBizIdentity(ctx, &userpb.EnsureBizIdentityReq{ + return userpb.NewUserClient(cli.Conn()).InternalCreate(ctx, &userpb.InternalCreateReq{ Mobile: mobile, - ClientCode: saleClientCode, - CredentialType: "password", + ClientCode: []string{saleClientCode}, + CredentialType: []string{"password"}, Secret: password, }) } -func updateSaleUserMobile(ctx context.Context, userSvcName string, userId int64, mobile string) (*userpb.UpdateMobileData, error) { +func updateSaleUserMobile(ctx context.Context, userSvcName string, userId int64, mobile string) (*userpb.InternalUpdateMobileData, error) { cli, err := rpcclient.Get(userSvcName) if err != nil { return nil, err } - return userpb.NewUserClient(cli.Conn()).UpdateMobile(ctx, &userpb.UpdateMobileReq{ + return userpb.NewUserClient(cli.Conn()).InternalUpdateMobile(ctx, &userpb.InternalUpdateMobileReq{ UserId: userId, Mobile: mobile, }) } -func revokeSaleUserClient(ctx context.Context, userSvcName string, userId int64) (*userpb.RevokeBizClientData, error) { +func revokeSaleUserClient(ctx context.Context, userSvcName string, userId int64) (*userpb.InternalRevokeBizClientData, error) { cli, err := rpcclient.Get(userSvcName) if err != nil { return nil, err } - return userpb.NewUserClient(cli.Conn()).RevokeBizClient(ctx, &userpb.RevokeBizClientReq{ + return userpb.NewUserClient(cli.Conn()).InternalRevokeBizClient(ctx, &userpb.InternalRevokeBizClientReq{ UserId: userId, ClientCode: saleClientCode, }) } -func reopenSaleUserClient(ctx context.Context, userSvcName, mobile string) (*userpb.EnsureBizIdentityData, error) { +func reopenSaleUserClient(ctx context.Context, userSvcName, mobile string) (*userpb.InternalCreateData, error) { return ensureSaleIdentity(ctx, userSvcName, mobile, utils.StringEmpty) } diff --git a/services/user/internal/dao/const.go b/services/user/internal/dao/const.go index 242206e..c1eeb88 100644 --- a/services/user/internal/dao/const.go +++ b/services/user/internal/dao/const.go @@ -5,6 +5,7 @@ const ( StatusDisabled uint8 = 2 CredentialTypePassword = "password" + CredentialTypeSms = "sms" CredentialTypeWecom = "wecom" CredentialTypeOpenid = "openid" CredentialTypeUnionid = "unionid" @@ -16,9 +17,6 @@ const ( SmsSceneLogin int32 = 1 SmsSceneResetPassword int32 = 2 - SmsRateLimitSeconds = 60 - SmsCodeLength = 6 - TypeSale uint8 = 1 TypeStore uint8 = 2 TypeUser uint8 = 3 diff --git a/services/user/internal/logic/internalCheckCreateLogic.go b/services/user/internal/logic/internalCheckCreateLogic.go new file mode 100644 index 0000000..b570812 --- /dev/null +++ b/services/user/internal/logic/internalCheckCreateLogic.go @@ -0,0 +1,56 @@ +package logic + +import ( + "context" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + user "lone-services/rpc/user/pb" + "lone-services/services/user/internal/dao" + "lone-services/services/user/internal/model" + "lone-services/services/user/internal/svc" + "lone-services/services/user/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type InternalCheckCreateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInternalCheckCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalCheckCreateLogic { + return &InternalCheckCreateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InternalCheckCreateLogic) InternalCheckCreate(in *user.InternalCheckCreateReq) (*user.InternalCheckCreateData, error) { + var req validator.InternalCheckCreateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + encryptMobile, encErr := utils.EncryptPhone(req.Mobile) + if encErr != nil { + l.Errorf("internal check create encrypt: %v", encErr) + return nil, status.Error(codes.Internal, utils.ErrorEncryptAesError.Msg) + } + + var exist dao.UserRow + userModel := model.UserModel{}.Init() + if err := userModel.GetOne(modelbase.Params{ + Eq: map[string]string{"mobile": encryptMobile}, + }, &exist); err != nil { + l.Errorf("internal check create: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + + return &user.InternalCheckCreateData{Result: exist.Id < utils.NumberOne}, nil +} diff --git a/services/user/internal/logic/internalCheckUpdateLogic.go b/services/user/internal/logic/internalCheckUpdateLogic.go new file mode 100644 index 0000000..c0cdf6f --- /dev/null +++ b/services/user/internal/logic/internalCheckUpdateLogic.go @@ -0,0 +1,75 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + user "lone-services/rpc/user/pb" + "lone-services/services/user/internal/dao" + "lone-services/services/user/internal/model" + "lone-services/services/user/internal/svc" + "lone-services/services/user/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type InternalCheckUpdateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInternalCheckUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalCheckUpdateLogic { + return &InternalCheckUpdateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InternalCheckUpdateLogic) InternalCheckUpdate(in *user.InternalCheckUpdateReq) (*user.InternalCheckUpdateData, error) { + var req validator.InternalCheckUpdateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + userModel := model.UserModel{}.Init() + var row dao.UserRow + if err := userModel.GetOne(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(req.UserId, utils.NumberTen)}, + }, &row); err != nil { + l.Errorf("internal check update get user: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if row.Id < utils.NumberOne { + return nil, status.Error(codes.NotFound, utils.ErrorNotFund.Msg) + } + + encryptMobile, encErr := utils.EncryptPhone(req.Mobile) + if encErr != nil { + l.Errorf("internal check update encrypt: %v", encErr) + return nil, status.Error(codes.Internal, utils.ErrorEncryptAesError.Msg) + } + + if encryptMobile == row.Mobile { + return &user.InternalCheckUpdateData{Result: true}, nil + } + + var occupied dao.UserRow + if err := userModel.GetOne(modelbase.Params{ + Eq: map[string]string{"mobile": encryptMobile}, + }, &occupied); err != nil { + l.Errorf("internal check update: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + + if occupied.Id > utils.NumberZero && occupied.Id != row.Id { + return &user.InternalCheckUpdateData{Result: false}, nil + } + return &user.InternalCheckUpdateData{Result: true}, nil +} diff --git a/services/user/internal/logic/ensureBizIdentityLogic.go b/services/user/internal/logic/internalCreateLogic.go similarity index 63% rename from services/user/internal/logic/ensureBizIdentityLogic.go rename to services/user/internal/logic/internalCreateLogic.go index a356ef5..3f9e7a9 100644 --- a/services/user/internal/logic/ensureBizIdentityLogic.go +++ b/services/user/internal/logic/internalCreateLogic.go @@ -19,44 +19,51 @@ import ( "gorm.io/gorm" ) -type EnsureBizIdentityLogic struct { +type InternalCreateLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } -func NewEnsureBizIdentityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EnsureBizIdentityLogic { - return &EnsureBizIdentityLogic{ +func NewInternalCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalCreateLogic { + return &InternalCreateLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } -func (l *EnsureBizIdentityLogic) EnsureBizIdentity(in *user.EnsureBizIdentityReq) (*user.EnsureBizIdentityData, error) { - var req validator.EnsureBizIdentityValidator +func (l *InternalCreateLogic) InternalCreate(in *user.InternalCreateReq) (*user.InternalCreateData, error) { + var req validator.InternalCreateValidator if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { return nil, status.Error(codes.InvalidArgument, msg) } - var client dao.Client - clientModel := model.ClientModel{}.Init() - if err := clientModel.GetOne(modelbase.Params{ - Eq: map[string]string{ - "code": req.ClientCode, - "status": strconv.Itoa(int(dao.StatusEnabled)), - }, - }, &client); err != nil { - l.Errorf("ensure identity client: %v", err) - return nil, status.Error(codes.Internal, utils.Fail.Msg) + clientCodes := uniqueNonEmpty(req.ClientCode) + if len(clientCodes) == 0 { + return nil, status.Error(codes.InvalidArgument, "端编码不能为空") } - if client.Id < utils.NumberOne { - return nil, status.Error(codes.InvalidArgument, "端配置不存在或已禁用") + + clientModel := model.ClientModel{}.Init() + for _, code := range clientCodes { + var client dao.Client + if err := clientModel.GetOne(modelbase.Params{ + Eq: map[string]string{ + "code": code, + "status": strconv.Itoa(int(dao.StatusEnabled)), + }, + }, &client); err != nil { + l.Errorf("internal create client: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if client.Id < utils.NumberOne { + return nil, status.Error(codes.InvalidArgument, "端配置不存在或已禁用: "+code) + } } encryptMobile, encErr := utils.EncryptPhone(req.Mobile) if encErr != nil { - l.Errorf("ensure identity encrypt mobile: %v", encErr) + l.Errorf("internal create encrypt mobile: %v", encErr) return nil, status.Error(codes.Internal, utils.ErrorEncryptAesError.Msg) } @@ -66,6 +73,8 @@ func (l *EnsureBizIdentityLogic) EnsureBizIdentity(in *user.EnsureBizIdentityReq name = req.Name ) + credentialTypes := uniqueNonEmpty(req.CredentialType) + txErr := l.svcCtx.DB.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error { userModel := model.UserModel{}.Init() userModel.Base = userModel.Base.WithTX(tx) @@ -105,23 +114,28 @@ func (l *EnsureBizIdentityLogic) EnsureBizIdentity(in *user.EnsureBizIdentityReq created = true } - if req.CredentialType != utils.StringEmpty { - if err := ensureCredential(tx, userId, req, encryptMobile); err != nil { + for _, credType := range credentialTypes { + if err := ensureCredential(tx, userId, credType, req.Identifier, req.Secret, encryptMobile); err != nil { return err } } - return ensureUserClient(tx, userId, req.ClientCode) + for _, code := range clientCodes { + if err := ensureUserClient(tx, userId, code); err != nil { + return err + } + } + return nil }) if txErr != nil { if st, ok := status.FromError(txErr); ok { return nil, st.Err() } - l.Errorf("ensure identity tx: %v", txErr) + l.Errorf("internal create tx: %v", txErr) return nil, status.Error(codes.Internal, utils.Fail.Msg) } - return &user.EnsureBizIdentityData{ + return &user.InternalCreateData{ UserId: userId, Created: created, Mobile: encryptMobile, @@ -129,19 +143,20 @@ func (l *EnsureBizIdentityLogic) EnsureBizIdentity(in *user.EnsureBizIdentityReq }, nil } -func ensureCredential(tx *gorm.DB, userId int64, req validator.EnsureBizIdentityValidator, encryptMobile string) error { - identifier := req.Identifier +func ensureCredential(tx *gorm.DB, userId int64, credentialType, identifier, secret, encryptMobile string) error { if identifier == utils.StringEmpty { identifier = encryptMobile + } else if credentialType != dao.CredentialTypeOpenid { + identifier, _ = utils.EncryptPhone(identifier) } - secret := utils.StringEmpty - if req.Secret != utils.StringEmpty { - hashed, err := utils.EncryptPassword(req.Secret) + hashedSecret := utils.StringEmpty + if credentialType == dao.CredentialTypePassword && secret != utils.StringEmpty { + hashed, err := utils.EncryptPassword(secret) if err != nil { return err } - secret = hashed + hashedSecret = hashed } credModel := model.UserCredentialModel{}.Init() @@ -150,7 +165,7 @@ func ensureCredential(tx *gorm.DB, userId int64, req validator.EnsureBizIdentity var exist dao.UserCredential if err := credModel.GetOne(modelbase.Params{ Eq: map[string]string{ - "credential_type": req.CredentialType, + "credential_type": credentialType, "identifier": identifier, }, }, &exist); err != nil { @@ -161,13 +176,13 @@ func ensureCredential(tx *gorm.DB, userId int64, req validator.EnsureBizIdentity if exist.UserId != userId { return status.Error(codes.AlreadyExists, "登录凭证已被其他用户占用") } - if secret == utils.StringEmpty { + if hashedSecret == utils.StringEmpty { return nil } _, err := credModel.Edit(modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(exist.Id, utils.NumberTen)}, }, map[string]interface{}{ - "secret": secret, + "secret": hashedSecret, "status": dao.StatusEnabled, }) return err @@ -175,9 +190,9 @@ func ensureCredential(tx *gorm.DB, userId int64, req validator.EnsureBizIdentity return credModel.Create(&dao.UserCredential{ UserId: userId, - CredentialType: req.CredentialType, + CredentialType: credentialType, Identifier: identifier, - Secret: secret, + Secret: hashedSecret, ExtraJson: dao.ExtraJsonEmpty, Status: dao.StatusEnabled, }) @@ -213,3 +228,19 @@ func ensureUserClient(tx *gorm.DB, userId int64, clientCode string) error { OpenedAt: utils.Now(), }) } + +func uniqueNonEmpty(items []string) []string { + out := make([]string, 0, len(items)) + seen := make(map[string]struct{}, len(items)) + for _, item := range items { + if item == utils.StringEmpty { + continue + } + if _, ok := seen[item]; ok { + continue + } + seen[item] = struct{}{} + out = append(out, item) + } + return out +} diff --git a/services/user/internal/logic/revokeBizClientLogic.go b/services/user/internal/logic/internalRevokeBizClientLogic.go similarity index 66% rename from services/user/internal/logic/revokeBizClientLogic.go rename to services/user/internal/logic/internalRevokeBizClientLogic.go index 24cab10..b778fc7 100644 --- a/services/user/internal/logic/revokeBizClientLogic.go +++ b/services/user/internal/logic/internalRevokeBizClientLogic.go @@ -18,23 +18,22 @@ import ( "google.golang.org/grpc/status" ) -type RevokeBizClientLogic struct { +type InternalRevokeBizClientLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } -func NewRevokeBizClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RevokeBizClientLogic { - return &RevokeBizClientLogic{ +func NewInternalRevokeBizClientLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalRevokeBizClientLogic { + return &InternalRevokeBizClientLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } -// RevokeBizClient 内部:撤销某业务端开通(不删 users,保留其他端) -func (l *RevokeBizClientLogic) RevokeBizClient(in *user.RevokeBizClientReq) (*user.RevokeBizClientData, error) { - var req validator.RevokeBizClientValidator +func (l *InternalRevokeBizClientLogic) InternalRevokeBizClient(in *user.InternalRevokeBizClientReq) (*user.InternalRevokeBizClientData, error) { + var req validator.InternalRevokeBizClientValidator if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { return nil, status.Error(codes.InvalidArgument, msg) } @@ -47,22 +46,22 @@ func (l *RevokeBizClientLogic) RevokeBizClient(in *user.RevokeBizClientReq) (*us "client_code": req.ClientCode, }, }, &row); err != nil { - l.Errorf("revoke biz client get: %v", err) + l.Errorf("internal revoke biz client get: %v", err) return nil, status.Error(codes.Internal, utils.Fail.Msg) } if row.Id < utils.NumberOne { - return &user.RevokeBizClientData{Revoked: false}, nil + return &user.InternalRevokeBizClientData{Revoked: false}, nil } if row.Status == dao.StatusDisabled { - return &user.RevokeBizClientData{Revoked: true}, nil + return &user.InternalRevokeBizClientData{Revoked: true}, nil } if _, err := clientModel.Edit(modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(row.Id, utils.NumberTen)}, }, map[string]interface{}{"status": dao.StatusDisabled}); err != nil { - l.Errorf("revoke biz client edit: %v", err) + l.Errorf("internal revoke biz client edit: %v", err) return nil, status.Error(codes.Internal, utils.Fail.Msg) } - return &user.RevokeBizClientData{Revoked: true}, nil + return &user.InternalRevokeBizClientData{Revoked: true}, nil } diff --git a/services/user/internal/logic/internalUpdateLogic.go b/services/user/internal/logic/internalUpdateLogic.go new file mode 100644 index 0000000..70cb9fa --- /dev/null +++ b/services/user/internal/logic/internalUpdateLogic.go @@ -0,0 +1,182 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + user "lone-services/rpc/user/pb" + "lone-services/services/user/internal/dao" + "lone-services/services/user/internal/model" + "lone-services/services/user/internal/svc" + "lone-services/services/user/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "gorm.io/gorm" +) + +type InternalUpdateLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInternalUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalUpdateLogic { + return &InternalUpdateLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InternalUpdateLogic) InternalUpdate(in *user.InternalUpdateReq) (*user.InternalUpdateData, error) { + var req validator.InternalUpdateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + userModel := model.UserModel{}.Init() + var row dao.UserRow + if err := userModel.GetOne(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(req.UserId, utils.NumberTen)}, + }, &row); err != nil { + l.Errorf("internal update get user: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if row.Id < utils.NumberOne { + return nil, status.Error(codes.NotFound, utils.ErrorNotFund.Msg) + } + if row.Status == dao.StatusDisabled { + return nil, status.Error(codes.FailedPrecondition, "用户已禁用") + } + + encryptMobile, encErr := utils.EncryptPhone(req.Mobile) + if encErr != nil { + l.Errorf("internal update encrypt: %v", encErr) + return nil, status.Error(codes.Internal, utils.ErrorEncryptAesError.Msg) + } + + if encryptMobile != row.Mobile { + var occupied dao.UserRow + if err := userModel.GetOne(modelbase.Params{ + Eq: map[string]string{"mobile": encryptMobile}, + }, &occupied); err != nil { + l.Errorf("internal update unique check: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if occupied.Id > utils.NumberZero && occupied.Id != row.Id { + return nil, status.Error(codes.AlreadyExists, utils.ErrorDataIsExist.Msg) + } + } + + clientCodes := uniqueNonEmpty(req.ClientCode) + clientModel := model.ClientModel{}.Init() + for _, code := range clientCodes { + var client dao.Client + if err := clientModel.GetOne(modelbase.Params{ + Eq: map[string]string{ + "code": code, + "status": strconv.Itoa(int(dao.StatusEnabled)), + }, + }, &client); err != nil { + l.Errorf("internal update client: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if client.Id < utils.NumberOne { + return nil, status.Error(codes.InvalidArgument, "端配置不存在或已禁用: "+code) + } + } + + updates := map[string]interface{}{} + if encryptMobile != row.Mobile { + updates["mobile"] = encryptMobile + } + if req.Name != utils.StringEmpty { + updates["name"] = req.Name + } + if req.Avatar != utils.StringEmpty { + updates["avatar"] = req.Avatar + } + if req.Gender > utils.NumberZero { + updates["gender"] = uint8(req.Gender) + } + if req.Birthday != utils.StringEmpty { + birthday, bErr := utils.ParseDateOnly(req.Birthday) + if bErr != nil { + return nil, status.Error(codes.InvalidArgument, "生日格式不正确") + } + updates["birthday"] = birthday + } + + oldMobile := row.Mobile + credentialTypes := uniqueNonEmpty(req.CredentialType) + + txErr := l.svcCtx.DB.WithContext(l.ctx).Transaction(func(tx *gorm.DB) error { + um := model.UserModel{}.Init() + um.Base = um.Base.WithTX(tx) + + if len(updates) > utils.NumberZero { + if _, err := um.Edit(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(row.Id, utils.NumberTen)}, + }, updates); err != nil { + return err + } + } + + if encryptMobile != oldMobile { + credModel := model.UserCredentialModel{}.Init() + credModel.Base = credModel.Base.WithTX(tx) + var cred dao.UserCredential + if err := credModel.GetOne(modelbase.Params{ + Eq: map[string]string{ + "user_id": strconv.FormatInt(row.Id, utils.NumberTen), + "credential_type": dao.CredentialTypePassword, + "identifier": oldMobile, + }, + }, &cred); err != nil { + return err + } + if cred.Id > utils.NumberZero { + if _, err := credModel.Edit(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(cred.Id, utils.NumberTen)}, + }, map[string]interface{}{"identifier": encryptMobile}); err != nil { + return err + } + } + } + + for _, credType := range credentialTypes { + if err := ensureCredential(tx, row.Id, credType, req.Identifier, req.Secret, encryptMobile); err != nil { + return err + } + } + + for _, code := range clientCodes { + if err := ensureUserClient(tx, row.Id, code); err != nil { + return err + } + } + return nil + }) + if txErr != nil { + if st, ok := status.FromError(txErr); ok { + return nil, st.Err() + } + l.Errorf("internal update tx: %v", txErr) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + + name := row.Name + if req.Name != utils.StringEmpty { + name = req.Name + } + return &user.InternalUpdateData{ + UserId: row.Id, + Mobile: encryptMobile, + Name: name, + }, nil +} diff --git a/services/user/internal/logic/updateMobileLogic.go b/services/user/internal/logic/internalUpdateMobileLogic.go similarity index 78% rename from services/user/internal/logic/updateMobileLogic.go rename to services/user/internal/logic/internalUpdateMobileLogic.go index 6d36782..7901fe2 100644 --- a/services/user/internal/logic/updateMobileLogic.go +++ b/services/user/internal/logic/internalUpdateMobileLogic.go @@ -19,23 +19,22 @@ import ( "gorm.io/gorm" ) -type UpdateMobileLogic struct { +type InternalUpdateMobileLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } -func NewUpdateMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateMobileLogic { - return &UpdateMobileLogic{ +func NewInternalUpdateMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalUpdateMobileLogic { + return &InternalUpdateMobileLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } -// UpdateMobile 内部:修改用户手机号,并同步 password 凭证的 identifier -func (l *UpdateMobileLogic) UpdateMobile(in *user.UpdateMobileReq) (*user.UpdateMobileData, error) { - var req validator.UpdateMobileValidator +func (l *InternalUpdateMobileLogic) InternalUpdateMobile(in *user.InternalUpdateMobileReq) (*user.InternalUpdateMobileData, error) { + var req validator.InternalUpdateMobileValidator if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { return nil, status.Error(codes.InvalidArgument, msg) } @@ -45,7 +44,7 @@ func (l *UpdateMobileLogic) UpdateMobile(in *user.UpdateMobileReq) (*user.Update if err := userModel.GetOne(modelbase.Params{ Eq: map[string]string{"id": strconv.FormatInt(req.UserId, utils.NumberTen)}, }, &row); err != nil { - l.Errorf("update mobile get user: %v", err) + l.Errorf("internal update mobile get user: %v", err) return nil, status.Error(codes.Internal, utils.Fail.Msg) } if row.Id < utils.NumberOne { @@ -54,18 +53,18 @@ func (l *UpdateMobileLogic) UpdateMobile(in *user.UpdateMobileReq) (*user.Update newEncrypt, encErr := utils.EncryptPhone(req.Mobile) if encErr != nil { - l.Errorf("update mobile encrypt: %v", encErr) + l.Errorf("internal update mobile encrypt: %v", encErr) return nil, status.Error(codes.Internal, utils.ErrorEncryptAesError.Msg) } if newEncrypt == row.Mobile { - return &user.UpdateMobileData{UserId: row.Id, Mobile: row.Mobile}, nil + return &user.InternalUpdateMobileData{UserId: row.Id, Mobile: row.Mobile}, nil } var occupied dao.UserRow if err := userModel.GetOne(modelbase.Params{ Eq: map[string]string{"mobile": newEncrypt}, }, &occupied); err != nil { - l.Errorf("update mobile unique check: %v", err) + l.Errorf("internal update mobile unique check: %v", err) return nil, status.Error(codes.Internal, utils.Fail.Msg) } if occupied.Id > utils.NumberZero && occupied.Id != row.Id { @@ -103,9 +102,9 @@ func (l *UpdateMobileLogic) UpdateMobile(in *user.UpdateMobileReq) (*user.Update return err }) if txErr != nil { - l.Errorf("update mobile tx: %v", txErr) + l.Errorf("internal update mobile tx: %v", txErr) return nil, status.Error(codes.Internal, utils.Fail.Msg) } - return &user.UpdateMobileData{UserId: row.Id, Mobile: newEncrypt}, nil + return &user.InternalUpdateMobileData{UserId: row.Id, Mobile: newEncrypt}, nil } diff --git a/services/user/internal/logic/usersByIdsLogic.go b/services/user/internal/logic/internalUsersByIdsLogic.go similarity index 75% rename from services/user/internal/logic/usersByIdsLogic.go rename to services/user/internal/logic/internalUsersByIdsLogic.go index 05da653..3297dd5 100644 --- a/services/user/internal/logic/usersByIdsLogic.go +++ b/services/user/internal/logic/internalUsersByIdsLogic.go @@ -18,22 +18,22 @@ import ( "google.golang.org/grpc/status" ) -type UsersByIdsLogic struct { +type InternalUsersByIdsLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } -func NewUsersByIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsersByIdsLogic { - return &UsersByIdsLogic{ +func NewInternalUsersByIdsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InternalUsersByIdsLogic { + return &InternalUsersByIdsLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } -func (l *UsersByIdsLogic) UsersByIds(in *user.UsersByIdsReq) (*user.UsersByIdsData, error) { - var req validator.UsersByIdsValidator +func (l *InternalUsersByIdsLogic) InternalUsersByIds(in *user.InternalUsersByIdsReq) (*user.InternalUsersByIdsData, error) { + var req validator.InternalUsersByIdsValidator if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { return nil, status.Error(codes.InvalidArgument, msg) } @@ -51,7 +51,7 @@ func (l *UsersByIdsLogic) UsersByIds(in *user.UsersByIdsReq) (*user.UsersByIdsDa ids = append(ids, strconv.FormatInt(id, utils.NumberTen)) } if len(ids) < utils.NumberOne { - return &user.UsersByIdsData{Items: []*user.UserBriefItem{}}, nil + return &user.InternalUsersByIdsData{Items: []*user.UserBriefItem{}}, nil } var rows []dao.UserRow @@ -59,7 +59,7 @@ func (l *UsersByIdsLogic) UsersByIds(in *user.UsersByIdsReq) (*user.UsersByIdsDa if err := userModel.Items(modelbase.Params{ In: map[string][]string{"id": ids}, }, &rows); err != nil { - l.Errorf("users by ids: %v", err) + l.Errorf("internal users by ids: %v", err) return nil, status.Error(codes.Internal, utils.Fail.Msg) } @@ -75,5 +75,5 @@ func (l *UsersByIdsLogic) UsersByIds(in *user.UsersByIdsReq) (*user.UsersByIdsDa Status: uint32(rows[i].Status), }) } - return &user.UsersByIdsData{Items: items}, nil + return &user.InternalUsersByIdsData{Items: items}, nil } diff --git a/services/user/internal/logic/smsHelper.go b/services/user/internal/logic/smsHelper.go new file mode 100644 index 0000000..036177b --- /dev/null +++ b/services/user/internal/logic/smsHelper.go @@ -0,0 +1,34 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/redis" + "lone-services/pkg/utils" +) + +func smsCodeRedisKey(scene int32, mobile string) string { + return utils.CodeKey + strconv.Itoa(int(scene)) + ":" + mobile +} + +func verifyAndConsumeSmsCode(ctx context.Context, scene int32, mobile, code string) (bool, error) { + if code == utils.StringEmpty { + return false, nil + } + codeKey := smsCodeRedisKey(scene, mobile) + cached, err := redis.Client.Get(ctx, codeKey).Result() + if err == redis.Nil { + return false, nil + } + if err != nil { + return false, err + } + if cached != code { + return false, nil + } + if delErr := redis.Client.Del(ctx, codeKey).Err(); delErr != nil { + return false, delErr + } + return true, nil +} diff --git a/services/user/internal/server/userServer.go b/services/user/internal/server/userServer.go index d9ad6a2..2937c2c 100644 --- a/services/user/internal/server/userServer.go +++ b/services/user/internal/server/userServer.go @@ -23,11 +23,6 @@ func NewUserServer(svcCtx *svc.ServiceContext) *UserServer { } } -func (s *UserServer) SendSms(ctx context.Context, in *user.SendSmsReq) (*user.Response, error) { - l := logic.NewSendSmsLogic(ctx, s.svcCtx) - return l.SendSms(in) -} - func (s *UserServer) Login(ctx context.Context, in *user.LoginReq) (*user.Response, error) { l := logic.NewLoginLogic(ctx, s.svcCtx) return l.Login(in) @@ -48,22 +43,37 @@ func (s *UserServer) UserStatus(ctx context.Context, in *user.UserStatusReq) (*u return l.UserStatus(in) } -func (s *UserServer) EnsureBizIdentity(ctx context.Context, in *user.EnsureBizIdentityReq) (*user.EnsureBizIdentityData, error) { - l := logic.NewEnsureBizIdentityLogic(ctx, s.svcCtx) - return l.EnsureBizIdentity(in) +func (s *UserServer) InternalCreate(ctx context.Context, in *user.InternalCreateReq) (*user.InternalCreateData, error) { + l := logic.NewInternalCreateLogic(ctx, s.svcCtx) + return l.InternalCreate(in) } -func (s *UserServer) UsersByIds(ctx context.Context, in *user.UsersByIdsReq) (*user.UsersByIdsData, error) { - l := logic.NewUsersByIdsLogic(ctx, s.svcCtx) - return l.UsersByIds(in) +func (s *UserServer) InternalCheckCreate(ctx context.Context, in *user.InternalCheckCreateReq) (*user.InternalCheckCreateData, error) { + l := logic.NewInternalCheckCreateLogic(ctx, s.svcCtx) + return l.InternalCheckCreate(in) } -func (s *UserServer) UpdateMobile(ctx context.Context, in *user.UpdateMobileReq) (*user.UpdateMobileData, error) { - l := logic.NewUpdateMobileLogic(ctx, s.svcCtx) - return l.UpdateMobile(in) +func (s *UserServer) InternalCheckUpdate(ctx context.Context, in *user.InternalCheckUpdateReq) (*user.InternalCheckUpdateData, error) { + l := logic.NewInternalCheckUpdateLogic(ctx, s.svcCtx) + return l.InternalCheckUpdate(in) } -func (s *UserServer) RevokeBizClient(ctx context.Context, in *user.RevokeBizClientReq) (*user.RevokeBizClientData, error) { - l := logic.NewRevokeBizClientLogic(ctx, s.svcCtx) - return l.RevokeBizClient(in) +func (s *UserServer) InternalUpdate(ctx context.Context, in *user.InternalUpdateReq) (*user.InternalUpdateData, error) { + l := logic.NewInternalUpdateLogic(ctx, s.svcCtx) + return l.InternalUpdate(in) +} + +func (s *UserServer) InternalUsersByIds(ctx context.Context, in *user.InternalUsersByIdsReq) (*user.InternalUsersByIdsData, error) { + l := logic.NewInternalUsersByIdsLogic(ctx, s.svcCtx) + return l.InternalUsersByIds(in) +} + +func (s *UserServer) InternalUpdateMobile(ctx context.Context, in *user.InternalUpdateMobileReq) (*user.InternalUpdateMobileData, error) { + l := logic.NewInternalUpdateMobileLogic(ctx, s.svcCtx) + return l.InternalUpdateMobile(in) +} + +func (s *UserServer) InternalRevokeBizClient(ctx context.Context, in *user.InternalRevokeBizClientReq) (*user.InternalRevokeBizClientData, error) { + l := logic.NewInternalRevokeBizClientLogic(ctx, s.svcCtx) + return l.InternalRevokeBizClient(in) } diff --git a/services/user/internal/svc/servicecontext.go b/services/user/internal/svc/servicecontext.go index 8a29c16..2a11323 100644 --- a/services/user/internal/svc/servicecontext.go +++ b/services/user/internal/svc/servicecontext.go @@ -1,7 +1,6 @@ package svc import ( - "lone-services/pkg/sms" "lone-services/pkg/utils" "lone-services/services/user/internal/config" @@ -15,7 +14,6 @@ type ServiceContext struct { Prefix string JWT *config.JWTAuth SaleSvcName string - SMS sms.SMS } func NewServiceContext(c config.Config, db *gorm.DB, jwtAuth *config.JWTAuth) *ServiceContext { @@ -24,17 +22,11 @@ func NewServiceContext(c config.Config, db *gorm.DB, jwtAuth *config.JWTAuth) *S logx.Error("config services.sale empty") } - smsClient, err := config.NewSMS() - if err != nil { - logx.Errorf("sms init: %v", err) - } - return &ServiceContext{ Config: c, DB: db, Prefix: utils.GetConfigString("mysql.prefix"), JWT: jwtAuth, SaleSvcName: saleSvc, - SMS: smsClient, } } diff --git a/services/user/userClient/user.go b/services/user/userClient/user.go index 951af9c..9d21399 100644 --- a/services/user/userClient/user.go +++ b/services/user/userClient/user.go @@ -14,32 +14,39 @@ import ( ) type ( - EnsureBizIdentityData = user.EnsureBizIdentityData - EnsureBizIdentityReq = user.EnsureBizIdentityReq - InfoReq = user.InfoReq - LoginReq = user.LoginReq - Response = user.Response - RevokeBizClientData = user.RevokeBizClientData - RevokeBizClientReq = user.RevokeBizClientReq - SendSmsReq = user.SendSmsReq - UpdateMobileData = user.UpdateMobileData - UpdateMobileReq = user.UpdateMobileReq - UserBriefItem = user.UserBriefItem - UserItemsReq = user.UserItemsReq - UserStatusReq = user.UserStatusReq - UsersByIdsData = user.UsersByIdsData - UsersByIdsReq = user.UsersByIdsReq + InfoReq = user.InfoReq + InternalCheckCreateData = user.InternalCheckCreateData + InternalCheckCreateReq = user.InternalCheckCreateReq + InternalCheckUpdateData = user.InternalCheckUpdateData + InternalCheckUpdateReq = user.InternalCheckUpdateReq + InternalCreateData = user.InternalCreateData + InternalCreateReq = user.InternalCreateReq + InternalRevokeBizClientData = user.InternalRevokeBizClientData + InternalRevokeBizClientReq = user.InternalRevokeBizClientReq + InternalUpdateData = user.InternalUpdateData + InternalUpdateMobileData = user.InternalUpdateMobileData + InternalUpdateMobileReq = user.InternalUpdateMobileReq + InternalUpdateReq = user.InternalUpdateReq + InternalUsersByIdsData = user.InternalUsersByIdsData + InternalUsersByIdsReq = user.InternalUsersByIdsReq + LoginReq = user.LoginReq + Response = user.Response + UserBriefItem = user.UserBriefItem + UserItemsReq = user.UserItemsReq + UserStatusReq = user.UserStatusReq User interface { - SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, 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) - EnsureBizIdentity(ctx context.Context, in *EnsureBizIdentityReq, opts ...grpc.CallOption) (*EnsureBizIdentityData, error) - UsersByIds(ctx context.Context, in *UsersByIdsReq, opts ...grpc.CallOption) (*UsersByIdsData, error) - UpdateMobile(ctx context.Context, in *UpdateMobileReq, opts ...grpc.CallOption) (*UpdateMobileData, error) - RevokeBizClient(ctx context.Context, in *RevokeBizClientReq, opts ...grpc.CallOption) (*RevokeBizClientData, error) + InternalCreate(ctx context.Context, in *InternalCreateReq, opts ...grpc.CallOption) (*InternalCreateData, error) + InternalCheckCreate(ctx context.Context, in *InternalCheckCreateReq, opts ...grpc.CallOption) (*InternalCheckCreateData, error) + InternalCheckUpdate(ctx context.Context, in *InternalCheckUpdateReq, opts ...grpc.CallOption) (*InternalCheckUpdateData, error) + InternalUpdate(ctx context.Context, in *InternalUpdateReq, opts ...grpc.CallOption) (*InternalUpdateData, error) + InternalUsersByIds(ctx context.Context, in *InternalUsersByIdsReq, opts ...grpc.CallOption) (*InternalUsersByIdsData, error) + InternalUpdateMobile(ctx context.Context, in *InternalUpdateMobileReq, opts ...grpc.CallOption) (*InternalUpdateMobileData, error) + InternalRevokeBizClient(ctx context.Context, in *InternalRevokeBizClientReq, opts ...grpc.CallOption) (*InternalRevokeBizClientData, error) } defaultUser struct { @@ -53,11 +60,6 @@ func NewUser(cli zrpc.Client) User { } } -func (m *defaultUser) SendSms(ctx context.Context, in *SendSmsReq, opts ...grpc.CallOption) (*Response, error) { - client := user.NewUserClient(m.cli.Conn()) - return client.SendSms(ctx, in, opts...) -} - func (m *defaultUser) Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*Response, error) { client := user.NewUserClient(m.cli.Conn()) return client.Login(ctx, in, opts...) @@ -78,22 +80,37 @@ func (m *defaultUser) UserStatus(ctx context.Context, in *UserStatusReq, opts .. return client.UserStatus(ctx, in, opts...) } -func (m *defaultUser) EnsureBizIdentity(ctx context.Context, in *EnsureBizIdentityReq, opts ...grpc.CallOption) (*EnsureBizIdentityData, error) { +func (m *defaultUser) InternalCreate(ctx context.Context, in *InternalCreateReq, opts ...grpc.CallOption) (*InternalCreateData, error) { client := user.NewUserClient(m.cli.Conn()) - return client.EnsureBizIdentity(ctx, in, opts...) + return client.InternalCreate(ctx, in, opts...) } -func (m *defaultUser) UsersByIds(ctx context.Context, in *UsersByIdsReq, opts ...grpc.CallOption) (*UsersByIdsData, error) { +func (m *defaultUser) InternalCheckCreate(ctx context.Context, in *InternalCheckCreateReq, opts ...grpc.CallOption) (*InternalCheckCreateData, error) { client := user.NewUserClient(m.cli.Conn()) - return client.UsersByIds(ctx, in, opts...) + return client.InternalCheckCreate(ctx, in, opts...) } -func (m *defaultUser) UpdateMobile(ctx context.Context, in *UpdateMobileReq, opts ...grpc.CallOption) (*UpdateMobileData, error) { +func (m *defaultUser) InternalCheckUpdate(ctx context.Context, in *InternalCheckUpdateReq, opts ...grpc.CallOption) (*InternalCheckUpdateData, error) { client := user.NewUserClient(m.cli.Conn()) - return client.UpdateMobile(ctx, in, opts...) + return client.InternalCheckUpdate(ctx, in, opts...) } -func (m *defaultUser) RevokeBizClient(ctx context.Context, in *RevokeBizClientReq, opts ...grpc.CallOption) (*RevokeBizClientData, error) { +func (m *defaultUser) InternalUpdate(ctx context.Context, in *InternalUpdateReq, opts ...grpc.CallOption) (*InternalUpdateData, error) { client := user.NewUserClient(m.cli.Conn()) - return client.RevokeBizClient(ctx, in, opts...) + return client.InternalUpdate(ctx, in, opts...) +} + +func (m *defaultUser) InternalUsersByIds(ctx context.Context, in *InternalUsersByIdsReq, opts ...grpc.CallOption) (*InternalUsersByIdsData, error) { + client := user.NewUserClient(m.cli.Conn()) + return client.InternalUsersByIds(ctx, in, opts...) +} + +func (m *defaultUser) InternalUpdateMobile(ctx context.Context, in *InternalUpdateMobileReq, opts ...grpc.CallOption) (*InternalUpdateMobileData, error) { + client := user.NewUserClient(m.cli.Conn()) + return client.InternalUpdateMobile(ctx, in, opts...) +} + +func (m *defaultUser) InternalRevokeBizClient(ctx context.Context, in *InternalRevokeBizClientReq, opts ...grpc.CallOption) (*InternalRevokeBizClientData, error) { + client := user.NewUserClient(m.cli.Conn()) + return client.InternalRevokeBizClient(ctx, in, opts...) } diff --git a/services/user/validator/user.go b/services/user/validator/user.go index d3eb55c..bcffc3e 100644 --- a/services/user/validator/user.go +++ b/services/user/validator/user.go @@ -11,20 +11,6 @@ type LoginValidator struct { SmsCode string `validate:"required_if=GrantType sms,omitempty,max=8"` } -type SendSmsValidator struct { - Mobile string `validate:"required,len=11"` - Scene int32 `validate:"required,oneof=1 2"` -} - -func (p SendSmsValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{ - "Mobile.required": "手机号不能为空", - "Mobile.len": "手机号格式错误", - "Scene.required": "短信场景不能为空", - "Scene.oneof": "短信场景不正确", - } -} - func (p LoginValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ "ClientCode.required": "端编码不能为空", @@ -65,44 +51,46 @@ func (p UserStatusValidator) GetMessage() validate.ValidatorMessages { } } -type EnsureBizIdentityValidator struct { - Mobile string `validate:"required,max=20"` - Name string `validate:"omitempty,max=64"` - Avatar string `validate:"omitempty,max=255"` - Gender uint32 `validate:"omitempty,oneof=0 1 2 3"` - Birthday string `validate:"omitempty,max=12"` - ClientCode string `validate:"required,max=32"` - CredentialType string `validate:"omitempty,max=32"` - Identifier string `validate:"omitempty,max=128"` - Secret string `validate:"omitempty,max=255"` +type InternalCreateValidator struct { + Mobile string `validate:"required,max=20"` + Name string `validate:"omitempty,max=64"` + Avatar string `validate:"omitempty,max=255"` + Gender uint32 `validate:"omitempty,oneof=0 1 2 3"` + Birthday string `validate:"omitempty,max=12"` + ClientCode []string `validate:"required,min=1,dive,required,max=32"` + CredentialType []string `validate:"omitempty,dive,oneof=password sms"` + Identifier string `validate:"omitempty,max=128"` + Secret string `validate:"omitempty,max=255"` } -func (p EnsureBizIdentityValidator) GetMessage() validate.ValidatorMessages { +func (p InternalCreateValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ - "Mobile.required": "手机号不能为空", - "Mobile.max": "手机号过长", - "ClientCode.required": "端编码不能为空", - "ClientCode.max": "端编码过长", + "Mobile.required": "手机号不能为空", + "Mobile.max": "手机号过长", + "ClientCode.required": "端编码不能为空", + "ClientCode.min": "端编码不能为空", + "ClientCode.max": "端编码过长", + "CredentialType.oneof": "凭证类型不正确", } } -type UsersByIdsValidator struct { +type InternalUsersByIdsValidator struct { Ids []int64 `validate:"required,min=1,dive,gt=0"` } -func (p UsersByIdsValidator) GetMessage() validate.ValidatorMessages { +func (p InternalUsersByIdsValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ "Ids.required": "用户ID不能为空", "Ids.min": "用户ID不能为空", } } -type UpdateMobileValidator struct { +type InternalUpdateMobileValidator struct { UserId int64 `validate:"required,gt=0"` Mobile string `validate:"required,max=20"` } -func (p UpdateMobileValidator) GetMessage() validate.ValidatorMessages { +func (p InternalUpdateMobileValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ "UserId.required": "用户ID不能为空", "UserId.gt": "用户ID必须大于0", @@ -111,12 +99,12 @@ func (p UpdateMobileValidator) GetMessage() validate.ValidatorMessages { } } -type RevokeBizClientValidator struct { +type InternalRevokeBizClientValidator struct { UserId int64 `validate:"required,gt=0"` ClientCode string `validate:"required,max=32"` } -func (p RevokeBizClientValidator) GetMessage() validate.ValidatorMessages { +func (p InternalRevokeBizClientValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ "UserId.required": "用户ID不能为空", "UserId.gt": "用户ID必须大于0", @@ -124,3 +112,52 @@ func (p RevokeBizClientValidator) GetMessage() validate.ValidatorMessages { "ClientCode.max": "端编码过长", } } + +type InternalCheckCreateValidator struct { + Mobile string `validate:"required,max=20"` +} + +func (p InternalCheckCreateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Mobile.required": "手机号不能为空", + "Mobile.max": "手机号过长", + } +} + +type InternalCheckUpdateValidator struct { + UserId int64 `validate:"required,gt=0"` + Mobile string `validate:"required,max=20"` +} + +func (p InternalCheckUpdateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "UserId.required": "用户ID不能为空", + "UserId.gt": "用户ID必须大于0", + "Mobile.required": "手机号不能为空", + "Mobile.max": "手机号过长", + } +} + +type InternalUpdateValidator struct { + UserId int64 `validate:"required,gt=0"` + Mobile string `validate:"required,max=20"` + Name string `validate:"omitempty,max=64"` + Avatar string `validate:"omitempty,max=255"` + Gender uint32 `validate:"omitempty,oneof=0 1 2 3"` + Birthday string `validate:"omitempty,max=12"` + ClientCode []string `validate:"omitempty,dive,required,max=32"` + CredentialType []string `validate:"omitempty"` + Identifier string `validate:"omitempty,max=128"` + Secret string `validate:"omitempty,max=255"` +} + +func (p InternalUpdateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "UserId.required": "用户ID不能为空", + "UserId.gt": "用户ID必须大于0", + "Mobile.required": "手机号不能为空", + "Mobile.max": "手机号过长", + "ClientCode.max": "端编码过长", + "CredentialType.oneof": "凭证类型不正确", + } +}