From 0fb238cdab0b09eecb0066bd1129c6b20cbfa4ea Mon Sep 17 00:00:00 2001 From: Yehyeok Bang Date: Sat, 3 Feb 2024 16:30:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20fcm=20=ED=86=A0=ED=81=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20(gRPC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - gRPC로도 토큰을 수정할 수 있습니다. --- app/user/pb/user_pb_app.go | 21 ++- protos/user/user.pb.go | 290 +++++++++++++++++++++++++++--------- protos/user/user.proto | 18 ++- protos/user/user_grpc.pb.go | 36 +++++ 4 files changed, 287 insertions(+), 78 deletions(-) diff --git a/app/user/pb/user_pb_app.go b/app/user/pb/user_pb_app.go index 482455e..0be1759 100644 --- a/app/user/pb/user_pb_app.go +++ b/app/user/pb/user_pb_app.go @@ -27,7 +27,8 @@ func NewUserPbApp(userRepository repositories.UserRepositoryInterface, userUtil func (app *UserPbApp) Login(c context.Context, req *userpb.RequestCreateUser) (*userpb.ResponseToken, error) { user := models.User{ Name: req.Name, - Nickname: req.Nickname, + Nickname: req.Name, + FcmToken: req.FcmToken, Email: req.Email, Age: int(req.Age), Gender: req.Gender, @@ -64,6 +65,24 @@ func (app *UserPbApp) GetUserInfo(c context.Context, req *userpb.Empty) (*userpb }, nil } +func (app *UserPbApp) UpdateFcmToken(c context.Context, req *userpb.RequestUpdateFcmToken) (*userpb.ResponseUpdateFcmToken, error) { + userID := c.Value(auth.UserIDKey).(string) + + user, err := app.UserRepository.FindByID(userID) + if err != nil { + return nil, err + } + + user.FcmToken = req.FcmToken + + _, err = app.UserRepository.Update(&user) + if err != nil { + return nil, err + } + + return &userpb.ResponseUpdateFcmToken{Message: "Fcm token updated successfully"}, nil +} + func (app *UserPbApp) UpdateUserInfo(c context.Context, req *userpb.RequestUpdateUser) (*userpb.ResponseUser, error) { userID := c.Value(auth.UserIDKey).(string) diff --git a/protos/user/user.pb.go b/protos/user/user.pb.go index 98e01d9..ed1de4a 100644 --- a/protos/user/user.pb.go +++ b/protos/user/user.pb.go @@ -28,9 +28,10 @@ type User struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Nickname string `protobuf:"bytes,3,opt,name=nickname,proto3" json:"nickname,omitempty"` - Email string `protobuf:"bytes,4,opt,name=email,proto3" json:"email,omitempty"` - Age int32 `protobuf:"varint,5,opt,name=age,proto3" json:"age,omitempty"` - Gender string `protobuf:"bytes,6,opt,name=gender,proto3" json:"gender,omitempty"` + FcmToken string `protobuf:"bytes,4,opt,name=fcm_token,json=fcmToken,proto3" json:"fcm_token,omitempty"` + Email string `protobuf:"bytes,5,opt,name=email,proto3" json:"email,omitempty"` + Age int32 `protobuf:"varint,6,opt,name=age,proto3" json:"age,omitempty"` + Gender string `protobuf:"bytes,7,opt,name=gender,proto3" json:"gender,omitempty"` } func (x *User) Reset() { @@ -86,6 +87,13 @@ func (x *User) GetNickname() string { return "" } +func (x *User) GetFcmToken() string { + if x != nil { + return x.FcmToken + } + return "" +} + func (x *User) GetEmail() string { if x != nil { return x.Email @@ -113,7 +121,7 @@ type RequestCreateUser struct { unknownFields protoimpl.UnknownFields Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` // Optional + FcmToken string `protobuf:"bytes,2,opt,name=fcm_token,json=fcmToken,proto3" json:"fcm_token,omitempty"` // Optional Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` Age int32 `protobuf:"varint,4,opt,name=age,proto3" json:"age,omitempty"` // Optional Gender string `protobuf:"bytes,5,opt,name=gender,proto3" json:"gender,omitempty"` // Optional @@ -158,9 +166,9 @@ func (x *RequestCreateUser) GetName() string { return "" } -func (x *RequestCreateUser) GetNickname() string { +func (x *RequestCreateUser) GetFcmToken() string { if x != nil { - return x.Nickname + return x.FcmToken } return "" } @@ -383,6 +391,100 @@ func (x *RequestUpdateUser) GetGender() string { return "" } +type RequestUpdateFcmToken struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FcmToken string `protobuf:"bytes,1,opt,name=fcm_token,json=fcmToken,proto3" json:"fcm_token,omitempty"` +} + +func (x *RequestUpdateFcmToken) Reset() { + *x = RequestUpdateFcmToken{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_user_user_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RequestUpdateFcmToken) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RequestUpdateFcmToken) ProtoMessage() {} + +func (x *RequestUpdateFcmToken) ProtoReflect() protoreflect.Message { + mi := &file_protos_user_user_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RequestUpdateFcmToken.ProtoReflect.Descriptor instead. +func (*RequestUpdateFcmToken) Descriptor() ([]byte, []int) { + return file_protos_user_user_proto_rawDescGZIP(), []int{5} +} + +func (x *RequestUpdateFcmToken) GetFcmToken() string { + if x != nil { + return x.FcmToken + } + return "" +} + +type ResponseUpdateFcmToken struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *ResponseUpdateFcmToken) Reset() { + *x = ResponseUpdateFcmToken{} + if protoimpl.UnsafeEnabled { + mi := &file_protos_user_user_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ResponseUpdateFcmToken) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ResponseUpdateFcmToken) ProtoMessage() {} + +func (x *ResponseUpdateFcmToken) ProtoReflect() protoreflect.Message { + mi := &file_protos_user_user_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ResponseUpdateFcmToken.ProtoReflect.Descriptor instead. +func (*ResponseUpdateFcmToken) Descriptor() ([]byte, []int) { + return file_protos_user_user_proto_rawDescGZIP(), []int{6} +} + +func (x *ResponseUpdateFcmToken) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + type Empty struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -392,7 +494,7 @@ type Empty struct { func (x *Empty) Reset() { *x = Empty{} if protoimpl.UnsafeEnabled { - mi := &file_protos_user_user_proto_msgTypes[5] + mi := &file_protos_user_user_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -405,7 +507,7 @@ func (x *Empty) String() string { func (*Empty) ProtoMessage() {} func (x *Empty) ProtoReflect() protoreflect.Message { - mi := &file_protos_user_user_proto_msgTypes[5] + mi := &file_protos_user_user_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -418,65 +520,79 @@ func (x *Empty) ProtoReflect() protoreflect.Message { // Deprecated: Use Empty.ProtoReflect.Descriptor instead. func (*Empty) Descriptor() ([]byte, []int) { - return file_protos_user_user_proto_rawDescGZIP(), []int{5} + return file_protos_user_user_proto_rawDescGZIP(), []int{7} } var File_protos_user_user_proto protoreflect.FileDescriptor var file_protos_user_user_proto_rawDesc = []byte{ 0x0a, 0x16, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x75, 0x73, - 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x86, + 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0xa3, 0x01, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, - 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x10, 0x0a, - 0x03, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, - 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x83, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, - 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, - 0x61, 0x69, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x25, 0x0a, - 0x0d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, - 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x8e, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, - 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, - 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x61, - 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, - 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, - 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, - 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, - 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0xe3, 0x01, 0x0a, 0x0b, 0x55, 0x73, - 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x05, 0x4c, 0x6f, 0x67, - 0x69, 0x6e, 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x13, 0x2e, 0x75, 0x73, - 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x22, 0x00, 0x12, 0x30, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, - 0x6f, 0x12, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, - 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, - 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x1a, - 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x28, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, - 0x73, 0x65, 0x72, 0x12, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x1a, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, - 0x12, 0x5a, 0x10, 0x62, 0x61, 0x72, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x75, - 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x63, 0x6d, 0x5f, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x63, 0x6d, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x22, 0x84, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, + 0x0a, 0x09, 0x66, 0x63, 0x6d, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x66, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, + 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x25, 0x0a, 0x0d, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, + 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, + 0x65, 0x6e, 0x22, 0x8e, 0x01, 0x0a, 0x0c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, + 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, + 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x22, 0x34, + 0x0a, 0x15, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, + 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x63, 0x6d, 0x5f, 0x74, + 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x63, 0x6d, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x32, 0x0a, 0x16, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x32, 0xb2, 0x02, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x37, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x17, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x1a, 0x13, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x0b, 0x47, 0x65, + 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x0e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x17, + 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x28, 0x0a, + 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0b, 0x2e, 0x75, 0x73, + 0x65, 0x72, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x46, 0x63, 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, + 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x63, + 0x6d, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x46, 0x63, 0x6d, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x00, 0x42, 0x12, 0x5a, 0x10, 0x62, 0x61, 0x72, 0x6f, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -491,26 +607,30 @@ func file_protos_user_user_proto_rawDescGZIP() []byte { return file_protos_user_user_proto_rawDescData } -var file_protos_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_protos_user_user_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_protos_user_user_proto_goTypes = []interface{}{ - (*User)(nil), // 0: user.User - (*RequestCreateUser)(nil), // 1: user.RequestCreateUser - (*ResponseToken)(nil), // 2: user.ResponseToken - (*ResponseUser)(nil), // 3: user.ResponseUser - (*RequestUpdateUser)(nil), // 4: user.RequestUpdateUser - (*Empty)(nil), // 5: user.Empty + (*User)(nil), // 0: user.User + (*RequestCreateUser)(nil), // 1: user.RequestCreateUser + (*ResponseToken)(nil), // 2: user.ResponseToken + (*ResponseUser)(nil), // 3: user.ResponseUser + (*RequestUpdateUser)(nil), // 4: user.RequestUpdateUser + (*RequestUpdateFcmToken)(nil), // 5: user.RequestUpdateFcmToken + (*ResponseUpdateFcmToken)(nil), // 6: user.ResponseUpdateFcmToken + (*Empty)(nil), // 7: user.Empty } var file_protos_user_user_proto_depIdxs = []int32{ 1, // 0: user.UserService.Login:input_type -> user.RequestCreateUser - 5, // 1: user.UserService.GetUserInfo:input_type -> user.Empty + 7, // 1: user.UserService.GetUserInfo:input_type -> user.Empty 4, // 2: user.UserService.UpdateUserInfo:input_type -> user.RequestUpdateUser - 5, // 3: user.UserService.DeleteUser:input_type -> user.Empty - 2, // 4: user.UserService.Login:output_type -> user.ResponseToken - 3, // 5: user.UserService.GetUserInfo:output_type -> user.ResponseUser - 3, // 6: user.UserService.UpdateUserInfo:output_type -> user.ResponseUser - 5, // 7: user.UserService.DeleteUser:output_type -> user.Empty - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type + 7, // 3: user.UserService.DeleteUser:input_type -> user.Empty + 5, // 4: user.UserService.UpdateFcmToken:input_type -> user.RequestUpdateFcmToken + 2, // 5: user.UserService.Login:output_type -> user.ResponseToken + 3, // 6: user.UserService.GetUserInfo:output_type -> user.ResponseUser + 3, // 7: user.UserService.UpdateUserInfo:output_type -> user.ResponseUser + 7, // 8: user.UserService.DeleteUser:output_type -> user.Empty + 6, // 9: user.UserService.UpdateFcmToken:output_type -> user.ResponseUpdateFcmToken + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -583,6 +703,30 @@ func file_protos_user_user_proto_init() { } } file_protos_user_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RequestUpdateFcmToken); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_user_user_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ResponseUpdateFcmToken); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_protos_user_user_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Empty); i { case 0: return &v.state @@ -601,7 +745,7 @@ func file_protos_user_user_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_protos_user_user_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/protos/user/user.proto b/protos/user/user.proto index d5be720..6255904 100644 --- a/protos/user/user.proto +++ b/protos/user/user.proto @@ -8,14 +8,15 @@ message User { uint64 id = 1; string name = 2; string nickname = 3; - string email = 4; - int32 age = 5; - string gender = 6; + string fcm_token = 4; + string email = 5; + int32 age = 6; + string gender = 7; } message RequestCreateUser { string name = 1; - string nickname = 2; // Optional + string fcm_token = 2; // Optional string email = 3; int32 age = 4; // Optional string gender = 5; // Optional @@ -40,11 +41,20 @@ message RequestUpdateUser { string gender = 3; // Optional } +message RequestUpdateFcmToken { + string fcm_token = 1; +} + +message ResponseUpdateFcmToken { + string message = 1; +} + service UserService { rpc Login(RequestCreateUser) returns (ResponseToken) {} rpc GetUserInfo(Empty) returns (ResponseUser) {} rpc UpdateUserInfo(RequestUpdateUser) returns (ResponseUser) {} rpc DeleteUser(Empty) returns (Empty) {} + rpc UpdateFcmToken(RequestUpdateFcmToken) returns (ResponseUpdateFcmToken) {} } message Empty {} \ No newline at end of file diff --git a/protos/user/user_grpc.pb.go b/protos/user/user_grpc.pb.go index 2d7833a..649d6c2 100644 --- a/protos/user/user_grpc.pb.go +++ b/protos/user/user_grpc.pb.go @@ -26,6 +26,7 @@ type UserServiceClient interface { GetUserInfo(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*ResponseUser, error) UpdateUserInfo(ctx context.Context, in *RequestUpdateUser, opts ...grpc.CallOption) (*ResponseUser, error) DeleteUser(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) + UpdateFcmToken(ctx context.Context, in *RequestUpdateFcmToken, opts ...grpc.CallOption) (*ResponseUpdateFcmToken, error) } type userServiceClient struct { @@ -72,6 +73,15 @@ func (c *userServiceClient) DeleteUser(ctx context.Context, in *Empty, opts ...g return out, nil } +func (c *userServiceClient) UpdateFcmToken(ctx context.Context, in *RequestUpdateFcmToken, opts ...grpc.CallOption) (*ResponseUpdateFcmToken, error) { + out := new(ResponseUpdateFcmToken) + err := c.cc.Invoke(ctx, "/user.UserService/UpdateFcmToken", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // UserServiceServer is the server API for UserService service. // All implementations must embed UnimplementedUserServiceServer // for forward compatibility @@ -80,6 +90,7 @@ type UserServiceServer interface { GetUserInfo(context.Context, *Empty) (*ResponseUser, error) UpdateUserInfo(context.Context, *RequestUpdateUser) (*ResponseUser, error) DeleteUser(context.Context, *Empty) (*Empty, error) + UpdateFcmToken(context.Context, *RequestUpdateFcmToken) (*ResponseUpdateFcmToken, error) mustEmbedUnimplementedUserServiceServer() } @@ -99,6 +110,9 @@ func (UnimplementedUserServiceServer) UpdateUserInfo(context.Context, *RequestUp func (UnimplementedUserServiceServer) DeleteUser(context.Context, *Empty) (*Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented") } +func (UnimplementedUserServiceServer) UpdateFcmToken(context.Context, *RequestUpdateFcmToken) (*ResponseUpdateFcmToken, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateFcmToken not implemented") +} func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} // UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. @@ -184,6 +198,24 @@ func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _UserService_UpdateFcmToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RequestUpdateFcmToken) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).UpdateFcmToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/user.UserService/UpdateFcmToken", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).UpdateFcmToken(ctx, req.(*RequestUpdateFcmToken)) + } + return interceptor(ctx, in, info, handler) +} + // UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -207,6 +239,10 @@ var UserService_ServiceDesc = grpc.ServiceDesc{ MethodName: "DeleteUser", Handler: _UserService_DeleteUser_Handler, }, + { + MethodName: "UpdateFcmToken", + Handler: _UserService_UpdateFcmToken_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "protos/user/user.proto",