Browse Source

代码提交

WH01243 3 years ago
parent
commit
245a2eb26a

+ 8 - 7
entity/db.go

@@ -1,9 +1,10 @@
 package entity
 
-import "C"
-import (
-	"app.yhyue.com/moapp/jybase/mysql"
-	_ "github.com/go-sql-driver/mysql"
-)
-
-var Mysql *mysql.Mysql
+type MysqlMainStruct struct {
+	DbName       string `json:"dbName"`
+	Address      string `json:"address"`
+	UserName     string `json:"userName"`
+	PassWord     string `json:"passWord"`
+	MaxOpenConns int    `json:"maxOpenConns"`
+	MaxIdleConns int    `json:"maxIdleConns"`
+}

+ 0 - 20
entity/message.go

@@ -1,20 +0,0 @@
-package entity
-
-type MessageService interface {
-	Get(id int) map[string]interface{}
-}
-type Message struct {
-	Id           string `json:"id"`
-	Appid        string `json:"appid"`
-	Title        string `json:"title"`
-	Content      string `json:"content"`
-	Item         string `json:"item"`
-	Type         string `json:"type"`
-	Link         string `json:"link"`
-	CreateTime   string `json:"create_time"`
-	CreatePerson string `json:"create_person"`
-}
-
-func (m Message) Get(id int) (msg map[string]interface{}) {
-	return *Mysql.FindOne("socialize_message", map[string]interface{}{"id": id}, "", "")
-}

+ 0 - 196
entity/message_mail_box_test.go

@@ -1,196 +0,0 @@
-package entity
-
-import (
-	"fmt"
-	"reflect"
-	"testing"
-)
-
-func TestMessageMailBox_Count(t *testing.T) {
-	type fields struct {
-		Id             string
-		AppID          string
-		MessageId      string
-		Type           string
-		SendUserId     string
-		ReceiveUserId  string
-		SendIsDel      string
-		SendDelTime    string
-		ReceiveIsDel   string
-		ReceiveDelTime string
-		IsWithdraw     string
-		WithdrawTime   string
-		OwnId          string
-		ReadTime       string
-		CreateTime     string
-		IsRead         string
-	}
-	type args struct {
-		receiveId string
-		sendId    string
-		msgType   int
-		isRead    int
-	}
-	tests := []struct {
-		name      string
-		fields    fields
-		args      args
-		wantCount int
-		wantErr   bool
-	}{
-		{
-			name: "case1", fields: fields{}, args: args{
-			"1", "1", 1, 1,
-		}, wantCount: 1, wantErr: false,
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := MessageMailBox{
-				Id:             tt.fields.Id,
-				AppID:          tt.fields.AppID,
-				MessageId:      tt.fields.MessageId,
-				Type:           tt.fields.Type,
-				SendUserId:     tt.fields.SendUserId,
-				ReceiveUserId:  tt.fields.ReceiveUserId,
-				SendIsDel:      tt.fields.SendIsDel,
-				SendDelTime:    tt.fields.SendDelTime,
-				ReceiveIsDel:   tt.fields.ReceiveIsDel,
-				ReceiveDelTime: tt.fields.ReceiveDelTime,
-				IsWithdraw:     tt.fields.IsWithdraw,
-				WithdrawTime:   tt.fields.WithdrawTime,
-				OwnId:          tt.fields.OwnId,
-				ReadTime:       tt.fields.ReadTime,
-				CreateTime:     tt.fields.CreateTime,
-				IsRead:         tt.fields.IsRead,
-			}
-			gotCount, err := b.Count(tt.args.receiveId, tt.args.sendId, tt.args.msgType, tt.args.isRead)
-			fmt.Println(gotCount)
-			if (err != nil) != tt.wantErr {
-				t.Errorf("Count() error = %v, wantErr %v", err, tt.wantErr)
-				return
-			}
-			if gotCount != tt.wantCount {
-				t.Errorf("Count() gotCount = %v, want %v", gotCount, tt.wantCount)
-			}
-		})
-	}
-}
-
-func TestMessageMailBox_GetLast(t *testing.T) {
-	type fields struct {
-		Id             string
-		AppID          string
-		MessageId      string
-		Type           string
-		SendUserId     string
-		ReceiveUserId  string
-		SendIsDel      string
-		SendDelTime    string
-		ReceiveIsDel   string
-		ReceiveDelTime string
-		IsWithdraw     string
-		WithdrawTime   string
-		OwnId          string
-		ReadTime       string
-		CreateTime     string
-		IsRead         string
-	}
-	type args struct {
-		receiveId string
-		sendId    string
-		msgType   int
-	}
-	tests := []struct {
-		name           string
-		fields         fields
-		args           args
-		wantMessageBox map[string]interface{}
-		wantErr        bool
-	}{
-		{
-			name: "case1", fields: fields{}, args: args{
-			"1", "1", 1,
-		}, wantMessageBox: map[string]interface{}{}, wantErr: false,
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := MessageMailBox{
-				Id:             tt.fields.Id,
-				AppID:          tt.fields.AppID,
-				MessageId:      tt.fields.MessageId,
-				Type:           tt.fields.Type,
-				SendUserId:     tt.fields.SendUserId,
-				ReceiveUserId:  tt.fields.ReceiveUserId,
-				SendIsDel:      tt.fields.SendIsDel,
-				SendDelTime:    tt.fields.SendDelTime,
-				ReceiveIsDel:   tt.fields.ReceiveIsDel,
-				ReceiveDelTime: tt.fields.ReceiveDelTime,
-				IsWithdraw:     tt.fields.IsWithdraw,
-				WithdrawTime:   tt.fields.WithdrawTime,
-				OwnId:          tt.fields.OwnId,
-				ReadTime:       tt.fields.ReadTime,
-				CreateTime:     tt.fields.CreateTime,
-				IsRead:         tt.fields.IsRead,
-			}
-			gotMessageBox, err := b.GetLast(tt.args.receiveId, tt.args.sendId, tt.args.msgType)
-			fmt.Println(gotMessageBox)
-			if (err != nil) != tt.wantErr {
-				t.Errorf("GetLast() error = %v, wantErr %v", err, tt.wantErr)
-				return
-			}
-			if !reflect.DeepEqual(gotMessageBox, tt.wantMessageBox) {
-				t.Errorf("GetLast() gotMessageBox = %v, want %v", gotMessageBox, tt.wantMessageBox)
-			}
-		})
-	}
-}
-
-func TestMessage_Get(t *testing.T) {
-	type fields struct {
-		Id           string
-		Appid        string
-		Title        string
-		Content      string
-		Item         string
-		Type         string
-		Link         string
-		CreateTime   string
-		CreatePerson string
-	}
-	type args struct {
-		id int
-	}
-	tests := []struct {
-		name    string
-		fields  fields
-		args    args
-		wantMsg map[string]interface{}
-	}{
-		{
-			name: "case1", fields: fields{}, args: args{
-			1,
-		}, wantMsg: map[string]interface{}{},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			m := Message{
-				Id:           tt.fields.Id,
-				Appid:        tt.fields.Appid,
-				Title:        tt.fields.Title,
-				Content:      tt.fields.Content,
-				Item:         tt.fields.Item,
-				Type:         tt.fields.Type,
-				Link:         tt.fields.Link,
-				CreateTime:   tt.fields.CreateTime,
-				CreatePerson: tt.fields.CreatePerson,
-			}
-
-			if gotMsg := m.Get(tt.args.id); !reflect.DeepEqual(gotMsg, tt.wantMsg) {
-				t.Errorf("Get() = %v, want %v", gotMsg, tt.wantMsg)
-			}
-		})
-	}
-}

