feat: add shared chatapp grpc proto

This commit is contained in:
ZuoZuo 2026-04-04 15:26:25 +08:00
parent 0971558d5b
commit 9a68eb0302
8 changed files with 974 additions and 1 deletions

View File

@ -19,3 +19,9 @@ Import:
```go
import common "gitea.haiyihy.com/hy/chatappcommon"
```
Proto package:
```go
import commonpb "gitea.haiyihy.com/hy/chatappcommon/proto"
```

View File

@ -1,4 +1,4 @@
// Package common provides shared code for ChatApp services.
package common
const Version = "v0.1.0"
const Version = "v0.2.0"

12
go.mod
View File

@ -1,3 +1,15 @@
module gitea.haiyihy.com/hy/chatappcommon
go 1.23.1
require (
google.golang.org/grpc v1.67.3
google.golang.org/protobuf v1.36.11
)
require (
golang.org/x/net v0.28.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
)

14
go.sum Normal file
View File

@ -0,0 +1,14 @@
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.67.3 h1:OgPcDAFKHnH8X3O4WcO4XUc8GRDeKsKReqbQtiCj7N8=
google.golang.org/grpc v1.67.3/go.mod h1:YGaHCc6Oap+FzBJTZLBzkGSYt/cvGPFTPxkn7QfSU8s=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=

660
proto/chatapp.pb.go Normal file
View File

