Browse Source

信息标识加密

WH01243 3 years ago
parent
commit
36ebb2506c

+ 1 - 1
api/messagecenter/internal/logic/findmessagelogic.go

@@ -31,7 +31,7 @@ func (l *FindMessageLogic) FindMessage(req *types.MessageReq) (*types.CommonRes,
 		UserType:  req.UserType,
 		MsgType:   req.MsgType,
 		SendId:    quitl.Int64All(encrypt.SE.Decode4Hex(req.SendId)),
-		LastId:    req.LastId,
+		LastId:    quitl.Int64All(encrypt.SE.Decode4Hex(req.LastId)),
 		EntId:     req.EntId,
 		PageSize:  req.PageSize,
 		EntUserId: req.EntUserId,

+ 1 - 1
api/messagecenter/internal/types/types.go

@@ -41,7 +41,7 @@ type MessageReq struct {
 	MsgType   int64  `json:"msgType"`
 	UserType  int64  `json:"userType"`
 	SendId    string `json:"sendId,optional"`
-	LastId    int64  `json:"lastId,optional"`
+	LastId    string `json:"lastId,optional"`
 	PageSize  int64  `json:"pageSize"`
 	NewUserId int64  `header:"newUserId"`
 	EntUserId int64  `header:"entUserId,optional"`

+ 1 - 1
api/messagecenter/messagecenter.api

@@ -35,7 +35,7 @@ type MessageReq {
 	MsgType   int64  `json:"msgType"`
 	UserType  int64  `json:"userType"`
 	SendId    string `json:"sendId,optional"`
-	LastId    int64  `json:"lastId,optional"`
+	LastId    string `json:"lastId,optional"`
 	PageSize  int64  `json:"pageSize"`
 	NewUserId int64  `header:"newUserId"`
 	EntUserId int64  `header:"entUserId,optional"`

+ 2 - 1
rpc/messagecenter/internal/logic/findmessagelogic.go

@@ -2,6 +2,7 @@ package logic
 
 import (
 	quitl "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
 	"context"
 
@@ -45,7 +46,7 @@ func (l *FindMessageLogic) FindMessage(in *messagecenter.MessageReq) (*messagece
 			RobotImg:   quitl.ObjToString(v["robotImg"]),
 			SetName:    quitl.ObjToString(v["setName"]),
 			OwnImg:     quitl.ObjToString(v["ownImg"]),
-			MessageId:  quitl.Int64All(v["messageId"]),
+			MessageId:  encrypt.SE.Encode2Hex(quitl.InterfaceToStr(v["messageId"])),
 		}
 		list = append(list, &messageEntity)
 	}

+ 9 - 2
rpc/messagecenter/internal/logic/saveautoreplymsglogic.go

@@ -1,6 +1,8 @@
 package logic
 
 import (
+	quitl "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
 	"context"
 
@@ -28,12 +30,17 @@ func NewSaveAutoReplyMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
 func (l *SaveAutoReplyMsgLogic) SaveAutoReplyMsg(in *messagecenter.SaveAutoReplyReq) (*messagecenter.MessageResp, error) {
 	// todo: add your logic here and delete this line
 	m := service.MessaggeService{}
-	error_code := m.SaveAutoReplyMsg(in.UserType, in.EntId, in.EntUserId, in.UserId, in.Content, in.AppId, in.NowFormat)
-	error_message := "保存失败"
+	error_code, messageId := m.SaveAutoReplyMsg(in.UserType, in.EntId, in.EntUserId, in.UserId, in.Content, in.AppId, in.NowFormat)
+	error_message := ""
 	if error_code {
 		return &messagecenter.MessageResp{
 			ErrorCode: 0,
 			ErrorMsg:  error_message,
+			Data: []*messagecenter.MessageEntity{
+				{
+					MessageId: encrypt.SE.Encode2Hex(quitl.InterfaceToStr(messageId)),
+				},
+			},
 		}, nil
 	} else {
 		return &messagecenter.MessageResp{

+ 3 - 1
rpc/messagecenter/internal/logic/savemessagelogic.go

@@ -1,6 +1,8 @@
 package logic
 
 import (
+	quitl "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/service"
 	"context"
 
@@ -40,7 +42,7 @@ func (l *SaveMessageLogic) SaveMessage(in *messagecenter.MessageEntity) (*messag
 		ErrorMsg:  error_message,
 		Data: &messagecenter.MessageEntity{
 			Content:   content,
-			MessageId: messageId,
+			MessageId: encrypt.SE.Encode2Hex(quitl.InterfaceToStr(messageId)),
 		},
 	}, nil
 }

+ 1 - 1
rpc/messagecenter/messagecenter.proto

@@ -81,7 +81,7 @@ message MessageEntity {
   string        setName=15;
   int64         receiveId=17;
   string        ownImg=18;
-  int64         messageId=19;
+  string        messageId=19;
 }
 
 message ChatSessionReq {

+ 4 - 4
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -699,7 +699,7 @@ type MessageEntity struct {
 	SetName    string `protobuf:"bytes,15,opt,name=setName,proto3" json:"setName,omitempty"`
 	ReceiveId  int64  `protobuf:"varint,17,opt,name=receiveId,proto3" json:"receiveId,omitempty"`
 	OwnImg     string `protobuf:"bytes,18,opt,name=ownImg,proto3" json:"ownImg,omitempty"`
-	MessageId  int64  `protobuf:"varint,19,opt,name=messageId,proto3" json:"messageId,omitempty"`
+	MessageId  string `protobuf:"bytes,19,opt,name=messageId,proto3" json:"messageId,omitempty"`
 }
 
 func (x *MessageEntity) Reset() {
@@ -860,11 +860,11 @@ func (x *MessageEntity) GetOwnImg() string {
 	return ""
 }
 
-func (x *MessageEntity) GetMessageId() int64 {
+func (x *MessageEntity) GetMessageId() string {
 	if x != nil {
 		return x.MessageId
 	}
-	return 0
+	return ""
 }
 
 type ChatSessionReq struct {
@@ -1375,7 +1375,7 @@ var file_messageCenter_proto_rawDesc = []byte{
 	0x01, 0x28, 0x03, 0x52, 0x09, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x49, 0x64, 0x12, 0x16,
 	0x0a, 0x06, 0x6f, 0x77, 0x6e, 0x49, 0x6d, 0x67, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
 	0x6f, 0x77, 0x6e, 0x49, 0x6d, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
-	0x65, 0x49, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x65, 0x49, 0x64, 0x18, 0x13, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61,
 	0x67, 0x65, 0x49, 0x64, 0x22, 0xb4, 0x01, 0x0a, 0x0e, 0x43, 0x68, 0x61, 0x74, 0x53, 0x65, 0x73,
 	0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64,
 	0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2c, 0x0a,

+ 4 - 3
service/message_mail_box.go

@@ -364,7 +364,8 @@ func (b MessaggeService) CloseChatSession(in *messagecenter.CloseSessionReq) boo
 	return fool
 }
 
-func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId int64, content, appId, nowFormat string) bool {
+func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId int64, content, appId, nowFormat string) (bool, int64) {
+	messageId := int64(0)
 	return util.Mysql.ExecTx("保存自动回复消息", func(tx *sql.Tx) bool {
 		entUserName := ""
 		if entUserId > 0 {
@@ -373,7 +374,7 @@ func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId in
 				entUserName, _ = (*list)[0]["customer_service_name"].(string)
 			}
 		}
-		messageId := util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message (appid,content,item,type,create_time,create_person) values (?,?,?,?,?,?)`, appId, content, 8, 1, nowFormat, "admin")
+		messageId = util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message (appid,content,item,type,create_time,create_person) values (?,?,?,?,?,?)`, appId, content, 8, 1, nowFormat, "admin")
 		sessionId := util.Mysql.InsertBySqlByTx(tx, `insert into socialize_chat_session (appid,type,ent_id,customer_service_id,customer_service_name,user_id,start_time,end_time) values (?,?,?,?,?,?,?,?)`, appId, 1, entId, entUserId, entUserName, userId, nowFormat, nowFormat)
 		ok := false
 		if userType == 0 {
@@ -386,7 +387,7 @@ func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId in
 			ok = util.Mysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time) values (?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, userId, 2, nowFormat) > 0
 		}
 		return messageId > 0 && sessionId > 0 && ok
-	})
+	}), messageId
 }
 func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) bool {
 	fool := util.Mysql.ExecTx("已读状态修改", func(tx *sql.Tx) bool {