+ 6 - 0
rpc/messagecenter/etc/logs.yaml

@@ -0,0 +1,6 @@
+Mode: file
+Path: ./logs
+Level:
+  - info
+  - error
+KeepDays: 10

+ 15 - 0
rpc/messagecenter/etc/messagecenter.yaml

@@ -1,6 +1,21 @@
 Name: messagecenter.rpc
 ListenOn: 127.0.0.1:8080
+Timeout: 20000
 Etcd:
   Hosts:
   - 127.0.0.1:2379
   Key: messagecenter.rpc
+WebRpcPort: 8016
+MysqlMain:
+  dbName: base_service
+  address: 192.168.3.11:3366
+  userName: root
+  passWord: Topnet123
+  maxOpenConns: 5
+  maxIdleConns: 5
+
+TestConf:
+  Etcd:
+    Hosts:
+      - 127.0.0.1:2379
+    Key: messagecenter.rpc

+ 56 - 0
rpc/messagecenter/init/init.go

@@ -0,0 +1,56 @@
+package init
+
+import (
+	"app.yhyue.com/moapp/jybase/mysql"
+	"flag"
+	_ "github.com/go-sql-driver/mysql"
+	"github.com/zeromicro/go-zero/core/conf"
+	"github.com/zeromicro/go-zero/core/logx"
+	"log"
+	"messagecenter/entity"
+	"messagecenter/rpc/messagecenter/internal/config"
+)
+
+var configF = flag.String("ff", "etc/messagecenter.yaml", "the config file")
+
+//
+var logFile = flag.String("lf", "etc/logs.yaml", "the config file")
+var logc entity.Logc
+
+var C config.Config
+
+var (
+	Mysql *mysql.Mysql
+)
+
+func init() {
+	conf.MustLoad(*configF, &C)
+	//初始化mysql
+	mm := C.MysqlMain
+	if mm.Address != "" {
+		log.Println("--初始化 mysql--")
+		Mysql = &mysql.Mysql{
+			Address:      mm.Address,
+			UserName:     mm.UserName,
+			PassWord:     mm.PassWord,
+			DBName:       mm.DbName,
+			MaxOpenConns: mm.MaxOpenConns,
+			MaxIdleConns: mm.MaxIdleConns,
+		}
+		Mysql.Init()
+	}
+
+	//初始化日志信息
+	conf.MustLoad(*logFile, &logc)
+	if len(logc.Level) > 0 {
+		for _, v := range logc.Level {
+			logx.MustSetup(logx.LogConf{
+				Mode:     logc.Mode,
+				Path:     logc.Path,
+				Level:    v,
+				KeepDays: logc.KeepDays,
+			})
+			logx.Info(v, "--日志记录")
+		}
+	}
+}

+ 7 - 1
rpc/messagecenter/internal/config/config.go

@@ -1,7 +1,13 @@
 package config
 