@ -0,0 +1,660 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.34.2
// protoc v5.29.2
// source: chatapp.proto
package commonpb
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type RegisterRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
CountryCode string `protobuf:"bytes,3,opt,name=country_code,json=countryCode,proto3" json:"country_code,omitempty"`
VerifyCode string `protobuf:"bytes,4,opt,name=verify_code,json=verifyCode,proto3" json:"verify_code,omitempty"`
Nickname string `protobuf:"bytes,5,opt,name=nickname,proto3" json:"nickname,omitempty"`
DeviceId string `protobuf:"bytes,6,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty"`
Platform string `protobuf:"bytes,7,opt,name=platform,proto3" json:"platform,omitempty"`
AppVersion string `protobuf:"bytes,8,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"`
}
func (x *RegisterRequest) Reset() {
*x = RegisterRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_chatapp_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterRequest) ProtoMessage() {}
func (x *RegisterRequest) ProtoReflect() protoreflect.Message {
mi := &file_chatapp_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead.
func (*RegisterRequest) Descriptor() ([]byte, []int) {
return file_chatapp_proto_rawDescGZIP(), []int{0}
}
func (x *RegisterRequest) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *RegisterRequest) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *RegisterRequest) GetCountryCode() string {
if x != nil {
return x.CountryCode
}
return ""
}
func (x *RegisterRequest) GetVerifyCode() string {
if x != nil {
return x.VerifyCode
}
return ""
}
func (x *RegisterRequest) GetNickname() string {
if x != nil {
return x.Nickname
}
return ""
}
func (x *RegisterRequest) GetDeviceId() string {
if x != nil {
return x.DeviceId
}
return ""
}
func (x *RegisterRequest) GetPlatform() string {
if x != nil {
return x.Platform
}
return ""
}
func (x *RegisterRequest) GetAppVersion() string {
if x != nil {
return x.AppVersion
}
return ""
}
type UserProfile struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"`
AvatarUrl string `protobuf:"bytes,3,opt,name=avatar_url,json=avatarUrl,proto3" json:"avatar_url,omitempty"`
}
func (x *UserProfile) Reset() {
*x = UserProfile{}
if protoimpl.UnsafeEnabled {
mi := &file_chatapp_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserProfile) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserProfile) ProtoMessage() {}
func (x *UserProfile) ProtoReflect() protoreflect.Message {
mi := &file_chatapp_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UserProfile.ProtoReflect.Descriptor instead.
func (*UserProfile) Descriptor() ([]byte, []int) {
return file_chatapp_proto_rawDescGZIP(), []int{1}
}
func (x *UserProfile) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *UserProfile) GetNickname() string {
if x != nil {
return x.Nickname
}
return ""
}
func (x *UserProfile) GetAvatarUrl() string {
if x != nil {
return x.AvatarUrl
}
return ""
}
type RegisterResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
IsNewUser bool `protobuf:"varint,3,opt,name=is_new_user,json=isNewUser,proto3" json:"is_new_user,omitempty"`
Profile *UserProfile `protobuf:"bytes,4,opt,name=profile,proto3" json:"profile,omitempty"`
}
func (x *RegisterResponse) Reset() {
*x = RegisterResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_chatapp_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterResponse) ProtoMessage() {}
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
mi := &file_chatapp_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead.
func (*RegisterResponse) Descriptor() ([]byte, []int) {
return file_chatapp_proto_rawDescGZIP(), []int{2}
}
func (x *RegisterResponse) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *RegisterResponse) GetAccessToken() string {
if x != nil {
return x.AccessToken
}
return ""
}
func (x *RegisterResponse) GetIsNewUser() bool {
if x != nil {
return x.IsNewUser
}
return false
}
func (x *RegisterResponse) GetProfile() *UserProfile {
if x != nil {
return x.Profile
}
return nil
}
type PayRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
OrderNo string `protobuf:"bytes,1,opt,name=order_no,json=orderNo,proto3" json:"order_no,omitempty"`
UserId string `protobuf:"bytes,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
Currency string `protobuf:"bytes,4,opt,name=currency,proto3" json:"currency,omitempty"`
PayMethod string `protobuf:"bytes,5,opt,name=pay_method,json=payMethod,proto3" json:"pay_method,omitempty"`
Subject string `protobuf:"bytes,6,opt,name=subject,proto3" json:"subject,omitempty"`
}
func (x *PayRequest) Reset() {
*x = PayRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_chatapp_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PayRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PayRequest) ProtoMessage() {}
func (x *PayRequest) ProtoReflect() protoreflect.Message {
mi := &file_chatapp_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PayRequest.ProtoReflect.Descriptor instead.
func (*PayRequest) Descriptor() ([]byte, []int) {
return file_chatapp_proto_rawDescGZIP(), []int{3}
}
func (x *PayRequest) GetOrderNo() string {
if x != nil {
return x.OrderNo
}
return ""
}
func (x *PayRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *PayRequest) GetAmount() string {
if x != nil {
return x.Amount
}
return ""
}
func (x *PayRequest) GetCurrency() string {
if x != nil {
return x.Currency
}
return ""
}
func (x *PayRequest) GetPayMethod() string {
if x != nil {
return x.PayMethod
}
return ""
}
func (x *PayRequest) GetSubject() string {
if x != nil {
return x.Subject
}
return ""
}
type PayResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
PaymentId string `protobuf:"bytes,1,opt,name=payment_id,json=paymentId,proto3" json:"payment_id,omitempty"`
OrderNo string `protobuf:"bytes,2,opt,name=order_no,json=orderNo,proto3" json:"order_no,omitempty"`
UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
Amount string `protobuf:"bytes,5,opt,name=amount,proto3" json:"amount,omitempty"`
Currency string `protobuf:"bytes,6,opt,name=currency,proto3" json:"currency,omitempty"`
PayMethod string `protobuf:"bytes,7,opt,name=pay_method,json=payMethod,proto3" json:"pay_method,omitempty"`
Subject string `protobuf:"bytes,8,opt,name=subject,proto3" json:"subject,omitempty"`
CreatedAt string `protobuf:"bytes,9,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
}
func (x *PayResponse) Reset() {
*x = PayResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_chatapp_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *PayResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*PayResponse) ProtoMessage() {}
func (x *PayResponse) ProtoReflect() protoreflect.Message {
mi := &file_chatapp_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use PayResponse.ProtoReflect.Descriptor instead.
func (*PayResponse) Descriptor() ([]byte, []int) {
return file_chatapp_proto_rawDescGZIP(), []int{4}
}
func (x *PayResponse) GetPaymentId() string {
if x != nil {
return x.PaymentId
}
return ""
}
func (x *PayResponse) GetOrderNo() string {
if x != nil {
return x.OrderNo
}
return ""
}
func (x *PayResponse) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *PayResponse) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
func (x *PayResponse) GetAmount() string {
if x != nil {
return x.Amount
}
return ""
}
func (x *PayResponse) GetCurrency() string {
if x != nil {
return x.Currency
}
return ""
}
func (x *PayResponse) GetPayMethod() string {
if x != nil {
return x.PayMethod
}
return ""
}
func (x *PayResponse) GetSubject() string {
if x != nil {
return x.Subject
}
return ""
}
func (x *PayResponse) GetCreatedAt() string {
if x != nil {
return x.CreatedAt
}
return ""
}
var File_chatapp_proto protoreflect.FileDescriptor
var file_chatapp_proto_rawDesc = []byte{
0x0a, 0x0d, 0x63, 0x68, 0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x11, 0x63, 0x68, 0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e,
0x76, 0x31, 0x22, 0x81, 0x02, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x21, 0x0a, 0x0c,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x1f, 0x0a, 0x0b, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x64, 0x65,
0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09,
0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x6c, 0x61,
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x6c, 0x61,
0x74, 0x66, 0x6f, 0x72, 0x6d, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x70, 0x70, 0x5f, 0x76, 0x65, 0x72,
0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x70, 0x70, 0x56,
0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x61, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72,
0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 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, 0x1d, 0x0a, 0x0a, 0x61, 0x76,
0x61, 0x74, 0x61, 0x72, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x55, 0x72, 0x6c, 0x22, 0xa8, 0x01, 0x0a, 0x10, 0x52, 0x65,
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73,
0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61,
0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1e, 0x0a, 0x0b, 0x69, 0x73,
0x5f, 0x6e, 0x65, 0x77, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52,
0x09, 0x69, 0x73, 0x4e, 0x65, 0x77, 0x55, 0x73, 0x65, 0x72, 0x12, 0x38, 0x0a, 0x07, 0x70, 0x72,
0x6f, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x68,
0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e,
0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x07, 0x70, 0x72, 0x6f,
0x66, 0x69, 0x6c, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x0a, 0x50, 0x61, 0x79, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x6e, 0x6f, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e,
0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12,
0x1a, 0x0a, 0x08, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x70,
0x61, 0x79, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
0x09, 0x70, 0x61, 0x79, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75,
0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62,
0x6a, 0x65, 0x63, 0x74, 0x22, 0x84, 0x02, 0x0a, 0x0b, 0x50, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f,
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e,
0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x5f, 0x6e, 0x6f, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12,
0x16, 0x0a, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x75, 0x72, 0x72, 0x65,
0x6e, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x75, 0x72, 0x72, 0x65,
0x6e, 0x63, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x79, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f,
0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61, 0x79, 0x4d, 0x65, 0x74, 0x68,
0x6f, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x08, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1d, 0x0a, 0x0a,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09,
0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x32, 0x69, 0x0a, 0x12, 0x43,
0x68, 0x61, 0x74, 0x41, 0x70, 0x70, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x12, 0x53, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x22, 0x2e,
0x63, 0x68, 0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76,
0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x23, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x59, 0x0a, 0x11, 0x43, 0x68, 0x61, 0x74, 0x41, 0x70,
0x70, 0x50, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x03, 0x50,
0x61, 0x79, 0x12, 0x1d, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d,
0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1e, 0x2e, 0x63, 0x68, 0x61, 0x74, 0x61, 0x70, 0x70, 0x2e, 0x63, 0x6f, 0x6d, 0x6d,
0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x65, 0x61, 0x2e, 0x68, 0x61, 0x69, 0x79, 0x69,
0x68, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x79, 0x2f, 0x63, 0x68, 0x61, 0x74, 0x61, 0x70,
0x70, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x63, 0x6f,
0x6d, 0x6d, 0x6f, 0x6e, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_chatapp_proto_rawDescOnce sync.Once
file_chatapp_proto_rawDescData = file_chatapp_proto_rawDesc
)
func file_chatapp_proto_rawDescGZIP() []byte {
file_chatapp_proto_rawDescOnce.Do(func() {
file_chatapp_proto_rawDescData = protoimpl.X.CompressGZIP(file_chatapp_proto_rawDescData)
})
return file_chatapp_proto_rawDescData
}
var file_chatapp_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_chatapp_proto_goTypes = []any{
(*RegisterRequest)(nil), // 0: chatapp.common.v1.RegisterRequest
(*UserProfile)(nil), // 1: chatapp.common.v1.UserProfile
(*RegisterResponse)(nil), // 2: chatapp.common.v1.RegisterResponse
(*PayRequest)(nil), // 3: chatapp.common.v1.PayRequest
(*PayResponse)(nil), // 4: chatapp.common.v1.PayResponse
}
var file_chatapp_proto_depIdxs = []int32{
1, // 0: chatapp.common.v1.RegisterResponse.profile:type_name -> chatapp.common.v1.UserProfile
0, // 1: chatapp.common.v1.ChatAppUserService.Register:input_type -> chatapp.common.v1.RegisterRequest
3, // 2: chatapp.common.v1.ChatAppPayService.Pay:input_type -> chatapp.common.v1.PayRequest
2, // 3: chatapp.common.v1.ChatAppUserService.Register:output_type -> chatapp.common.v1.RegisterResponse
4, // 4: chatapp.common.v1.ChatAppPayService.Pay:output_type -> chatapp.common.v1.PayResponse
3, // [3:5] is the sub-list for method output_type
1, // [1:3] 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
}
func init() { file_chatapp_proto_init() }
func file_chatapp_proto_init() {
if File_chatapp_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_chatapp_proto_msgTypes[0].Exporter = func(v any, i int) any {
switch v := v.(*RegisterRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_chatapp_proto_msgTypes[1].Exporter = func(v any, i int) any {
switch v := v.(*UserProfile); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_chatapp_proto_msgTypes[2].Exporter = func(v any, i int) any {
switch v := v.(*RegisterResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_chatapp_proto_msgTypes[3].Exporter = func(v any, i int) any {
switch v := v.(*PayRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_chatapp_proto_msgTypes[4].Exporter = func(v any, i int) any {
switch v := v.(*PayResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_chatapp_proto_rawDesc,
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 2,
},
GoTypes: file_chatapp_proto_goTypes,
DependencyIndexes: file_chatapp_proto_depIdxs,
MessageInfos: file_chatapp_proto_msgTypes,
}.Build()
File_chatapp_proto = out.File
file_chatapp_proto_rawDesc = nil
file_chatapp_proto_goTypes = nil
file_chatapp_proto_depIdxs = nil
}

58
proto/chatapp.proto Normal file
View File

@ -0,0 +1,58 @@
syntax = "proto3";
package chatapp.common.v1;
option go_package = "gitea.haiyihy.com/hy/chatappcommon/proto;commonpb";
service ChatAppUserService {
rpc Register(RegisterRequest) returns (RegisterResponse);
}
service ChatAppPayService {
rpc Pay(PayRequest) returns (PayResponse);
}
message RegisterRequest {
string account = 1;
string password = 2;
string country_code = 3;
string verify_code = 4;
string nickname = 5;
string device_id = 6;
string platform = 7;
string app_version = 8;
}
message UserProfile {
string user_id = 1;
string nickname = 2;
string avatar_url = 3;
}
message RegisterResponse {
string user_id = 1;
string access_token = 2;
bool is_new_user = 3;
UserProfile profile = 4;
}
message PayRequest {
string order_no = 1;
string user_id = 2;
string amount = 3;
string currency = 4;
string pay_method = 5;
string subject = 6;
}
message PayResponse {
string payment_id = 1;
string order_no = 2;
string user_id = 3;
string status = 4;
string amount = 5;
string currency = 6;
string pay_method = 7;
string subject = 8;
string created_at = 9;
}

223
proto/chatapp_grpc.pb.go Normal file
View File

@ -0,0 +1,223 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v5.29.2
// source: chatapp.proto
package commonpb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
ChatAppUserService_Register_FullMethodName = "/chatapp.common.v1.ChatAppUserService/Register"
)
// ChatAppUserServiceClient is the client API for ChatAppUserService 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 ChatAppUserServiceClient interface {
Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error)
}
type chatAppUserServiceClient struct {
cc grpc.ClientConnInterface
}
func NewChatAppUserServiceClient(cc grpc.ClientConnInterface) ChatAppUserServiceClient {
return &chatAppUserServiceClient{cc}
}
func (c *chatAppUserServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RegisterResponse)
err := c.cc.Invoke(ctx, ChatAppUserService_Register_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ChatAppUserServiceServer is the server API for ChatAppUserService service.
// All implementations must embed UnimplementedChatAppUserServiceServer
// for forward compatibility.
type ChatAppUserServiceServer interface {
Register(context.Context, *RegisterRequest) (*RegisterResponse, error)
mustEmbedUnimplementedChatAppUserServiceServer()
}
// UnimplementedChatAppUserServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedChatAppUserServiceServer struct{}
func (UnimplementedChatAppUserServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (UnimplementedChatAppUserServiceServer) mustEmbedUnimplementedChatAppUserServiceServer() {}
func (UnimplementedChatAppUserServiceServer) testEmbeddedByValue() {}
// UnsafeChatAppUserServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ChatAppUserServiceServer will
// result in compilation errors.
type UnsafeChatAppUserServiceServer interface {
mustEmbedUnimplementedChatAppUserServiceServer()
}
func RegisterChatAppUserServiceServer(s grpc.ServiceRegistrar, srv ChatAppUserServiceServer) {
// If the following call pancis, it indicates UnimplementedChatAppUserServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&ChatAppUserService_ServiceDesc, srv)
}
func _ChatAppUserService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChatAppUserServiceServer).Register(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ChatAppUserService_Register_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChatAppUserServiceServer).Register(ctx, req.(*RegisterRequest))
}
return interceptor(ctx, in, info, handler)
}
// ChatAppUserService_ServiceDesc is the grpc.ServiceDesc for ChatAppUserService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var ChatAppUserService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "chatapp.common.v1.ChatAppUserService",
HandlerType: (*ChatAppUserServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _ChatAppUserService_Register_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "chatapp.proto",
}
const (
ChatAppPayService_Pay_FullMethodName = "/chatapp.common.v1.ChatAppPayService/Pay"
)
// ChatAppPayServiceClient is the client API for ChatAppPayService 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 ChatAppPayServiceClient interface {
Pay(ctx context.Context, in *PayRequest, opts ...grpc.CallOption) (*PayResponse, error)
}
type chatAppPayServiceClient struct {
cc grpc.ClientConnInterface
}
func NewChatAppPayServiceClient(cc grpc.ClientConnInterface) ChatAppPayServiceClient {
return &chatAppPayServiceClient{cc}
}
func (c *chatAppPayServiceClient) Pay(ctx context.Context, in *PayRequest, opts ...grpc.CallOption) (*PayResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(PayResponse)
err := c.cc.Invoke(ctx, ChatAppPayService_Pay_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ChatAppPayServiceServer is the server API for ChatAppPayService service.
// All implementations must embed UnimplementedChatAppPayServiceServer
// for forward compatibility.
type ChatAppPayServiceServer interface {
Pay(context.Context, *PayRequest) (*PayResponse, error)
mustEmbedUnimplementedChatAppPayServiceServer()
}
// UnimplementedChatAppPayServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedChatAppPayServiceServer struct{}
func (UnimplementedChatAppPayServiceServer) Pay(context.Context, *PayRequest) (*PayResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Pay not implemented")
}
func (UnimplementedChatAppPayServiceServer) mustEmbedUnimplementedChatAppPayServiceServer() {}
func (UnimplementedChatAppPayServiceServer) testEmbeddedByValue() {}
// UnsafeChatAppPayServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ChatAppPayServiceServer will
// result in compilation errors.
type UnsafeChatAppPayServiceServer interface {
mustEmbedUnimplementedChatAppPayServiceServer()
}
func RegisterChatAppPayServiceServer(s grpc.ServiceRegistrar, srv ChatAppPayServiceServer) {
// If the following call pancis, it indicates UnimplementedChatAppPayServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&ChatAppPayService_ServiceDesc, srv)
}
func _ChatAppPayService_Pay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(PayRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChatAppPayServiceServer).Pay(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ChatAppPayService_Pay_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChatAppPayServiceServer).Pay(ctx, req.(*PayRequest))
}
return interceptor(ctx, in, info, handler)
}
// ChatAppPayService_ServiceDesc is the grpc.ServiceDesc for ChatAppPayService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var ChatAppPayService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "chatapp.common.v1.ChatAppPayService",
HandlerType: (*ChatAppPayServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Pay",
Handler: _ChatAppPayService_Pay_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "chatapp.proto",
}

View File