From cb487e3e794628c9a760f515d2645e696928b51b Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 26 Oct 2021 12:37:22 +0800 Subject: [PATCH] msg modify --- src/rpc/chat/chat/pull_message.go | 39 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/rpc/chat/chat/pull_message.go b/src/rpc/chat/chat/pull_message.go index 884e1dd9a..57a4e3897 100644 --- a/src/rpc/chat/chat/pull_message.go +++ b/src/rpc/chat/chat/pull_message.go @@ -19,30 +19,27 @@ func (rpc *rpcChat) GetMaxAndMinSeq(_ context.Context, in *pbMsg.GetMaxAndMinSeq maxSeq, err1 := commonDB.DB.GetUserMaxSeq(in.UserID) minSeq, err2 := commonDB.DB.GetUserMinSeq(in.UserID) resp := new(pbMsg.GetMaxAndMinSeqResp) - if err1 == nil && err2 == nil { + if err1 == nil { resp.MaxSeq = maxSeq - resp.MinSeq = minSeq - resp.ErrCode = 0 - resp.ErrMsg = "" - return resp, nil + } else if err1 == redis.ErrNil { + resp.MaxSeq = 0 } else { - if err1 == redis.ErrNil { - resp.MaxSeq = 0 - } else if err1 != nil { - log.NewInfo(in.OperationID, "getMaxSeq from redis error", in.String(), err1.Error()) - resp.MaxSeq = -1 - } - if err2 == redis.ErrNil { - resp.MinSeq = 0 - } else if err2 != nil { - log.NewInfo(in.OperationID, "getMinSeq from redis error", in.String(), err2.Error()) - resp.MinSeq = -1 - } - resp.ErrCode = 0 - resp.ErrMsg = "" - return resp, nil + log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err1.Error()) + resp.MaxSeq = -1 + resp.ErrCode = 200 + resp.ErrMsg = "redis get err" } - + if err2 == nil { + resp.MinSeq = minSeq + } else if err2 == redis.ErrNil { + resp.MinSeq = 0 + } else { + log.NewError(in.OperationID, "getMaxSeq from redis error", in.String(), err2.Error()) + resp.MinSeq = -1 + resp.ErrCode = 200 + resp.ErrMsg = "redis get err" + } + return resp, nil } func (rpc *rpcChat) PullMessage(_ context.Context, in *pbMsg.PullMessageReq) (*pbMsg.PullMessageResp, error) { log.InfoByKv("rpc pullMessage is arriving", in.OperationID, "args", in.String())