-import "github.com/zeromicro/go-zero/zrpc"
+import (
+	"github.com/zeromicro/go-zero/zrpc"
+	"messagecenter/entity"
+)
 
 type Config struct {
 	zrpc.RpcServerConf
+	WebRpcPort int64
+	MysqlMain  entity.MysqlMainStruct
+	TestConf   zrpc.RpcClientConf
 }

+ 0 - 6
rpc/messagecenter/internal/server/messagecenterserver.go

@@ -28,12 +28,6 @@ func (s *MessageCenterServer) Count(ctx context.Context, in *messagecenter.Count
 	return l.Count(in)
 }
 
-//  获取消息
-func (s *MessageCenterServer) GetLast(ctx context.Context, in *messagecenter.GetReq) (*messagecenter.GetResp, error) {
-	l := logic.NewGetLastLogic(ctx, s.svcCtx)
-	return l.GetLast(in)
-}
-
 //  用户列表查询
 func (s *MessageCenterServer) UserList(ctx context.Context, in *messagecenter.UserReq) (*messagecenter.UserResp, error) {
 	l := logic.NewUserListLogic(ctx, s.svcCtx)

+ 17 - 23
rpc/messagecenter/messagecenter.go

@@ -1,40 +1,34 @@
 package main
 
 import (
-	"flag"
+	mc "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/endless"
+	"app.yhyue.com/moapp/jybase/go-xweb/log"
 	"fmt"
-
-	"messagecenter/rpc/messagecenter/internal/config"
+	"github.com/zeromicro/go-zero/zrpc"
+	"google.golang.org/grpc"
+	IC "messagecenter/rpc/messagecenter/init"
 	"messagecenter/rpc/messagecenter/internal/server"
 	"messagecenter/rpc/messagecenter/internal/svc"
 	"messagecenter/rpc/messagecenter/messagecenter"
-
-	"github.com/zeromicro/go-zero/core/conf"
-	"github.com/zeromicro/go-zero/core/service"
-	"github.com/zeromicro/go-zero/zrpc"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/reflection"
 )
 
-var configFile = flag.String("f", "etc/messagecenter.yaml", "the config file")
-
 func main() {
-	flag.Parse()
-
-	var c config.Config
-	conf.MustLoad(*configFile, &c)
-	ctx := svc.NewServiceContext(c)
-	svr := server.NewMessageCenterServer(ctx)
+	go func() {
+		err := endless.ListenAndServe(":"+mc.InterfaceToStr(IC.C.WebRpcPort), nil, func() {})
+		if err != nil {
+			log.Println("ListenAndServe: ", err)
+		}
+	}()
 
-	s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
-		messagecenter.RegisterMessageCenterServer(grpcServer, svr)
+	ctx := svc.NewServiceContext(IC.C)
+	srv := server.NewMessageCenterServer(ctx)
 
-		if c.Mode == service.DevMode || c.Mode == service.TestMode {
-			reflection.Register(grpcServer)
-		}
+	s := zrpc.MustNewServer(IC.C.RpcServerConf, func(grpcServer *grpc.Server) {
+		messagecenter.RegisterMessageCenterServer(grpcServer, srv)
 	})
 	defer s.Stop()
 
-	fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
+	fmt.Printf("Starting rpc server at %s...\n", IC.C.ListenOn)
 	s.Start()
 }

+ 8 - 7
rpc/messagecenter/messagecenter.proto

@@ -5,7 +5,7 @@ option go_package="./messagecenter";
 
 message CountReq {
   int64 msgType = 1;     // 消息类型 ;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息
-  int64 userType=2;      //用户类型:0用户1客服
+  int64 userType=2;      //用户类型:2用户1客服
   string sendId = 3;     // 发送方id
   int64 entId=4;        //企业标识
   string receiveId = 5;  // 接收方id
@@ -30,7 +30,9 @@ message UserReq {
   string startTime = 2;
   string endTime = 3;
   string customer_service_id = 4;
-  int64 userType=5;      //用户类型:0用户1客服
+  int64 userType=5;      //用户类型:2用户1客服
+  int64 pageIndex = 6;
+  int64 pageSize = 7;
 }
 message UserResp {
    repeated UserEntity data=1;
@@ -41,7 +43,7 @@ message UserEntity {
 }
 message MessageReq {
   int64 msgType = 1;     // 消息类型 ;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息
-  int64 userType=6;      //用户类型:0用户1客服
+  int64 userType=6;      //用户类型:2用户1客服
   int64 pageIndex = 2;
   int64 pageSize = 3;
   string send_user_id = 4;
@@ -56,21 +58,20 @@ message MessageResp {
 message MessageEntity {
   string title = 1;
   string content = 2;
-  string item = 3;
-  string type = 4;
+  int64 item = 3;
+  int64 type = 4;
   string link = 5;
   string create_time = 6;
   string appid=7;
   int64 itemType=8;
   string send_user_id=9;
   string receive_user_id=10;
+  int64 own_type =11;//拥有者类型;1:用户 2:会话
 }
 
 service messageCenter {
   // 查询数量
   rpc Count(CountReq) returns (CountResp);
-  // 获取消息
-  rpc GetLast(GetReq)   returns (GetResp);
   // 用户列表查询
   rpc UserList(UserReq) returns(UserResp);
   // 聊天内容查询

+ 0 - 8
rpc/messagecenter/messagecenter/messagecenter.go

@@ -14,8 +14,6 @@ type (
 	MessageCenter interface {
 		//  查询数量
 		Count(ctx context.Context, in *CountReq, opts ...grpc.CallOption) (*CountResp, error)
-		//  获取消息
-		GetLast(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetResp, error)
 		//  用户列表查询
 		UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error)
 		//  聊天内容查询
@@ -41,12 +39,6 @@ func (m *defaultMessageCenter) Count(ctx context.Context, in *CountReq, opts ...
 	return client.Count(ctx, in, opts...)
 }
 
-//  获取消息
-func (m *defaultMessageCenter) GetLast(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetResp, error) {
-	client := NewMessageCenterClient(m.cli.Conn())
-	return client.GetLast(ctx, in, opts...)
-}
-
 //  用户列表查询
 func (m *defaultMessageCenter) UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())

+ 113 - 89
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -26,7 +26,7 @@ type CountReq struct {
 	unknownFields protoimpl.UnknownFields
 
 	MsgType   int64  `protobuf:"varint,1,opt,name=msgType,proto3" json:"msgType,omitempty"`    // 消息类型 ;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息
-	UserType  int64  `protobuf:"varint,2,opt,name=userType,proto3" json:"userType,omitempty"`  //用户类型:0用户1客服
+	UserType  int64  `protobuf:"varint,2,opt,name=userType,proto3" json:"userType,omitempty"`  //用户类型:2用户1客服
 	SendId    string `protobuf:"bytes,3,opt,name=sendId,proto3" json:"sendId,omitempty"`       // 发送方id
 	EntId     int64  `protobuf:"varint,4,opt,name=entId,proto3" json:"entId,omitempty"`        //企业标识
 	ReceiveId string `protobuf:"bytes,5,opt,name=receiveId,proto3" json:"receiveId,omitempty"` // 接收方id
@@ -273,7 +273,9 @@ type UserReq struct {
 	StartTime         string `protobuf:"bytes,2,opt,name=startTime,proto3" json:"startTime,omitempty"`
 	EndTime           string `protobuf:"bytes,3,opt,name=endTime,proto3" json:"endTime,omitempty"`
 	CustomerServiceId string `protobuf:"bytes,4,opt,name=customer_service_id,json=customerServiceId,proto3" json:"customer_service_id,omitempty"`
-	UserType          int64  `protobuf:"varint,5,opt,name=userType,proto3" json:"userType,omitempty"` //用户类型:0用户1客服
+	UserType          int64  `protobuf:"varint,5,opt,name=userType,proto3" json:"userType,omitempty"` //用户类型:2用户1客服
+	PageIndex         int64  `protobuf:"varint,6,opt,name=pageIndex,proto3" json:"pageIndex,omitempty"`
+	PageSize          int64  `protobuf:"varint,7,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
 }
 
 func (x *UserReq) Reset() {
@@ -343,6 +345,20 @@ func (x *UserReq) GetUserType() int64 {
 	return 0
 }
 
+func (x *UserReq) GetPageIndex() int64 {
+	if x != nil {
+		return x.PageIndex
+	}
+	return 0
+}
+
+func (x *UserReq) GetPageSize() int64 {
+	if x != nil {
+		return x.PageSize
+	}
+	return 0
+}
+
 type UserResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -451,7 +467,7 @@ type MessageReq struct {
 	unknownFields protoimpl.UnknownFields
 
 	MsgType    int64  `protobuf:"varint,1,opt,name=msgType,proto3" json:"msgType,omitempty"`   // 消息类型 ;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息
-	UserType   int64  `protobuf:"varint,6,opt,name=userType,proto3" json:"userType,omitempty"` //用户类型:0用户1客服
+	UserType   int64  `protobuf:"varint,6,opt,name=userType,proto3" json:"userType,omitempty"` //用户类型:2用户1客服
 	PageIndex  int64  `protobuf:"varint,2,opt,name=pageIndex,proto3" json:"pageIndex,omitempty"`
 	PageSize   int64  `protobuf:"varint,3,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
 	SendUserId string `protobuf:"bytes,4,opt,name=send_user_id,json=sendUserId,proto3" json:"send_user_id,omitempty"`
@@ -610,14 +626,15 @@ type MessageEntity struct {
 
 	Title         string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
 	Content       string `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
-	Item          string `protobuf:"bytes,3,opt,name=item,proto3" json:"item,omitempty"`
-	Type          string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
+	Item          int64  `protobuf:"varint,3,opt,name=item,proto3" json:"item,omitempty"`
+	Type          int64  `protobuf:"varint,4,opt,name=type,proto3" json:"type,omitempty"`
 	Link          string `protobuf:"bytes,5,opt,name=link,proto3" json:"link,omitempty"`
 	CreateTime    string `protobuf:"bytes,6,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
 	Appid         string `protobuf:"bytes,7,opt,name=appid,proto3" json:"appid,omitempty"`
 	ItemType      int64  `protobuf:"varint,8,opt,name=itemType,proto3" json:"itemType,omitempty"`
 	SendUserId    string `protobuf:"bytes,9,opt,name=send_user_id,json=sendUserId,proto3" json:"send_user_id,omitempty"`
 	ReceiveUserId string `protobuf:"bytes,10,opt,name=receive_user_id,json=receiveUserId,proto3" json:"receive_user_id,omitempty"`
+	OwnType       int64  `protobuf:"varint,11,opt,name=own_type,json=ownType,proto3" json:"own_type,omitempty"` //拥有者类型;1:用户 2:会话
 }
 
 func (x *MessageEntity) Reset() {
@@ -666,18 +683,18 @@ func (x *MessageEntity) GetContent() string {
 	return ""
 }
 
-func (x *MessageEntity) GetItem() string {
+func (x *MessageEntity) GetItem() int64 {
 	if x != nil {
 		return x.Item
 	}
-	return ""
+	return 0
 }
 
-func (x *MessageEntity) GetType() string {
+func (x *MessageEntity) GetType() int64 {
 	if x != nil {
 		return x.Type
 	}
-	return ""
+	return 0
 }
 
 func (x *MessageEntity) GetLink() string {
@@ -722,6 +739,13 @@ func (x *MessageEntity) GetReceiveUserId() string {
 	return ""
 }
 
+func (x *MessageEntity) GetOwnType() int64 {
+	if x != nil {
+		return x.OwnType
+	}
+	return 0
+}
+
 var File_messageCenter_proto protoreflect.FileDescriptor
 
 var file_messageCenter_proto_rawDesc = []byte{
@@ -748,7 +772,7 @@ var file_messageCenter_proto_rawDesc = []byte{
 	0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f,
 	0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54,
 	0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74,
-	0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xa3, 0x01, 0x0a, 0x07, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
+	0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xdd, 0x01, 0x0a, 0x07, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
 	0x71, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74,
 	0x54, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72,
@@ -758,76 +782,78 @@ var file_messageCenter_proto_rawDesc = []byte{
 	0x69, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x63, 0x75,
 	0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12,
 	0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28,
-	0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x22, 0x39, 0x0a, 0x08, 0x55,
-	0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18,
-	0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63,
-	0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79,
-	0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x40, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e,
-	0x74, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08,
-	0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
-	0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xb5, 0x01, 0x0a, 0x0a, 0x4d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x79,
-	0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70,
-	0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20,
-	0x01, 0x28, 0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a,
-	0x09, 0x70, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
-	0x52, 0x09, 0x70, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x70,
-	0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70,
-	0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f,
-	0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73,
-	0x65, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x6f, 0x77, 0x6e,
-	0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x49, 0x64,
-	0x22, 0x91, 0x01, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70,
-	0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
-	0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02,
-	0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
-	0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74, 0x69,
-	0x74, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f,
-	0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72,
-	0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72,
-	0x5f, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f,
-	0x72, 0x4d, 0x73, 0x67, 0x22, 0x98, 0x02, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18,
-	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07,
-	0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63,
-	0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x03,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79,
-	0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12,
-	0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69,
-	0x6e, 0x6b, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d,
-	0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54,
-	0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x74, 0x65,
-	0x6d, 0x54, 0x79, 0x70, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x74, 0x65,
-	0x6d, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x75, 0x73,
-	0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x6e,
-	0x64, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x72, 0x65, 0x63, 0x65, 0x69,
-	0x76, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09,
-	0x52, 0x0d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x32,
-	0xd1, 0x02, 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x65, 0x6e, 0x74, 0x65,
-	0x72, 0x12, 0x3a, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x17, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74,
-	0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e,
-	0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x38, 0x0a,
-	0x07, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x73, 0x74, 0x12, 0x15, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
-	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a,
-	0x16, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
-	0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3b, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4c,
-	0x69, 0x73, 0x74, 0x12, 0x16, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e,
-	0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x65,
-	0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72,
-	0x52, 0x65, 0x73, 0x70, 0x12, 0x44, 0x0a, 0x0b, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73,
-	0x61, 0x67, 0x65, 0x12, 0x19, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e,
-	0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1a,
+	0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70,
+	0x61, 0x67, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09,
+	0x70, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67,
+	0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67,
+	0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x39, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73,
+	0x70, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
+	0x19, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
+	0x55, 0x73, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
+	0x22, 0x40, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x16,
+	0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
+	0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61,
+	0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61,
+	0x6d, 0x65, 0x22, 0xb5, 0x01, 0x0a, 0x0a, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65,
+	0x71, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x07, 0x6d, 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x75,
+	0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x75,
+	0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x49,
+	0x6e, 0x64, 0x65, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x61, 0x67, 0x65,
+	0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a,
+	0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a,
+	0x65, 0x12, 0x20, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69,
+	0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x6e, 0x64, 0x55, 0x73, 0x65,
+	0x72, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x6f, 0x77, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x49, 0x64, 0x22, 0x91, 0x01, 0x0a, 0x0b, 0x4d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f,
+	0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74,
+	0x12, 0x30, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c,
+	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, 0x04, 0x64, 0x61,
+	0x74, 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65,
+	0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64,
+	0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x03,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x22, 0xb3,
+	0x02, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79,
+	0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
+	0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
+	0x12, 0x12, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04,
+	0x69, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b,
+	0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x1f, 0x0a, 0x0b,
+	0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28,
+	0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a,
+	0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70,
+	0x70, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x18,
+	0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x74, 0x65, 0x6d, 0x54, 0x79, 0x70, 0x65, 0x12,
+	0x20, 0x0a, 0x0c, 0x73, 0x65, 0x6e, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18,
+	0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x49,
+	0x64, 0x12, 0x26, 0x0a, 0x0f, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x75, 0x73, 0x65,
+	0x72, 0x5f, 0x69, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x72, 0x65, 0x63, 0x65,
+	0x69, 0x76, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x77, 0x6e,
+	0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6f, 0x77, 0x6e,
+	0x54, 0x79, 0x70, 0x65, 0x32, 0x97, 0x02, 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+	0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12,
+	0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e,
+	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x3b, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x16,
+	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55,
+	0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x44, 0x0a, 0x0b, 0x46, 0x69, 0x6e, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x19,
 	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d,
-	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x47, 0x0a, 0x0b, 0x53, 0x61,
-	0x76, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x2e, 0x6d, 0x65, 0x73, 0x73,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73,
 	0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52,
-	0x65, 0x73, 0x70, 0x42, 0x11, 0x5a, 0x0f, 0x2e, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x47, 0x0a, 0x0b, 0x53, 0x61, 0x76, 0x65, 0x4d, 0x65, 0x73,
+	0x73, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
+	0x6e, 0x74, 0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74, 0x69,
+	0x74, 0x79, 0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74,
+	0x65, 0x72, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x11,
+	0x5a, 0x0f, 0x2e, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65,
+	0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -859,17 +885,15 @@ var file_messageCenter_proto_depIdxs = []int32{
 	6, // 0: messagecenter.UserResp.data:type_name -> messagecenter.UserEntity
 	9, // 1: messagecenter.MessageResp.data:type_name -> messagecenter.MessageEntity
 	0, // 2: messagecenter.messageCenter.Count:input_type -> messagecenter.CountReq
-	2, // 3: messagecenter.messageCenter.GetLast:input_type -> messagecenter.GetReq
-	4, // 4: messagecenter.messageCenter.UserList:input_type -> messagecenter.UserReq
-	7, // 5: messagecenter.messageCenter.FindMessage:input_type -> messagecenter.MessageReq
-	9, // 6: messagecenter.messageCenter.SaveMessage:input_type -> messagecenter.MessageEntity
-	1, // 7: messagecenter.messageCenter.Count:output_type -> messagecenter.CountResp
-	3, // 8: messagecenter.messageCenter.GetLast:output_type -> messagecenter.GetResp
-	5, // 9: messagecenter.messageCenter.UserList:output_type -> messagecenter.UserResp
-	8, // 10: messagecenter.messageCenter.FindMessage:output_type -> messagecenter.MessageResp
-	8, // 11: messagecenter.messageCenter.SaveMessage:output_type -> messagecenter.MessageResp
-	7, // [7:12] is the sub-list for method output_type
-	2, // [2:7] is the sub-list for method input_type
+	4, // 3: messagecenter.messageCenter.UserList:input_type -> messagecenter.UserReq
+	7, // 4: messagecenter.messageCenter.FindMessage:input_type -> messagecenter.MessageReq
+	9, // 5: messagecenter.messageCenter.SaveMessage:input_type -> messagecenter.MessageEntity
+	1, // 6: messagecenter.messageCenter.Count:output_type -> messagecenter.CountResp
+	5, // 7: messagecenter.messageCenter.UserList:output_type -> messagecenter.UserResp
+	8, // 8: messagecenter.messageCenter.FindMessage:output_type -> messagecenter.MessageResp
+	8, // 9: messagecenter.messageCenter.SaveMessage:output_type -> messagecenter.MessageResp
+	6, // [6:10] is the sub-list for method output_type
+	2, // [2:6] 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

+ 0 - 38
rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go

@@ -24,8 +24,6 @@ const _ = grpc.SupportPackageIsVersion7
 type MessageCenterClient interface {
 	// 查询数量
 	Count(ctx context.Context, in *CountReq, opts ...grpc.CallOption) (*CountResp, error)
-	// 获取消息
-	GetLast(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetResp, error)
 	// 用户列表查询
 	UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error)
 	// 聊天内容查询
@@ -51,15 +49,6 @@ func (c *messageCenterClient) Count(ctx context.Context, in *CountReq, opts ...g
 	return out, nil
 }
 
-func (c *messageCenterClient) GetLast(ctx context.Context, in *GetReq, opts ...grpc.CallOption) (*GetResp, error) {
-	out := new(GetResp)
-	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/GetLast", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
 func (c *messageCenterClient) UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error) {
 	out := new(UserResp)
 	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/UserList", in, out, opts...)
@@ -93,8 +82,6 @@ func (c *messageCenterClient) SaveMessage(ctx context.Context, in *MessageEntity
 type MessageCenterServer interface {
 	// 查询数量
 	Count(context.Context, *CountReq) (*CountResp, error)
-	// 获取消息
-	GetLast(context.Context, *GetReq) (*GetResp, error)
 	// 用户列表查询
 	UserList(context.Context, *UserReq) (*UserResp, error)
 	// 聊天内容查询
@@ -111,9 +98,6 @@ type UnimplementedMessageCenterServer struct {
 func (UnimplementedMessageCenterServer) Count(context.Context, *CountReq) (*CountResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method Count not implemented")
 }
-func (UnimplementedMessageCenterServer) GetLast(context.Context, *GetReq) (*GetResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method GetLast not implemented")
-}
 func (UnimplementedMessageCenterServer) UserList(context.Context, *UserReq) (*UserResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method UserList not implemented")
 }
@@ -154,24 +138,6 @@ func _MessageCenter_Count_Handler(srv interface{}, ctx context.Context, dec func
 	return interceptor(ctx, in, info, handler)
 }
 
-func _MessageCenter_GetLast_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(GetReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(MessageCenterServer).GetLast(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/messagecenter.messageCenter/GetLast",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(MessageCenterServer).GetLast(ctx, req.(*GetReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
 func _MessageCenter_UserList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(UserReq)
 	if err := dec(in); err != nil {
@@ -237,10 +203,6 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "Count",
 			Handler:    _MessageCenter_Count_Handler,
 		},
-		{
-			MethodName: "GetLast",
-			Handler:    _MessageCenter_GetLast_Handler,
-		},
 		{
 			MethodName: "UserList",
 			Handler:    _MessageCenter_UserList_Handler,

+ 85 - 55
entity/message_mail_box.go → service/message_mail_box.go

@@ -1,9 +1,9 @@
-package entity
+package service
 
 import (
-	"app.yhyue.com/moapp/jybase/common"
 	"database/sql"
 	"log"
+	. "messagecenter/rpc/messagecenter/init"
 	"messagecenter/rpc/messagecenter/messagecenter"
 	"time"
 )
@@ -34,38 +34,6 @@ type MessageMailBox struct {
 func (b MessageMailBox) Table() string {
 	return "socialize_message_mailbox"
 }
-func (b MessageMailBox) GetLast(receiveId, sendId string, msgType int) (messageBox map[string]interface{}, err error) {
-	q := "select create_time,isread,messag_id from socialize_message_mailbox where own_id=? "
-	v := []interface{}{
-		receiveId,
-	}
-	if sendId != "" {
-		q += "and  (send_user_id=? and receive_user_id=?) or (receive_user_id=? and send_user_id=?)"
-		v = append(v, sendId, receiveId, sendId, receiveId)
-	} else {
-		q += " receive_user_id=?"
-		v = append(v, receiveId)
-	}
-	if msgType != 0 {
-		q += " and type = ?"
-		v = append(v, msgType)
-	}
-	q += " order by create_time limit 0,1"
-	rs := Mysql.SelectBySql(q, v...)
-	if rs != nil && len(*rs) > 0 {
-		msg := (*rs)[0]
-		m := Message{}
-		msgId := common.IntAll(msg["messag_id"])
-		message := m.Get(msgId)
-		msg["content"] = message["content"]
-		msg["title"] = message["title"]
-		msg["item"] = message["item"]
-		msg["type"] = message["type"]
-		msg["link"] = message["link"]
-		return msg, err
-	}
-	return map[string]interface{}{}, nil
-}
 func (b MessageMailBox) Count(receiveId, sendId string, msgType, userType, entId int) (count int, err error) {
 	v := []interface{}{
 		receiveId,
@@ -94,7 +62,7 @@ func (b MessageMailBox) Count(receiveId, sendId string, msgType, userType, entId
 		break
 	case 5: //客服消息
 		//只查询属于自己和某个企业的会话信息
-		if userType == 0 {
+		if userType == 2 {
 			sql = "select  count(b.id) from   socialize_chat_session a  left  join  socialize_message_mailbox  b on a.id=b.receive_user_id where  b.type=4 and  b.own_id=?  and   (b.receive_user_id=? or b.send_user_id=?) and a.ent_id=?  and  b.isread=0 order by create_time"
 		} else {
 			sql = "select  count(b.id) from   socialize_chat_session a  left  join  socialize_message_mailbox  b on a.id=b.receive_user_id where (b.type=4 or b.type=5) and  b.own_id=?  and   (b.receive_user_id=? or b.send_user_id=?) and a.ent_id=?  and  b.isread=0 order by create_time"
@@ -112,7 +80,7 @@ func (b MessageMailBox) UserList(receiveId string, userType int, phone, startTim
 		receiveId,
 	}
 	sql := ""
-	if userType == 0 {
+	if userType == 2 {
 		//用户的客户列表
 		sql = "SELECT   a.*  FROM   socialize_message_mailbox b   LEFT JOIN base_user a ON a.id = b.receive_user_id  OR a.id = b.send_user_id  WHERE   b.type = 2  AND b.own_id = ?  AND (  b.receive_user_id = ? OR b.send_user_id = ? )  AND a.id != ?  GROUP BY   a.id  "
 		v = append(v, receiveId, receiveId, receiveId)
@@ -139,26 +107,44 @@ func (b MessageMailBox) SaveMessage(in *messagecenter.MessageEntity) (error_code
 			"create_person": in.SendUserId,
 		}
 		ok := Mysql.InsertByTx(tx, "socialize_message", message)
-		if ok > 0 {
+		if ok == 0 {
 			return false
 		}
 		//在插入邮箱表socialize_message_mailbox
 		messageMailBox := map[string]interface{}{
-			"appid":           in.Appid,
-			"messag_id":       ok,
-			"type":            in.ItemType,
-			"send_user_id":    in.SendUserId,
-			"receive_user_id": in.ReceiveUserId,
-			"own_id":          in.SendUserId,
-			"read_time":       time.Now(),
-			"create_time":     time.Now(),
-			"isread":          1,
-			"send_isdel":      0,
-			"receive_isdel":   0,
-			"iswithdraw":      0,
+			"appid":         in.Appid,
+			"messag_id":     ok,
+			"type":          in.ItemType,
+			"read_time":     time.Now(),
+			"create_time":   time.Now(),
+			"isread":        1,
+			"send_isdel":    0,
+			"receive_isdel": 0,
+			"iswithdraw":    0,
 		}
-		sendOk := Mysql.InsertByTx(tx, "socialize_message", messageMailBox)
-		if sendOk > 0 {
+		if in.ItemType == 4 || in.ItemType == 5 {
+			//客服或者机器人聊天
+			if in.OwnType == 1 {
+				//客服发送信息
+				messageMailBox["own_type"] = 1
+				messageMailBox["own_id"] = in.SendUserId
+				messageMailBox["send_user_id"] = in.SendUserId
+				messageMailBox["receive_user_id"] = in.ReceiveUserId
+			} else {
+				//用户发送信息
+				messageMailBox["own_type"] = 2
+				messageMailBox["own_id"] = in.SendUserId
+				messageMailBox["send_user_id"] = in.SendUserId
+				messageMailBox["receive_user_id"] = in.ReceiveUserId
+			}
+		} else {
+			messageMailBox["own_type"] = 2
+			messageMailBox["own_id"] = in.SendUserId
+			messageMailBox["send_user_id"] = in.SendUserId
+			messageMailBox["receive_user_id"] = in.ReceiveUserId
+		}
+		sendOk := Mysql.InsertByTx(tx, "socialize_message_mailbox", messageMailBox)
+		if sendOk == 0 {
 			return false
 		}
 		messageMailBox = map[string]interface{}{
@@ -174,16 +160,60 @@ func (b MessageMailBox) SaveMessage(in *messagecenter.MessageEntity) (error_code
 			"receive_isdel":   0,
 			"iswithdraw":      0,
 		}
-		receiveOk := Mysql.InsertByTx(tx, "socialize_message", messageMailBox)
-		if receiveOk > 0 {
+		if in.ItemType == 4 || in.ItemType == 5 {
+			//客服或者机器人聊天
+			if in.OwnType == 1 {
+				//客服发送信息(接受者为用户)
+				messageMailBox["own_type"] = 2
+				messageMailBox["own_id"] = in.ReceiveUserId
+				messageMailBox["send_user_id"] = in.SendUserId
+				messageMailBox["receive_user_id"] = in.ReceiveUserId
+			} else {
+				//用户发送信息(接受者客服)
+				messageMailBox["own_type"] = 1
+				messageMailBox["own_id"] = in.ReceiveUserId
+				messageMailBox["send_user_id"] = in.SendUserId
+				messageMailBox["receive_user_id"] = in.ReceiveUserId
+			}
+		} else {
+			messageMailBox["own_type"] = 2
+			messageMailBox["own_id"] = in.ReceiveUserId
+			messageMailBox["send_user_id"] = in.SendUserId
+			messageMailBox["receive_user_id"] = in.ReceiveUserId
+		}
+		receiveOk := Mysql.InsertByTx(tx, "socialize_message_mailbox", messageMailBox)
+		if receiveOk == 0 {
 			return false
 		}
 		return true
 	})
 	if fool {
-		return 1
-	} else {
 		return 0
+	} else {
+		return 1
 	}
 
 }
+func (b MessageMailBox) FindMessage(in *messagecenter.MessageReq) *[]map[string]interface{} {
+	sql := ""
+	v := []interface{}{}
+	switch in.MsgType {
+	case 2: //点对点聊天
+		sql = "SELECT     b.* ,a.send_user_id,a.receive_user_id,c.nickname,d.nickname     FROM     socialize_message_mailbox a     LEFT JOIN socialize_message b on  a.messag_id=b.id     left  join  base_user c on  c.id=a.send_user_id      left join  base_user d on  d.id=a.receive_user_id     where  a.own_id=? and ((a.send_user_id=? and   a.receive_user_id=?) or (a.send_user_id=? and  a.receive_user_id=?)) and  a.type=2"
+		v = append(v, in.OwnId, in.OwnId, in.SendUserId, in.SendUserId, in.OwnId)
+		break
+	case 5: //客服聊天
+		if in.UserType == 1 {
+			//客服聊天记录查看
+			sql = "SELECT   *     FROM   socialize_message_mailbox a    left join  socialize_message b on  a.messag_id=b.id       left join  socialize_chat_session c on (a.receive_user_id=c.id  or  a.send_user_id=c.id )    where  a.own_type=1 and   c.customer_service_id=?  and a.iswithdraw=0 and  c.user_id=?"
+			v = append(v, in.OwnId, in.SendUserId)
+		} else {
+			//用户聊天记录查看
+			sql = "SELECT    b.*    FROM    socialize_message_mailbox a     left join  socialize_message b on  a.messag_id=b.id        left join  socialize_chat_session c on (a.receive_user_id=c.id  or  a.send_user_id=c.id )     where  a.own_type=2 and   c.ent_id=?  and a.iswithdraw=0 and  a.own_id=?"
+			v = append(v, in.SendUserId, in.OwnId)
+		}
+		break
+	}
+	data := Mysql.SelectBySql(sql, v)
+	return data
+}