Realm Member GRPC

This commit is contained in:
LittleSheep 2024-05-04 10:53:24 +08:00
parent 854a50f63f
commit db1849933f
5 changed files with 414 additions and 46 deletions

15
.idea/workspace.xml generated
View File

@ -4,14 +4,12 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Realm in passport">
<change afterPath="$PROJECT_DIR$/pkg/grpc/proto/realms.proto" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pkg/grpc/realms.go" afterDir="false" />
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Realm GRPC">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/friendships.proto" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/friendships.proto" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/server.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/server/realms_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/realms_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/services/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/services/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/realms.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/realms.pb.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/realms.proto" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/realms.proto" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/proto/realms_grpc.pb.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/proto/realms_grpc.pb.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/grpc/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/realms.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -147,7 +145,8 @@
<MESSAGE value=":sparkles: Batch mark notify as read API" />
<MESSAGE value=":bug: Bug fixes of risk detection&#10;:lipstick: Optimized UI" />
<MESSAGE value=":sparkles: Realm in passport" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Realm in passport" />
<MESSAGE value=":sparkles: Realm GRPC" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Realm GRPC" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>

View File

@ -265,6 +265,171 @@ func (x *ListRealmResponse) GetData() []*RealmResponse {
return nil
}
type RealmMemberLookupRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RealmId uint64 `protobuf:"varint,1,opt,name=realm_id,json=realmId,proto3" json:"realm_id,omitempty"`
UserId *uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
}
func (x *RealmMemberLookupRequest) Reset() {
*x = RealmMemberLookupRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmMemberLookupRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmMemberLookupRequest) ProtoMessage() {}
func (x *RealmMemberLookupRequest) ProtoReflect() protoreflect.Message {
mi := &file_realms_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 RealmMemberLookupRequest.ProtoReflect.Descriptor instead.
func (*RealmMemberLookupRequest) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{4}
}
func (x *RealmMemberLookupRequest) GetRealmId() uint64 {
if x != nil {
return x.RealmId
}
return 0
}
func (x *RealmMemberLookupRequest) GetUserId() uint64 {
if x != nil && x.UserId != nil {
return *x.UserId
}
return 0
}
type RealmMemberResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
RealmId uint64 `protobuf:"varint,1,opt,name=realm_id,json=realmId,proto3" json:"realm_id,omitempty"`
UserId uint64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
PowerLevel int32 `protobuf:"varint,3,opt,name=power_level,json=powerLevel,proto3" json:"power_level,omitempty"`
}
func (x *RealmMemberResponse) Reset() {
*x = RealmMemberResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RealmMemberResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RealmMemberResponse) ProtoMessage() {}
func (x *RealmMemberResponse) ProtoReflect() protoreflect.Message {
mi := &file_realms_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 RealmMemberResponse.ProtoReflect.Descriptor instead.
func (*RealmMemberResponse) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{5}
}
func (x *RealmMemberResponse) GetRealmId() uint64 {
if x != nil {
return x.RealmId
}
return 0
}
func (x *RealmMemberResponse) GetUserId() uint64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *RealmMemberResponse) GetPowerLevel() int32 {
if x != nil {
return x.PowerLevel
}
return 0
}
type ListRealmMemberResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Data []*RealmMemberResponse `protobuf:"bytes,1,rep,name=data,proto3" json:"data,omitempty"`
}
func (x *ListRealmMemberResponse) Reset() {
*x = ListRealmMemberResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_realms_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListRealmMemberResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListRealmMemberResponse) ProtoMessage() {}
func (x *ListRealmMemberResponse) ProtoReflect() protoreflect.Message {
mi := &file_realms_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 ListRealmMemberResponse.ProtoReflect.Descriptor instead.
func (*ListRealmMemberResponse) Descriptor() ([]byte, []int) {
return file_realms_proto_rawDescGZIP(), []int{6}
}
func (x *ListRealmMemberResponse) GetData() []*RealmMemberResponse {
if x != nil {
return x.Data
}
return nil
}
var File_realms_proto protoreflect.FileDescriptor
var file_realms_proto_rawDesc = []byte{
@ -300,28 +465,56 @@ var file_realms_proto_rawDesc = []byte{
0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0xb7, 0x02, 0x0a, 0x06, 0x52, 0x65, 0x61, 0x6c,
0x6d, 0x73, 0x12, 0x48, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e,
0x69, 0x74, 0x79, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79,
0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61,
0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x12,
0x4c, 0x69, 0x73, 0x74, 0x41, 0x76, 0x61, 0x69, 0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x61,
0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x4f, 0x0a, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x77, 0x6e, 0x65, 0x64, 0x52, 0x65,
0x61, 0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c,
0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c,
0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x3d, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x19,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b,
0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x5f, 0x0a, 0x18, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x64, 0x12, 0x1c,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x48,
0x00, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08,
0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x22, 0x6a, 0x0a, 0x13, 0x52, 0x65, 0x61, 0x6c,
0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x19, 0x0a, 0x08, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
0x04, 0x52, 0x07, 0x72, 0x65, 0x61, 0x6c, 0x6d, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73,
0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x75, 0x73, 0x65,
0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76,
0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x4c,
0x65, 0x76, 0x65, 0x6c, 0x22, 0x49, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c,
0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x2e, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65,
0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32,
0xde, 0x03, 0x0a, 0x06, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x73, 0x12, 0x48, 0x0a, 0x12, 0x4c, 0x69,
0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x00, 0x12, 0x53, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x76, 0x61, 0x69,
0x6c, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57, 0x69,
0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4f, 0x0a, 0x0e, 0x4c, 0x69, 0x73,
0x74, 0x4f, 0x77, 0x6e, 0x65, 0x64, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x21, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x57,
0x69, 0x74, 0x68, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x08, 0x47, 0x65,
0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52,
0x65, 0x61, 0x6c, 0x6d, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x54, 0x0a, 0x0f, 0x4c, 0x69, 0x73,
0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x4f, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d, 0x65, 0x6d, 0x62, 0x65,
0x72, 0x12, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d, 0x4d,
0x65, 0x6d, 0x62, 0x65, 0x72, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x6d,
0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x42, 0x09, 0x5a, 0x07, 0x2e, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
@ -336,29 +529,37 @@ func file_realms_proto_rawDescGZIP() []byte {
return file_realms_proto_rawDescData
}
var file_realms_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_realms_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
var file_realms_proto_goTypes = []interface{}{
(*RealmLookupWithUserRequest)(nil), // 0: proto.RealmLookupWithUserRequest
(*RealmLookupRequest)(nil), // 1: proto.RealmLookupRequest
(*RealmResponse)(nil), // 2: proto.RealmResponse
(*ListRealmResponse)(nil), // 3: proto.ListRealmResponse
(*emptypb.Empty)(nil), // 4: google.protobuf.Empty
(*RealmMemberLookupRequest)(nil), // 4: proto.RealmMemberLookupRequest
(*RealmMemberResponse)(nil), // 5: proto.RealmMemberResponse
(*ListRealmMemberResponse)(nil), // 6: proto.ListRealmMemberResponse
(*emptypb.Empty)(nil), // 7: google.protobuf.Empty
}
var file_realms_proto_depIdxs = []int32{
2, // 0: proto.ListRealmResponse.data:type_name -> proto.RealmResponse
4, // 1: proto.Realms.ListCommunityRealm:input_type -> google.protobuf.Empty
0, // 2: proto.Realms.ListAvailableRealm:input_type -> proto.RealmLookupWithUserRequest
0, // 3: proto.Realms.ListOwnedRealm:input_type -> proto.RealmLookupWithUserRequest
1, // 4: proto.Realms.GetRealm:input_type -> proto.RealmLookupRequest
3, // 5: proto.Realms.ListCommunityRealm:output_type -> proto.ListRealmResponse
3, // 6: proto.Realms.ListAvailableRealm:output_type -> proto.ListRealmResponse
3, // 7: proto.Realms.ListOwnedRealm:output_type -> proto.ListRealmResponse
2, // 8: proto.Realms.GetRealm:output_type -> proto.RealmResponse
5, // [5:9] is the sub-list for method output_type
1, // [1:5] 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
5, // 1: proto.ListRealmMemberResponse.data:type_name -> proto.RealmMemberResponse
7, // 2: proto.Realms.ListCommunityRealm:input_type -> google.protobuf.Empty
0, // 3: proto.Realms.ListAvailableRealm:input_type -> proto.RealmLookupWithUserRequest
0, // 4: proto.Realms.ListOwnedRealm:input_type -> proto.RealmLookupWithUserRequest
1, // 5: proto.Realms.GetRealm:input_type -> proto.RealmLookupRequest
4, // 6: proto.Realms.ListRealmMember:input_type -> proto.RealmMemberLookupRequest
4, // 7: proto.Realms.GetRealmMember:input_type -> proto.RealmMemberLookupRequest
3, // 8: proto.Realms.ListCommunityRealm:output_type -> proto.ListRealmResponse
3, // 9: proto.Realms.ListAvailableRealm:output_type -> proto.ListRealmResponse
3, // 10: proto.Realms.ListOwnedRealm:output_type -> proto.ListRealmResponse
2, // 11: proto.Realms.GetRealm:output_type -> proto.RealmResponse
6, // 12: proto.Realms.ListRealmMember:output_type -> proto.ListRealmMemberResponse
5, // 13: proto.Realms.GetRealmMember:output_type -> proto.RealmMemberResponse
8, // [8:14] is the sub-list for method output_type
2, // [2:8] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_realms_proto_init() }
@ -415,15 +616,52 @@ func file_realms_proto_init() {
return nil
}
}
file_realms_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RealmMemberLookupRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RealmMemberResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_realms_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListRealmMemberResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_realms_proto_msgTypes[1].OneofWrappers = []interface{}{}
file_realms_proto_msgTypes[4].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_realms_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 7,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -11,6 +11,8 @@ service Realms {
rpc ListAvailableRealm(RealmLookupWithUserRequest) returns (ListRealmResponse) {}
rpc ListOwnedRealm(RealmLookupWithUserRequest) returns (ListRealmResponse) {}
rpc GetRealm(RealmLookupRequest) returns (RealmResponse) {}
rpc ListRealmMember(RealmMemberLookupRequest) returns (ListRealmMemberResponse) {}
rpc GetRealmMember(RealmMemberLookupRequest) returns (RealmMemberResponse) {}
}
message RealmLookupWithUserRequest {
@ -34,4 +36,19 @@ message RealmResponse {
message ListRealmResponse {
repeated RealmResponse data = 1;
}
message RealmMemberLookupRequest {
uint64 realm_id = 1;
optional uint64 user_id = 2;
}
message RealmMemberResponse {
uint64 realm_id = 1;
uint64 user_id = 2;
int32 power_level = 3;
}
message ListRealmMemberResponse {
repeated RealmMemberResponse data = 1;
}

View File

@ -24,6 +24,8 @@ const (
Realms_ListAvailableRealm_FullMethodName = "/proto.Realms/ListAvailableRealm"
Realms_ListOwnedRealm_FullMethodName = "/proto.Realms/ListOwnedRealm"
Realms_GetRealm_FullMethodName = "/proto.Realms/GetRealm"
Realms_ListRealmMember_FullMethodName = "/proto.Realms/ListRealmMember"
Realms_GetRealmMember_FullMethodName = "/proto.Realms/GetRealmMember"
)
// RealmsClient is the client API for Realms service.
@ -34,6 +36,8 @@ type RealmsClient interface {
ListAvailableRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
ListOwnedRealm(ctx context.Context, in *RealmLookupWithUserRequest, opts ...grpc.CallOption) (*ListRealmResponse, error)
GetRealm(ctx context.Context, in *RealmLookupRequest, opts ...grpc.CallOption) (*RealmResponse, error)
ListRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*ListRealmMemberResponse, error)
GetRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*RealmMemberResponse, error)
}
type realmsClient struct {
@ -80,6 +84,24 @@ func (c *realmsClient) GetRealm(ctx context.Context, in *RealmLookupRequest, opt
return out, nil
}
func (c *realmsClient) ListRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*ListRealmMemberResponse, error) {
out := new(ListRealmMemberResponse)
err := c.cc.Invoke(ctx, Realms_ListRealmMember_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *realmsClient) GetRealmMember(ctx context.Context, in *RealmMemberLookupRequest, opts ...grpc.CallOption) (*RealmMemberResponse, error) {
out := new(RealmMemberResponse)
err := c.cc.Invoke(ctx, Realms_GetRealmMember_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RealmsServer is the server API for Realms service.
// All implementations must embed UnimplementedRealmsServer
// for forward compatibility
@ -88,6 +110,8 @@ type RealmsServer interface {
ListAvailableRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error)
ListOwnedRealm(context.Context, *RealmLookupWithUserRequest) (*ListRealmResponse, error)
GetRealm(context.Context, *RealmLookupRequest) (*RealmResponse, error)
ListRealmMember(context.Context, *RealmMemberLookupRequest) (*ListRealmMemberResponse, error)
GetRealmMember(context.Context, *RealmMemberLookupRequest) (*RealmMemberResponse, error)
mustEmbedUnimplementedRealmsServer()
}
@ -107,6 +131,12 @@ func (UnimplementedRealmsServer) ListOwnedRealm(context.Context, *RealmLookupWit
func (UnimplementedRealmsServer) GetRealm(context.Context, *RealmLookupRequest) (*RealmResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRealm not implemented")
}
func (UnimplementedRealmsServer) ListRealmMember(context.Context, *RealmMemberLookupRequest) (*ListRealmMemberResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListRealmMember not implemented")
}
func (UnimplementedRealmsServer) GetRealmMember(context.Context, *RealmMemberLookupRequest) (*RealmMemberResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetRealmMember not implemented")
}
func (UnimplementedRealmsServer) mustEmbedUnimplementedRealmsServer() {}
// UnsafeRealmsServer may be embedded to opt out of forward compatibility for this service.
@ -192,6 +222,42 @@ func _Realms_GetRealm_Handler(srv interface{}, ctx context.Context, dec func(int
return interceptor(ctx, in, info, handler)
}
func _Realms_ListRealmMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmMemberLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).ListRealmMember(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_ListRealmMember_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).ListRealmMember(ctx, req.(*RealmMemberLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Realms_GetRealmMember_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RealmMemberLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RealmsServer).GetRealmMember(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Realms_GetRealmMember_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RealmsServer).GetRealmMember(ctx, req.(*RealmMemberLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
// Realms_ServiceDesc is the grpc.ServiceDesc for Realms service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -215,6 +281,14 @@ var Realms_ServiceDesc = grpc.ServiceDesc{
MethodName: "GetRealm",
Handler: _Realms_GetRealm_Handler,
},
{
MethodName: "ListRealmMember",
Handler: _Realms_ListRealmMember_Handler,
},
{
MethodName: "GetRealmMember",
Handler: _Realms_GetRealmMember_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "realms.proto",

View File

@ -105,3 +105,43 @@ func (v *Server) GetRealm(ctx context.Context, request *proto.RealmLookupRequest
IsCommunity: realm.IsCommunity,
}, nil
}
func (v *Server) ListRealmMember(ctx context.Context, request *proto.RealmMemberLookupRequest) (*proto.ListRealmMemberResponse, error) {
var members []models.RealmMember
tx := database.C.Where("realm_id = ?", request.GetRealmId())
if request.UserId != nil {
tx = tx.Where("account_id = ?", request.GetUserId())
}
if err := tx.Find(&members).Error; err != nil {
return nil, err
}
return &proto.ListRealmMemberResponse{
Data: lo.Map(members, func(item models.RealmMember, index int) *proto.RealmMemberResponse {
return &proto.RealmMemberResponse{
RealmId: uint64(item.RealmID),
UserId: uint64(item.AccountID),
PowerLevel: int32(item.PowerLevel),
}
}),
}, nil
}
func (v *Server) GetRealmMember(ctx context.Context, request *proto.RealmMemberLookupRequest) (*proto.RealmMemberResponse, error) {
var member models.RealmMember
tx := database.C.Where("realm_id = ?", request.GetRealmId())
if request.UserId != nil {
tx = tx.Where("account_id = ?", request.GetUserId())
}
if err := tx.First(&member).Error; err != nil {
return nil, err
}
return &proto.RealmMemberResponse{
RealmId: uint64(member.RealmID),
UserId: uint64(member.AccountID),
PowerLevel: int32(member.PowerLevel),
}, nil
}