From 04e826ff09fa831014286d1af73ed3865434a1c0 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Fri, 29 Jul 2022 17:49:15 +0800 Subject: [PATCH 1/2] Adjust error code --- internal/api/auth/auth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/api/auth/auth.go b/internal/api/auth/auth.go index 60bf1d8a5..8a94d73f2 100644 --- a/internal/api/auth/auth.go +++ b/internal/api/auth/auth.go @@ -150,7 +150,7 @@ func ParseToken(c *gin.Context) { if err := c.BindJSON(¶ms); err != nil { errMsg := " BindJSON failed " + err.Error() log.NewError("0", errMsg) - c.JSON(http.StatusBadRequest, gin.H{"errCode": 200, "errMsg": errMsg}) + c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg}) return } @@ -161,7 +161,7 @@ func ParseToken(c *gin.Context) { if !ok { errMsg := params.OperationID + " " + "GetUserIDFromTokenExpireTime failed " + errInfo + " token:" + c.Request.Header.Get("token") log.NewError(params.OperationID, errMsg) - c.JSON(http.StatusInternalServerError, gin.H{"errCode": 200, "errMsg": errMsg}) + c.JSON(http.StatusOK, gin.H{"errCode": 1001, "errMsg": errMsg}) return } From 151fec445e51d21b7a27ac19d17329170a6473da Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Fri, 29 Jul 2022 17:50:00 +0800 Subject: [PATCH 2/2] fix bug --- internal/rpc/group/super_group.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/rpc/group/super_group.go b/internal/rpc/group/super_group.go index d08a38742..9b50c7955 100644 --- a/internal/rpc/group/super_group.go +++ b/internal/rpc/group/super_group.go @@ -9,6 +9,7 @@ import ( commonPb "Open_IM/pkg/proto/sdk_ws" "Open_IM/pkg/utils" "context" + "github.com/go-redis/redis/v8" ) func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup.GetJoinedSuperGroupListReq) (*pbGroup.GetJoinedSuperGroupListResp, error) { @@ -17,6 +18,10 @@ func (s *groupServer) GetJoinedSuperGroupList(ctx context.Context, req *pbGroup. //userToSuperGroup, err := db.DB.GetSuperGroupByUserID(req.UserID) groupIDList, err := rocksCache.GetJoinedSuperGroupListFromCache(req.UserID) if err != nil { + if err == redis.Nil { + log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID nil ", err.Error(), req.UserID) + return resp, nil + } log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetSuperGroupByUserID failed ", err.Error(), req.UserID) resp.CommonResp.ErrCode = constant.ErrDB.ErrCode resp.CommonResp.ErrMsg = constant.ErrDB.ErrMsg