Commit c87e1382 by Li Feifei

refactoring

parent 905d0ad5
......@@ -46,7 +46,7 @@ func init() {
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
middleware.Interceptor,
grpc_validator.UnaryServerInterceptor(),
middleware.Auth,
//middleware.Auth,
grpc_recovery.UnaryServerInterceptor(middleware.RecoveryInterceptor()),
grpc_zap.UnaryServerInterceptor(middleware.ZapInterceptor()),
)))
......
......@@ -3,7 +3,6 @@ package main
import (
"net"
"im-microservice/gateway"
initialize "im-microservice/initialization"
beeLogger "github.com/beego/bee/logger"
......@@ -22,12 +21,7 @@ func main() {
}
beeLogger.Log.Success("gRPC server is running on " + port + " port.")
// 启动http服务
go func() {
if err := gateway.ProvideHTTP(Address, initialize.RpcServer).ListenAndServe(); err != nil {
beeLogger.Log.Fatalf("failed to api serve: %v", err)
}
}()
// 启动grpc服务
if err := initialize.RpcServer.Serve(lis); err != nil {
beeLogger.Log.Fatalf("failed to serve: %v", err)
......
......@@ -7,9 +7,7 @@
package pb
import (
_ "github.com/gogo/protobuf/gogoproto"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
......@@ -27,77 +25,6 @@ const (
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Common struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Appkey string `protobuf:"bytes,1,opt,name=Appkey,proto3" json:"Appkey,omitempty"`
Nonce string `protobuf:"bytes,2,opt,name=Nonce,proto3" json:"Nonce,omitempty"`
Curtime string `protobuf:"bytes,3,opt,name=Curtime,proto3" json:"Curtime,omitempty"`
Checksum string `protobuf:"bytes,4,opt,name=Checksum,proto3" json:"Checksum,omitempty"`
}
func (x *Common) Reset() {
*x = Common{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Common) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Common) ProtoMessage() {}
func (x *Common) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_common_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 Common.ProtoReflect.Descriptor instead.
func (*Common) Descriptor() ([]byte, []int) {
return file_u_proto_common_proto_rawDescGZIP(), []int{0}
}
func (x *Common) GetAppkey() string {
if x != nil {
return x.Appkey
}
return ""
}
func (x *Common) GetNonce() string {
if x != nil {
return x.Nonce
}
return ""
}
func (x *Common) GetCurtime() string {
if x != nil {
return x.Curtime
}
return ""
}
func (x *Common) GetChecksum() string {
if x != nil {
return x.Checksum
}
return ""
}
type Page struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
......@@ -112,7 +39,7 @@ type Page struct {
func (x *Page) Reset() {
*x = Page{}
if protoimpl.UnsafeEnabled {
mi := &file_u_proto_common_proto_msgTypes[1]
mi := &file_u_proto_common_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
......@@ -125,7 +52,7 @@ func (x *Page) String() string {
func (*Page) ProtoMessage() {}
func (x *Page) ProtoReflect() protoreflect.Message {
mi := &file_u_proto_common_proto_msgTypes[1]
mi := &file_u_proto_common_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
......@@ -138,7 +65,7 @@ func (x *Page) ProtoReflect() protoreflect.Message {
// Deprecated: Use Page.ProtoReflect.Descriptor instead.
func (*Page) Descriptor() ([]byte, []int) {
return file_u_proto_common_proto_rawDescGZIP(), []int{1}
return file_u_proto_common_proto_rawDescGZIP(), []int{0}
}
func (x *Page) GetPagetNo() int64 {
......@@ -173,31 +100,15 @@ var File_u_proto_common_proto protoreflect.FileDescriptor
var file_u_proto_common_proto_rawDesc = []byte{
0x0a, 0x14, 0x75, 0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a, 0x2d, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67,
0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x77, 0x69, 0x74, 0x6b, 0x6f, 0x77, 0x2f, 0x67, 0x6f,
0x2d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2d, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72,
0x73, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x8c, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x06,
0x41, 0x70, 0x70, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf,
0x1f, 0x02, 0x58, 0x01, 0x52, 0x06, 0x41, 0x70, 0x70, 0x6b, 0x65, 0x79, 0x12, 0x1c, 0x0a, 0x05,
0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f,
0x02, 0x58, 0x01, 0x52, 0x05, 0x4e, 0x6f, 0x6e, 0x63, 0x65, 0x12, 0x20, 0x0a, 0x07, 0x43, 0x75,
0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xe2, 0xdf, 0x1f,
0x02, 0x58, 0x01, 0x52, 0x07, 0x43, 0x75, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x08,
0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06,
0xe2, 0xdf, 0x1f, 0x02, 0x58, 0x01, 0x52, 0x08, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d,
0x22, 0x7a, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x67, 0x65,
0x74, 0x4e, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x50, 0x61, 0x67, 0x65, 0x74,
0x4e, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1c,
0x0a, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x03, 0x52, 0x09, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a,
0x54, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03,
0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22, 0x7a, 0x0a, 0x04, 0x50, 0x61,
0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x50, 0x61, 0x67, 0x65, 0x74, 0x4e, 0x6f, 0x18, 0x01, 0x20,
0x01, 0x28, 0x03, 0x52, 0x07, 0x50, 0x61, 0x67, 0x65, 0x74, 0x4e, 0x6f, 0x12, 0x1a, 0x0a, 0x08,
0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08,
0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x6f, 0x74, 0x61,
0x6c, 0x50, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x54, 0x6f, 0x74,
0x61, 0x6c, 0x50, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x43,
0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61,
0x6c, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
......@@ -212,10 +123,9 @@ func file_u_proto_common_proto_rawDescGZIP() []byte {
return file_u_proto_common_proto_rawDescData
}
var file_u_proto_common_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_u_proto_common_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_u_proto_common_proto_goTypes = []interface{}{
(*Common)(nil), // 0: pb.Common
(*Page)(nil), // 1: pb.Page
(*Page)(nil), // 0: pb.Page
}
var file_u_proto_common_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
......@@ -232,18 +142,6 @@ func file_u_proto_common_proto_init() {
}
if !protoimpl.UnsafeEnabled {
file_u_proto_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Common); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_u_proto_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Page); i {
case 0:
return &v.state
......@@ -262,7 +160,7 @@ func file_u_proto_common_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_u_proto_common_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
......
......@@ -5,10 +5,10 @@ package pb
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......@@ -20,11 +20,6 @@ func (this *Public) Validate() error {
return nil
}
func (this *ConfigureRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Public != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Public); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Public", err)
......@@ -42,19 +37,9 @@ func (this *ConfigureDelRequest) Validate() error {
if !(this.CompanyUserId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("CompanyUserId", fmt.Errorf(`value '%v' must be greater than '0'`, this.CompanyUserId))
}
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
return nil
}
func (this *GetAllRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
return nil
}
func (this *GetAllOneReply) Validate() error {
......@@ -76,11 +61,6 @@ func (this *GetAllReply) Validate() error {
return nil
}
func (this *UpdateRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Public != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Public); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Public", err)
......
......@@ -5,10 +5,10 @@ package pb
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......@@ -17,11 +17,6 @@ var _ = fmt.Errorf
var _ = math.Inf
func (this *ChatRoomAddRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Creator == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Creator", fmt.Errorf(`value '%v' must not be an empty string`, this.Creator))
}
......@@ -37,11 +32,6 @@ func (this *ChatRoomAddReply) Validate() error {
return nil
}
func (this *ChatRoomUpdateRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if !(this.RoomId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RoomId", fmt.Errorf(`value '%v' must be greater than '0'`, this.RoomId))
}
......@@ -51,11 +41,6 @@ func (this *ChatRoomUpdateReply) Validate() error {
return nil
}
func (this *ChatRoomDelRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if !(this.RoomId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RoomId", fmt.Errorf(`value '%v' must be greater than '0'`, this.RoomId))
}
......@@ -65,11 +50,6 @@ func (this *ChatRoomDelReply) Validate() error {
return nil
}
func (this *ChatRoomInfoRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if !(this.RoomId > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("RoomId", fmt.Errorf(`value '%v' must be greater than '0'`, this.RoomId))
}
......@@ -79,11 +59,6 @@ func (this *ChatRoomInfoReply) Validate() error {
return nil
}
func (this *ChatRoomAllRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
return nil
}
func (this *GetChatRoomsReply) Validate() error {
......
......@@ -5,10 +5,10 @@ package pb
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......@@ -17,28 +17,21 @@ var _ = fmt.Errorf
var _ = math.Inf
func (this *ImFriendAddReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
if this.Faccid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Faccid", fmt.Errorf(`value '%v' must not be an empty string`, this.Faccid))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *ImFriendEmptyReply) Validate() error {
return nil
}
func (this *ImFriendUpdateReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if !(this.Id > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Id", fmt.Errorf(`value '%v' must be greater than '0'`, this.Id))
}
......@@ -51,14 +44,12 @@ func (this *ImFriendUpdateReq) Validate() error {
return nil
}
func (this *ImFriendListReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *ImFriendListOne) Validate() error {
......
......@@ -5,10 +5,10 @@ package pb
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -207,6 +207,42 @@ func local_request_UserRelationshipService_ListBlackAndMuteList_0(ctx context.Co
}
var (
filter_UserRelationshipService_One_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_UserRelationshipService_One_0(ctx context.Context, marshaler runtime.Marshaler, client UserRelationshipServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq FriendRelationshipReq
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserRelationshipService_One_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.One(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_UserRelationshipService_One_0(ctx context.Context, marshaler runtime.Marshaler, server UserRelationshipServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq FriendRelationshipReq
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserRelationshipService_One_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.One(ctx, &protoReq)
return msg, metadata, err
}
// RegisterUserRelationshipServiceHandlerServer registers the http handlers for service UserRelationshipService to "mux".
// UnaryRPC :call UserRelationshipServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
......@@ -312,6 +348,26 @@ func RegisterUserRelationshipServiceHandlerServer(ctx context.Context, mux *runt
})
mux.Handle("GET", pattern_UserRelationshipService_One_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_UserRelationshipService_One_0(rctx, inboundMarshaler, server, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_UserRelationshipService_One_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
......@@ -453,6 +509,26 @@ func RegisterUserRelationshipServiceHandlerClient(ctx context.Context, mux *runt
})
mux.Handle("GET", pattern_UserRelationshipService_One_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_UserRelationshipService_One_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_UserRelationshipService_One_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
......@@ -466,6 +542,8 @@ var (
pattern_UserRelationshipService_SetSpecialRelation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nimserver", "user", "setSpecialRelation"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_UserRelationshipService_ListBlackAndMuteList_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nimserver", "user", "listBlackAndMuteList"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_UserRelationshipService_One_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"nimserver", "friend", "one"}, "", runtime.AssumeColonVerbOpt(true)))
)
var (
......@@ -478,4 +556,6 @@ var (
forward_UserRelationshipService_SetSpecialRelation_0 = runtime.ForwardResponseMessage
forward_UserRelationshipService_ListBlackAndMuteList_0 = runtime.ForwardResponseMessage
forward_UserRelationshipService_One_0 = runtime.ForwardResponseMessage
)
......@@ -5,10 +5,10 @@ package pb
import (
fmt "fmt"
math "math"
proto "github.com/golang/protobuf/proto"
_ "github.com/mwitkow/go-proto-validators"
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......@@ -17,11 +17,6 @@ var _ = fmt.Errorf
var _ = math.Inf
func (this *UserRelationshipAddRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
......@@ -31,37 +26,36 @@ func (this *UserRelationshipAddRequest) Validate() error {
if !(this.Type > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Type", fmt.Errorf(`value '%v' must be greater than '0'`, this.Type))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *UserRelationshipAddReply) Validate() error {
return nil
}
func (this *UserRelationshipDelRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
if this.Faccid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Faccid", fmt.Errorf(`value '%v' must not be an empty string`, this.Faccid))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *UserRelationshipListRequest) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
if this.Updatetime == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Updatetime", fmt.Errorf(`value '%v' must not be an empty string`, this.Updatetime))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *UserRelationshipInfo) Validate() error {
......@@ -78,11 +72,6 @@ func (this *UserRelationshipListReply) Validate() error {
return nil
}
func (this *SetSpecialRelationReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
......@@ -95,14 +84,12 @@ func (this *SetSpecialRelationReq) Validate() error {
if !(this.Value > 0) {
return github_com_mwitkow_go_proto_validators.FieldError("Value", fmt.Errorf(`value '%v' must be greater than '0'`, this.Value))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *ListBlackAndMuteListReq) Validate() error {
if this.Common != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Common); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("Common", err)
}
}
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
......@@ -125,3 +112,18 @@ func (this *ListBlackAndMuteListReply) Validate() error {
}
return nil
}
func (this *FriendRelationshipReq) Validate() error {
if this.Accid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Accid", fmt.Errorf(`value '%v' must not be an empty string`, this.Accid))
}
if this.Faccid == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Faccid", fmt.Errorf(`value '%v' must not be an empty string`, this.Faccid))
}
if this.Appkey == "" {
return github_com_mwitkow_go_proto_validators.FieldError("Appkey", fmt.Errorf(`value '%v' must not be an empty string`, this.Appkey))
}
return nil
}
func (this *FriendRelationshipReply) Validate() error {
return nil
}
......@@ -44,6 +44,7 @@ func (cr *ImChatRoomService) Delete(ctx context.Context,
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return
}
if err = DeleteChatRoom(in.RoomId); err != nil {
return
}
......
......@@ -48,7 +48,7 @@ func AddRecord(in *pb.ImFriendAddReq) error {
db_friend.Status = field_status_wait
db_friend.Createtime = now
db_friend.Updatetime = now
db_friend.Appkey = in.Common.Appkey
db_friend.Appkey = in.Appkey
_, err := db.MysqlClient.Insert(&db_friend)
return err
}
......
......@@ -22,7 +22,7 @@ func (fs *ImFriendService) All(ctx context.Context, in *pb.ImFriendListReq) (rep
return
}
// 添加用户是否存在
if _, err = im_user.GetImUserByAccidAppkey(in.Accid, in.Common.Appkey); err != nil {
if _, err = im_user.GetImUserByAccidAppkey(in.Accid, in.Appkey); err != nil {
err = status.Error(codes.NotFound, "用户不存在")
return
}
......@@ -51,27 +51,27 @@ func (fs *ImFriendService) Add(ctx context.Context, in *pb.ImFriendAddReq) (repl
return
}
// 添加用户是否存在
if _, err = im_user.GetImUserByAccidAppkey(in.Accid, in.Common.Appkey); err != nil {
if _, err = im_user.GetImUserByAccidAppkey(in.Accid, in.Appkey); err != nil {
err = status.Error(codes.NotFound, "用户不存在")
return
}
// 被添加用户存在
if _, err = im_user.GetImUserByAccidAppkey(in.Faccid, in.Common.Appkey); err != nil {
if _, err = im_user.GetImUserByAccidAppkey(in.Faccid, in.Appkey); err != nil {
err = status.Error(codes.NotFound, "被添加用户不存在")
return
}
//是否已经添加过好友
if ok := im_user_relationship.IsUserRelationship(in.Accid, in.Faccid, in.Common.Appkey); ok {
if ok := im_user_relationship.IsUserRelationship(in.Accid, in.Faccid, in.Appkey); ok {
err = status.Error(codes.AlreadyExists, "已经添加过该好友")
return
}
//对方用户黑名单不能添加
if ok := im_user_relationship.IsBlack(in.Accid, in.Faccid, in.Common.Appkey); ok {
if ok := im_user_relationship.IsBlack(in.Accid, in.Faccid, in.Appkey); ok {
err = status.Error(codes.AlreadyExists, "已经添加过该好友")
return
}
// 已经提过添加好友申请
if ok := FindExits(in.Accid, in.Faccid, in.Common.Appkey); ok {
if ok := FindExits(in.Accid, in.Faccid, in.Appkey); ok {
err = status.Error(codes.AlreadyExists, "已经提交过申请")
return
}
......
......@@ -32,6 +32,14 @@ func IsUserRelationship(accid, faccid, key string) bool {
Filter(db_field_faccid, faccid).Filter("appkey", key).Exist()
}
func GetUserRelationshipOne (accid, faccid, key string) (db.ImUserRelationship, error ) {
var one db.ImUserRelationship
err := db.MysqlClient.QueryTable(db_tabel).Filter(db_field_accid, accid).
Filter(db_field_faccid, faccid).Filter("appkey", key).One(&one)
return one, err
}
//是否是对方黑名单
func IsBlack(accid, faccid, key string) bool {
return db.MysqlClient.QueryTable(db_tabel).Filter(db_field_accid, faccid).
......@@ -55,10 +63,10 @@ func AddUserRelationship(in *pb.UserRelationshipAddRequest) error {
us.Blacklist = open
us.Mute = open
us.Createtime = now
us.Appkey = in.Common.Appkey
us.Appkey = in.Appkey
_, err := db.MysqlClient.Insert(&us)
if ok := IsUserRelationship(in.Faccid, in.Accid, in.Common.Appkey); !ok {
if ok := IsUserRelationship(in.Faccid, in.Accid, in.Appkey); !ok {
// 被添加者
ts.Accid = in.Faccid
ts.Faccid = in.Accid
......@@ -95,8 +103,7 @@ func DBAll(in *pb.UserRelationshipListRequest) ([]db.ImUserRelationship, error)
var friends []db.ImUserRelationship
num, err := db.MysqlClient.QueryTable(db_tabel).Filter(db_field_accid, in.Accid).
Filter(db_field_blacklist, open).Filter(db_field_updatetime+"__gte", in.Updatetime).
All(&friends, db_field_faccid, db_field_updatetime)
Filter("appkey", in.Appkey).All(&friends, db_field_faccid, db_field_updatetime)
if err != nil {
return nil, err
}
......@@ -108,7 +115,7 @@ func DBAll(in *pb.UserRelationshipListRequest) ([]db.ImUserRelationship, error)
func SetSpecialRelationDb(in *pb.SetSpecialRelationReq) error {
if ok := IsUserRelationship(in.Accid, in.TargetAcc, in.Common.Appkey); !ok {
if ok := IsUserRelationship(in.Accid, in.TargetAcc, in.Appkey); !ok {
return errors.New("被操作用户不是该用户好友")
}
orm_params := make(orm.Params)
......
......@@ -29,10 +29,10 @@ func (us *UserRelationshipService) Add(ctx context.Context,
// 更改用户版本信息
u_map := make(map[string]interface{})
u_map["edition"] = helper.GetNowTime()
_, _ = im_user.UpdateImUser(in.Accid, in.Common.Appkey, u_map)
_, _ = im_user.UpdateImUser(in.Accid, in.Appkey, u_map)
// 更改请求用户版本信息
_, _ = im_user.UpdateImUser(in.Faccid, in.Common.Appkey, u_map)
_, _ = im_user.UpdateImUser(in.Faccid, in.Appkey, u_map)
reply = &pb.UserRelationshipAddReply{}
return
......@@ -52,10 +52,10 @@ func (us *UserRelationshipService) Delete(ctx context.Context,
// 更改用户版本信息
u_map := make(map[string]interface{})
u_map["edition"] = helper.GetNowTime()
_, _ = im_user.UpdateImUser(in.Accid, in.Common.Appkey, u_map)
_, _ = im_user.UpdateImUser(in.Accid, in.Appkey, u_map)
// 更改被添加用户版本信息
_, _ = im_user.UpdateImUser(in.Faccid, in.Common.Appkey, u_map)
_, _ = im_user.UpdateImUser(in.Faccid, in.Appkey, u_map)
reply = &pb.UserRelationshipAddReply{}
return
......@@ -129,3 +129,29 @@ func (us *UserRelationshipService) ListBlackAndMuteList(ctx context.Context,
}
return
}
func (us *UserRelationshipService) One (ctx context.Context,
in *pb.FriendRelationshipReq) ( reply *pb.FriendRelationshipReply, err error) {
// 请求超时
if ctx.Err() == context.Canceled {
err = status.New(codes.Canceled, "Client cancelled, abandoning.").Err()
return
}
result, err := GetUserRelationshipOne(in.Accid, in.Faccid, in.Appkey)
if err != nil {
err = status.Error(codes.NotFound, err.Error())
return
}
reply = &pb.FriendRelationshipReply{
Type: int64(result.Type),
Msg: result.Msg,
Blacklist: int64(result.Blacklist),
Mute: int64(result.Mute),
Serverex: result.Serverex,
Createtime: result.Createtime,
Updatetime: result.Updatetime,
}
return
}
\ No newline at end of file
......@@ -2,15 +2,6 @@ syntax = "proto3";
package pb;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
message Common {
string Appkey = 1 [(validator.field) = {string_not_empty: true}];
string Nonce = 2 [(validator.field) = {string_not_empty: true}];
string Curtime = 3 [(validator.field) = {string_not_empty: true}];
string Checksum = 4 [(validator.field) = {string_not_empty: true}];
}
message Page {
int64 PagetNo = 1;
......
......@@ -2,8 +2,7 @@ syntax = "proto3";
package pb;
import "u-proto/common.proto";
import "u-proto/google/api/annotations.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
message Public {
......@@ -13,20 +12,19 @@ message Public {
}
message ConfigureRequest {
Common Common = 1;
Public Public = 2;
int64 AppId = 3 [(validator.field) = {int_gt: 0}];
string Appkey= 1;
string Current=2;
Public Public = 3;
int64 AppId = 4 [(validator.field) = {int_gt: 0}];
}
message ConfigureReply {}
message ConfigureDelRequest {
int64 CompanyUserId = 1 [(validator.field) = {int_gt: 0}];
Common Common = 2;
}
message GetAllRequest {
Common Common = 1;
}
message GetAllOneReply {
Public Reply = 1;
......@@ -37,31 +35,12 @@ message GetAllReply {
}
message UpdateRequest {
Common Common = 1;
Public Public = 2;
Public Public = 1;
}
service ConfigureSevice{
rpc Select(GetAllRequest) returns(GetAllReply) {
option(google.api.http) = {
get:"/nimserver/config/get"
};
}
rpc Add (ConfigureRequest) returns(ConfigureReply) {
option(google.api.http) = {
post:"/nimserver/config/add"
body:"*"
};
}
rpc Delete(ConfigureDelRequest) returns(ConfigureReply) {
option(google.api.http) = {
delete:"/nimserver/config/del"
};
}
rpc Update(UpdateRequest) returns(ConfigureReply) {
option(google.api.http) = {
put:"/nimserver/config/update"
body:"*"
};
}
rpc Select(GetAllRequest) returns(GetAllReply) { }
rpc Add (ConfigureRequest) returns(ConfigureReply) {}
rpc Delete(ConfigureDelRequest) returns(ConfigureReply) {}
rpc Update(UpdateRequest) returns(ConfigureReply) {}
}
......@@ -3,15 +3,14 @@ syntax = "proto3";
package pb;
import "u-proto/common.proto";
import "u-proto/google/api/annotations.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
// 添加聊天室
message ChatRoomAddRequest {
Common Common = 1;
string Creator = 2 [(validator.field) = {string_not_empty: true}];
string Name = 3 [(validator.field) = {string_not_empty: true}];
string Announcement = 4 [(validator.field) = {string_not_empty: true}];
string Creator = 1 [(validator.field) = {string_not_empty: true}];
string Name = 2 [(validator.field) = {string_not_empty: true}];
string Announcement = 3 [(validator.field) = {string_not_empty: true}];
}
message ChatRoomAddReply{
......@@ -20,27 +19,25 @@ message ChatRoomAddReply{
// 更新聊天室
message ChatRoomUpdateRequest {
Common Common = 1;
int64 RoomId = 2 [(validator.field) = {int_gt: 0}];
string Name = 3;
int64 Status = 4;
string Announcement = 5;
int64 RoomId = 1 [(validator.field) = {int_gt: 0}];
string Name = 2;
int64 Status = 3;
string Announcement = 4;
}
message ChatRoomUpdateReply {}
// 删除聊天室
message ChatRoomDelRequest {
Common Common = 1;
int64 RoomId = 2 [(validator.field) = {int_gt: 0}];
int64 RoomId = 1 [(validator.field) = {int_gt: 0}];
}
message ChatRoomDelReply {}
// 获取单个聊天室信息
message ChatRoomInfoRequest {
Common Common = 1;
int64 RoomId = 2 [(validator.field) = {int_gt: 0}];
int64 RoomId = 1 [(validator.field) = {int_gt: 0}];
}
message ChatRoomInfoReply {
......@@ -58,14 +55,13 @@ message ChatRoomInfoReply {
// 获取所有房间
message ChatRoomAllRequest {
Common Common = 1;
int64 Page = 2;
string Creator = 3;
string Name = 4;
string Announcement = 5;
int64 Status = 6;
string Createtime = 7;
string Updatetime = 8;
int64 Page = 1;
string Creator = 2;
string Name = 3;
string Announcement = 4;
int64 Status = 5;
string Createtime = 6;
string Updatetime = 7;
}
message GetChatRoomsReply {
......@@ -74,31 +70,9 @@ message GetChatRoomsReply {
}
service ChatRoomService {
rpc Add(ChatRoomAddRequest) returns(ChatRoomAddReply) {
option(google.api.http) = {
post:"/nimserver/chatroom/create"
body:"*"
};
}
rpc Update(ChatRoomUpdateRequest) returns(ChatRoomUpdateReply) {
option(google.api.http) = {
put:"/nimserver/chatroom/update"
body:"*"
};
}
rpc Delete(ChatRoomDelRequest) returns(ChatRoomDelReply) {
option(google.api.http) = {
delete:"/nimserver/chatroom/delete"
};
}
rpc Info(ChatRoomInfoRequest) returns (ChatRoomInfoReply) {
option(google.api.http) = {
get:"/nimserver/chatroom/get"
};
}
rpc All(ChatRoomAllRequest) returns (GetChatRoomsReply) {
option(google.api.http) = {
get:"/nimserver/chatroom/getBatch"
};
}
rpc Add(ChatRoomAddRequest) returns(ChatRoomAddReply) {}
rpc Update(ChatRoomUpdateRequest) returns(ChatRoomUpdateReply) {}
rpc Delete(ChatRoomDelRequest) returns(ChatRoomDelReply){}
rpc Info(ChatRoomInfoRequest) returns (ChatRoomInfoReply) {}
rpc All(ChatRoomAllRequest) returns (GetChatRoomsReply) {}
}
\ No newline at end of file
......@@ -2,30 +2,29 @@ syntax = "proto3";
package pb;
import "u-proto/common.proto";
import "u-proto/google/api/annotations.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
// 发起添加好友申请
message ImFriendAddReq {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Faccid = 3 [(validator.field) = {string_not_empty: true}];
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string Faccid = 2 [(validator.field) = {string_not_empty: true}];
string Appkey = 3 [(validator.field) = {string_not_empty: true}];
}
message ImFriendEmptyReply {}
// 更改添加好友状态
message ImFriendUpdateReq {
Common Common = 1;
int64 Id = 2 [(validator.field) = {int_gt: 0}];
int64 Status = 3 [(validator.field) = {int_gt: 0, int_lt:3}];
int64 Id = 1 [(validator.field) = {int_gt: 0}];
int64 Status = 2 [(validator.field) = {int_gt: 0, int_lt:3}];
}
// 获取申请好友列表
message ImFriendListReq {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string Appkey = 2 [(validator.field) = {string_not_empty: true}];
}
message ImFriendListOne {
int64 Id = 1;
......@@ -38,21 +37,7 @@ message ImFriendListReply {
}
service ImFriendService {
rpc All(ImFriendListReq) returns(ImFriendListReply) {
option(google.api.http) = {
get:"/nimserver/firendlist/getBatch"
};
}
rpc Add(ImFriendAddReq) returns(ImFriendEmptyReply) {
option(google.api.http) = {
post:"/nimserver/firendlist/create"
body:"*"
};
}
rpc Update(ImFriendUpdateReq) returns(ImFriendEmptyReply) {
option(google.api.http) = {
put:"/nimserver/firendlist/update"
body:"*"
};
}
rpc All(ImFriendListReq) returns(ImFriendListReply) { }
rpc Add(ImFriendAddReq) returns(ImFriendEmptyReply) {}
rpc Update(ImFriendUpdateReq) returns(ImFriendEmptyReply) { }
}
\ No newline at end of file
......@@ -2,17 +2,17 @@ syntax = "proto3";
package pb;
import "u-proto/common.proto";
import "u-proto/google/api/annotations.proto";
import "github.com/mwitkow/go-proto-validators/validator.proto";
//添加好友
message UserRelationshipAddRequest {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Faccid = 3 [(validator.field) = {string_not_empty: true}];
int64 Type = 4 [(validator.field) = {int_gt: 0}];
string Msg = 5;
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string Faccid = 2 [(validator.field) = {string_not_empty: true}];
int64 Type = 3 [(validator.field) = {int_gt: 0}];
string Msg = 4;
string Appkey = 5 [(validator.field) = {string_not_empty: true}];
}
message UserRelationshipAddReply {}
......@@ -20,16 +20,18 @@ message UserRelationshipAddReply {}
//删除好友
message UserRelationshipDelRequest {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Faccid = 3 [(validator.field) = {string_not_empty: true}];
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string Faccid = 2 [(validator.field) = {string_not_empty: true}];
string Appkey = 3 [(validator.field) = {string_not_empty: true}];
}
// 获取好友关系
message UserRelationshipListRequest {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Updatetime = 3 [(validator.field) = {string_not_empty: true}];
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string Updatetime = 2 [(validator.field) = {string_not_empty: true}];
string Appkey = 3 [(validator.field) = {string_not_empty: true}];
}
message UserRelationshipInfo {
......@@ -43,18 +45,19 @@ message UserRelationshipListReply {
//设置黑名单/静音
message SetSpecialRelationReq {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string TargetAcc = 3 [(validator.field) = {string_not_empty: true}];
int64 RelationType = 4 [(validator.field) = {int_gt: 0}];
int64 Value = 5 [(validator.field) = {int_gt: 0}];
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string TargetAcc = 2 [(validator.field) = {string_not_empty: true}];
int64 RelationType = 3 [(validator.field) = {int_gt: 0}];
int64 Value = 4 [(validator.field) = {int_gt: 0}];
string Appkey = 5 [(validator.field) = {string_not_empty: true}];
}
//查看指定用户的黑名单和静音列表
message ListBlackAndMuteListReq {
Common Common = 1;
string Accid = 2 [(validator.field) = {string_not_empty: true}];
string Accid = 1 [(validator.field) = {string_not_empty: true}];
}
message ListBlackAndMuteListReply {
......@@ -62,32 +65,29 @@ message ListBlackAndMuteListReply {
repeated UserRelationshipInfo Blacklist = 2;
}
// 获取当前聊天好友关系
message FriendRelationshipReq {
string Accid = 1 [(validator.field) = {string_not_empty: true}];
string Faccid = 2 [(validator.field) = {string_not_empty: true}];
string Appkey = 3 [(validator.field) = {string_not_empty: true}];
}
message FriendRelationshipReply {
int64 Type = 1;
string Msg = 2;
int64 Blacklist = 3;
int64 Mute = 4;
string Serverex = 5;
string Createtime = 6;
string Updatetime = 7;
}
service UserRelationshipService {
rpc Add(UserRelationshipAddRequest) returns (UserRelationshipAddReply) {
option(google.api.http) = {
post:"/nimserver/friend/add"
body:"*"
};
}
rpc Delete(UserRelationshipDelRequest) returns (UserRelationshipAddReply) {
option (google.api.http) = {
delete:"/nimserver/friend/delete"
};
}
rpc All(UserRelationshipListRequest) returns (UserRelationshipListReply) {
option (google.api.http) = {
get:"/nimserver/friend/get"
};
}
rpc SetSpecialRelation(SetSpecialRelationReq) returns (UserRelationshipAddReply) {
option (google.api.http) = {
put: "/nimserver/user/setSpecialRelation"
body: "*"
};
}
rpc ListBlackAndMuteList(ListBlackAndMuteListReq) returns(ListBlackAndMuteListReply) {
option (google.api.http) ={
get:"/nimserver/user/listBlackAndMuteList"
};
}
rpc Add(UserRelationshipAddRequest) returns (UserRelationshipAddReply) {}
rpc Delete(UserRelationshipDelRequest) returns (UserRelationshipAddReply) { }
rpc All(UserRelationshipListRequest) returns (UserRelationshipListReply) { }
rpc SetSpecialRelation(SetSpecialRelationReq) returns (UserRelationshipAddReply) {}
rpc ListBlackAndMuteList(ListBlackAndMuteListReq) returns(ListBlackAndMuteListReply) { }
rpc One(FriendRelationshipReq) returns(FriendRelationshipReply) {}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment