Procházet zdrojové kódy

已读状态修改

WH01243 před 3 roky
rodič
revize
30e741b3bf

+ 5 - 0
api/messagecenter/internal/handler/routes.go

@@ -47,6 +47,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/message/obtainShunt",
 				Handler: obtainShuntHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/updateReadById",
+				Handler: updateReadByIdHandler(serverCtx),
+			},
 		},
 	)
 }

+ 4 - 0
api/messagecenter/internal/types/types.go

@@ -75,3 +75,7 @@ type CloseSessionReq struct {
 type ShuntReq struct {
 	Type string `json:"type"`
 }
+
+type ReadStateReq struct {
+	MessageId int64 `json:"messageId"`
+}

+ 5 - 0
api/messagecenter/messagecenter.api

@@ -66,6 +66,9 @@ type CloseSessionReq {
 type ShuntReq {
 	Type string `json:"type"`
 }
+type ReadStateReq {
+	MessageId int64 `json:"messageId"`
+}
 service messagecenter-api {
 	@handler messageCount
 	post /message/messageCount (CountReq) returns (CommonRes);
@@ -81,4 +84,6 @@ service messagecenter-api {
 	post /message/closeChatSession (CloseSessionReq) returns (CommonRes);
 	@handler obtainShunt
 	post /message/obtainShunt (ShuntReq) returns (CommonRes);
+	@handler updateReadById
+	post /message/updateReadById (ReadStateReq) returns (CommonRes);
 }

+ 1 - 1
rpc/messagecenter/internal/logic/closechatsessionlogic.go

@@ -29,7 +29,7 @@ func (l *CloseChatSessionLogic) CloseChatSession(in *messagecenter.CloseSessionR
 	// todo: add your logic here and delete this line
 	m := service.MessaggeService{}
 	error_code := m.CloseChatSession(in)
-	error_message := "创建失败"
+	error_message := "修改失败"
 	if error_code == 0 {
 		error_message = ""
 	}

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

@@ -63,3 +63,9 @@ func (s *MessageCenterServer) SaveAutoReplyMsg(ctx context.Context, in *messagec
 	l := logic.NewSaveAutoReplyMsgLogic(ctx, s.svcCtx)
 	return l.SaveAutoReplyMsg(in)
 }
+
+// 根据消息修改已读状态
+func (s *MessageCenterServer) UpdateReadById(ctx context.Context, in *messagecenter.ReadStateReq) (*messagecenter.CurrencyResp, error) {
+	l := logic.NewUpdateReadByIdLogic(ctx, s.svcCtx)
+	return l.UpdateReadById(in)
+}

+ 9 - 0
rpc/messagecenter/messagecenter.proto

@@ -108,7 +108,14 @@ message SaveAutoReplyReq {
   string        appId = 6;
   string        nowFormat=7;
 }
+message ReadStateReq {
+  int64         messageId = 1;
+}
 
+message CurrencyResp {
+   int64 error_code = 2; //响应代码
+   string error_msg = 1; //响应消息
+}
 service messageCenter {
   // 查询数量
   rpc Count(CountReq) returns (CountResp);
@@ -124,4 +131,6 @@ service messageCenter {
   rpc CloseChatSession(CloseSessionReq) returns(ChatSessionResp);
    //创建会话并且保存信息
   rpc SaveAutoReplyMsg(SaveAutoReplyReq)returns(MessageResp);
+   //根据消息修改已读状态
+  rpc UpdateReadById(ReadStateReq)returns(CurrencyResp);
 }

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

@@ -26,6 +26,8 @@ type (
 		CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
 		// 创建会话并且保存信息
 		SaveAutoReplyMsg(ctx context.Context, in *SaveAutoReplyReq, opts ...grpc.CallOption) (*MessageResp, error)
+		// 根据消息修改已读状态
+		UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error)
 	}
 
 	defaultMessageCenter struct {
@@ -80,3 +82,9 @@ func (m *defaultMessageCenter) SaveAutoReplyMsg(ctx context.Context, in *SaveAut
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.SaveAutoReplyMsg(ctx, in, opts...)
 }
+
+// 根据消息修改已读状态
+func (m *defaultMessageCenter) UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.UpdateReadById(ctx, in, opts...)
+}

+ 187 - 45
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -1151,6 +1151,108 @@ func (x *SaveAutoReplyReq) GetNowFormat() string {
 	return ""
 }
 
+type ReadStateReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	MessageId int64 `protobuf:"varint,1,opt,name=messageId,proto3" json:"messageId,omitempty"`
+}
+
+func (x *ReadStateReq) Reset() {
+	*x = ReadStateReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_messageCenter_proto_msgTypes[13]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *ReadStateReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ReadStateReq) ProtoMessage() {}
+
+func (x *ReadStateReq) ProtoReflect() protoreflect.Message {
+	mi := &file_messageCenter_proto_msgTypes[13]
+	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 ReadStateReq.ProtoReflect.Descriptor instead.
+func (*ReadStateReq) Descriptor() ([]byte, []int) {
+	return file_messageCenter_proto_rawDescGZIP(), []int{13}
+}
+
+func (x *ReadStateReq) GetMessageId() int64 {
+	if x != nil {
+		return x.MessageId
+	}
+	return 0
+}
+
+type CurrencyResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ErrorCode int64  `protobuf:"varint,2,opt,name=error_code,json=errorCode,proto3" json:"error_code,omitempty"` //响应代码
+	ErrorMsg  string `protobuf:"bytes,1,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"`     //响应消息
+}
+
+func (x *CurrencyResp) Reset() {
+	*x = CurrencyResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_messageCenter_proto_msgTypes[14]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *CurrencyResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*CurrencyResp) ProtoMessage() {}
+
+func (x *CurrencyResp) ProtoReflect() protoreflect.Message {
+	mi := &file_messageCenter_proto_msgTypes[14]
+	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 CurrencyResp.ProtoReflect.Descriptor instead.
+func (*CurrencyResp) Descriptor() ([]byte, []int) {
+	return file_messageCenter_proto_rawDescGZIP(), []int{14}
+}
+
+func (x *CurrencyResp) GetErrorCode() int64 {
+	if x != nil {
+		return x.ErrorCode
+	}
+	return 0
+}
+
+func (x *CurrencyResp) GetErrorMsg() string {
+	if x != nil {
+		return x.ErrorMsg
+	}
+	return ""
+}
+
 var File_messageCenter_proto protoreflect.FileDescriptor
 
 var file_messageCenter_proto_rawDesc = []byte{
@@ -1308,42 +1410,54 @@ var file_messageCenter_proto_rawDesc = []byte{
 	0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
 	0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x77, 0x46, 0x6f, 0x72,
 	0x6d, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x77, 0x46, 0x6f,
-	0x72, 0x6d, 0x61, 0x74, 0x32, 0x94, 0x04, 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,
+	0x72, 0x6d, 0x61, 0x74, 0x22, 0x2c, 0x0a, 0x0c, 0x52, 0x65, 0x61, 0x64, 0x53, 0x74, 0x61, 0x74,
+	0x65, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49,
+	0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+	0x49, 0x64, 0x22, 0x4a, 0x0a, 0x0c, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65,
+	0x18, 0x02, 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, 0x01,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x32, 0xe0,
+	0x04, 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, 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, 0x52, 0x65, 0x73, 0x70, 0x12,
+	0x4b, 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, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x6d, 0x65, 0x73, 0x73,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x1a, 0x1e, 0x2e, 0x6d,
+	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x53, 0x61, 0x76,
+	0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x52, 0x0a, 0x11,
+	0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
+	0x6e, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65,
+	0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71,
+	0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72,
+	0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x52, 0x0a, 0x10, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73,
+	0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
+	0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
+	0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
+	0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
+	0x52, 0x65, 0x73, 0x70, 0x12, 0x4f, 0x0a, 0x10, 0x53, 0x61, 0x76, 0x65, 0x41, 0x75, 0x74, 0x6f,
+	0x52, 0x65, 0x70, 0x6c, 0x79, 0x4d, 0x73, 0x67, 0x12, 0x1f, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x41, 0x75, 0x74,
+	0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 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, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4b, 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, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74,
-	0x65, 0x72, 0x2e, 0x53, 0x61, 0x76, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x65,
-	0x73, 0x70, 0x12, 0x52, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x74,
-	0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73,
-	0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
-	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69,
-	0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x52, 0x0a, 0x10, 0x43, 0x6c, 0x6f, 0x73, 0x65, 0x43,
-	0x68, 0x61, 0x74, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6c, 0x6f, 0x73, 0x65,
-	0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x68, 0x61, 0x74, 0x53,
-	0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4f, 0x0a, 0x10, 0x53, 0x61,
-	0x76, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x4d, 0x73, 0x67, 0x12, 0x1f,
-	0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x53,
-	0x61, 0x76, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 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, 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, 0x4a, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x52,
+	0x65, 0x61, 0x64, 0x42, 0x79, 0x49, 0x64, 0x12, 0x1b, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x53, 0x74, 0x61, 0x74,
+	0x65, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x63, 0x65,
+	0x6e, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 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 (
@@ -1358,7 +1472,7 @@ func file_messageCenter_proto_rawDescGZIP() []byte {
 	return file_messageCenter_proto_rawDescData
 }
 
-var file_messageCenter_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
+var file_messageCenter_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
 var file_messageCenter_proto_goTypes = []interface{}{
 	(*CountReq)(nil),         // 0: messagecenter.CountReq
 	(*CountResp)(nil),        // 1: messagecenter.CountResp
@@ -1373,6 +1487,8 @@ var file_messageCenter_proto_goTypes = []interface{}{
 	(*CloseSessionReq)(nil),  // 10: messagecenter.CloseSessionReq
 	(*ChatSessionResp)(nil),  // 11: messagecenter.ChatSessionResp
 	(*SaveAutoReplyReq)(nil), // 12: messagecenter.SaveAutoReplyReq
+	(*ReadStateReq)(nil),     // 13: messagecenter.ReadStateReq
+	(*CurrencyResp)(nil),     // 14: messagecenter.CurrencyResp
 }
 var file_messageCenter_proto_depIdxs = []int32{
 	8,  // 0: messagecenter.CountResp.lastMessage:type_name -> messagecenter.MessageEntity
@@ -1386,15 +1502,17 @@ var file_messageCenter_proto_depIdxs = []int32{
 	9,  // 8: messagecenter.messageCenter.CreateChatSession:input_type -> messagecenter.ChatSessionReq
 	10, // 9: messagecenter.messageCenter.CloseChatSession:input_type -> messagecenter.CloseSessionReq
 	12, // 10: messagecenter.messageCenter.SaveAutoReplyMsg:input_type -> messagecenter.SaveAutoReplyReq
-	1,  // 11: messagecenter.messageCenter.Count:output_type -> messagecenter.CountResp
-	3,  // 12: messagecenter.messageCenter.UserList:output_type -> messagecenter.UserResp
-	6,  // 13: messagecenter.messageCenter.FindMessage:output_type -> messagecenter.MessageResp
-	7,  // 14: messagecenter.messageCenter.SaveMessage:output_type -> messagecenter.SaveMessageResp
-	11, // 15: messagecenter.messageCenter.CreateChatSession:output_type -> messagecenter.ChatSessionResp
-	11, // 16: messagecenter.messageCenter.CloseChatSession:output_type -> messagecenter.ChatSessionResp
-	6,  // 17: messagecenter.messageCenter.SaveAutoReplyMsg:output_type -> messagecenter.MessageResp
-	11, // [11:18] is the sub-list for method output_type
-	4,  // [4:11] is the sub-list for method input_type
+	13, // 11: messagecenter.messageCenter.UpdateReadById:input_type -> messagecenter.ReadStateReq
+	1,  // 12: messagecenter.messageCenter.Count:output_type -> messagecenter.CountResp
+	3,  // 13: messagecenter.messageCenter.UserList:output_type -> messagecenter.UserResp
+	6,  // 14: messagecenter.messageCenter.FindMessage:output_type -> messagecenter.MessageResp
+	7,  // 15: messagecenter.messageCenter.SaveMessage:output_type -> messagecenter.SaveMessageResp
+	11, // 16: messagecenter.messageCenter.CreateChatSession:output_type -> messagecenter.ChatSessionResp
+	11, // 17: messagecenter.messageCenter.CloseChatSession:output_type -> messagecenter.ChatSessionResp
+	6,  // 18: messagecenter.messageCenter.SaveAutoReplyMsg:output_type -> messagecenter.MessageResp
+	14, // 19: messagecenter.messageCenter.UpdateReadById:output_type -> messagecenter.CurrencyResp
+	12, // [12:20] is the sub-list for method output_type
+	4,  // [4:12] is the sub-list for method input_type
 	4,  // [4:4] is the sub-list for extension type_name
 	4,  // [4:4] is the sub-list for extension extendee
 	0,  // [0:4] is the sub-list for field type_name
@@ -1562,6 +1680,30 @@ func file_messageCenter_proto_init() {
 				return nil
 			}
 		}
+		file_messageCenter_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*ReadStateReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_messageCenter_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*CurrencyResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -1569,7 +1711,7 @@ func file_messageCenter_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_messageCenter_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   13,
+			NumMessages:   15,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

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

@@ -36,6 +36,8 @@ type MessageCenterClient interface {
 	CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
 	//创建会话并且保存信息
 	SaveAutoReplyMsg(ctx context.Context, in *SaveAutoReplyReq, opts ...grpc.CallOption) (*MessageResp, error)
+	//根据消息修改已读状态
+	UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error)
 }
 
 type messageCenterClient struct {
@@ -109,6 +111,15 @@ func (c *messageCenterClient) SaveAutoReplyMsg(ctx context.Context, in *SaveAuto
 	return out, nil
 }
 
+func (c *messageCenterClient) UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
+	out := new(CurrencyResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/UpdateReadById", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // MessageCenterServer is the server API for MessageCenter service.
 // All implementations must embed UnimplementedMessageCenterServer
 // for forward compatibility
@@ -127,6 +138,8 @@ type MessageCenterServer interface {
 	CloseChatSession(context.Context, *CloseSessionReq) (*ChatSessionResp, error)
 	//创建会话并且保存信息
 	SaveAutoReplyMsg(context.Context, *SaveAutoReplyReq) (*MessageResp, error)
+	//根据消息修改已读状态
+	UpdateReadById(context.Context, *ReadStateReq) (*CurrencyResp, error)
 	mustEmbedUnimplementedMessageCenterServer()
 }
 
@@ -155,6 +168,9 @@ func (UnimplementedMessageCenterServer) CloseChatSession(context.Context, *Close
 func (UnimplementedMessageCenterServer) SaveAutoReplyMsg(context.Context, *SaveAutoReplyReq) (*MessageResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method SaveAutoReplyMsg not implemented")
 }
+func (UnimplementedMessageCenterServer) UpdateReadById(context.Context, *ReadStateReq) (*CurrencyResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method UpdateReadById not implemented")
+}
 func (UnimplementedMessageCenterServer) mustEmbedUnimplementedMessageCenterServer() {}
 
 // UnsafeMessageCenterServer may be embedded to opt out of forward compatibility for this service.
@@ -294,6 +310,24 @@ func _MessageCenter_SaveAutoReplyMsg_Handler(srv interface{}, ctx context.Contex
 	return interceptor(ctx, in, info, handler)
 }
 
+func _MessageCenter_UpdateReadById_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ReadStateReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).UpdateReadById(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/UpdateReadById",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).UpdateReadById(ctx, req.(*ReadStateReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // MessageCenter_ServiceDesc is the grpc.ServiceDesc for MessageCenter service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -329,6 +363,10 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "SaveAutoReplyMsg",
 			Handler:    _MessageCenter_SaveAutoReplyMsg_Handler,
 		},
+		{
+			MethodName: "UpdateReadById",
+			Handler:    _MessageCenter_UpdateReadById_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "messageCenter.proto",

+ 15 - 0
service/message_mail_box.go

@@ -406,3 +406,18 @@ func (m *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId in
 		return messageId > 0 && sessionId > 0 && ok
 	})
 }
+func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) (errorCode int64) {
+	fool := util.Mysql.ExecTx("已读状态修改", func(tx *sql.Tx) bool {
+		updateMap := map[string]interface{}{
+			"messag_id": in.MessageId,
+			"isread":    0,
+		}
+		fool := util.Mysql.Update("socialize_message_mailbox", updateMap, map[string]interface{}{"read_time": time.Now().Local().Format(util.Date_Full_Layout), "isread": 1})
+		return fool
+	})
+	if fool {
+		return 0
+	} else {
+		return 1
+	}
+}

+ 66 - 7
service/message_mail_box_test.go

@@ -36,7 +36,7 @@ func TestMessaggeService_CloseChatSession(t *testing.T) {
 			name: "关闭会话",
 			args: args{
 				in: &messagecenter.CloseSessionReq{
-					SessionId: 4626,
+					SessionId: 514,
 				},
 			}},
 	}
@@ -164,6 +164,18 @@ func TestMessaggeService_FindMessage(t *testing.T) {
 			}},
 			want1: 0,
 		},
+		{
+			name: "用户获取客服历史信息查询",
+			args: args{in: &messagecenter.MessageReq{
+				MsgType:   4,
+				UserType:  2,
+				SendId:    10,
+				PageSize:  10,
+				NewUserId: 10,
+				EntId:     1,
+			}},
+			want1: 0,
+		},
 		{
 			name: "用户获取历史信息查询",
 			args: args{in: &messagecenter.MessageReq{
@@ -285,7 +297,7 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 					ItemType:  5,
 					Link:      "1111",
 					Appid:     "10000",
-					ReceiveId: 4626,
+					ReceiveId: 514,
 					OwnType:   int64(1),
 					Type:      1,
 					NewUserId: 10,
@@ -300,7 +312,7 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 					ItemType:  4,
 					Link:      "1111",
 					Appid:     "10000",
-					ReceiveId: 4626,
+					ReceiveId: 514,
 					OwnType:   int64(1),
 					Type:      1,
 					NewUserId: 10,
@@ -315,7 +327,7 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 					ItemType:  4,
 					Link:      "1111",
 					Appid:     "10000",
-					SendId:    4626,
+					SendId:    514,
 					OwnType:   int64(2),
 					Type:      1,
 					NewUserId: 10,
@@ -331,7 +343,7 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 					Link:      "1111",
 					Appid:     "10000",
 					ReceiveId: 10,
-					SendId:    4626,
+					SendId:    514,
 					OwnType:   int64(2),
 					Type:      1,
 					NewUserId: 10,
@@ -361,7 +373,7 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 					ItemType:  6,
 					Link:      "1111",
 					Appid:     "10000",
-					ReceiveId: 4626,
+					ReceiveId: 514,
 					OwnType:   int64(1),
 					Type:      1,
 					NewUserId: 10,
@@ -377,8 +389,9 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 					ItemType:  6,
 					Link:      "1111",
 					Appid:     "10000",
-					SendId:    4626,
+					SendId:    514,
 					OwnType:   int64(2),
+					ReceiveId: 10,
 					Type:      1,
 					NewUserId: 10,
 				},
@@ -414,6 +427,22 @@ func TestMessaggeService_SaveMessage(t *testing.T) {
 				},
 			},
 		},
+		{name: "会话标识不存在",
+			args: args{
+				in: &messagecenter.MessageEntity{
+					Title:     "11",
+					Content:   "问在吗?",
+					Item:      8,
+					ItemType:  4,
+					Link:      "1111",
+					Appid:     "10000",
+					ReceiveId: 640,
+					OwnType:   int64(1),
+					Type:      1,
+					NewUserId: 10,
+				},
+			},
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
@@ -486,3 +515,33 @@ func TestMessaggeService_UserList(t *testing.T) {
 		})
 	}
 }
+
+func TestMessaggeService_UpdateReadById(t *testing.T) {
+	type args struct {
+		in *messagecenter.ReadStateReq
+	}
+	tests := []struct {
+		name          string
+		args          args
+		wantErrorCode int64
+	}{
+		// TODO: Add test cases.
+		{
+			name: "已读状态修改",
+			args: args{
+				in: &messagecenter.ReadStateReq{
+					MessageId: 11612,
+				},
+			},
+			wantErrorCode: 0,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			b := MessaggeService{}
+			if gotErrorCode := b.UpdateReadById(tt.args.in); gotErrorCode != tt.wantErrorCode {
+				t.Errorf("UpdateReadById() = %v, want %v", gotErrorCode, tt.wantErrorCode)
+			}
+		})
+	}
+}