From ac79481ec59fdabb224d7a7d343b65c3c4aa52a7 Mon Sep 17 00:00:00 2001 From: jjxu <428192774@qq.com> Date: Wed, 18 Jun 2025 15:59:01 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=9C=AA=E5=AE=9E=E5=90=8D=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=98=BE=E7=A4=BA=E6=89=8B=E6=9C=BA=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/asChat/handler.go | 36 +++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/pkg/service/asChat/handler.go b/pkg/service/asChat/handler.go index 7260b25..f70038b 100644 --- a/pkg/service/asChat/handler.go +++ b/pkg/service/asChat/handler.go @@ -232,7 +232,7 @@ func (cr ChatHandler) MessageList(c *gin.Context) { } domain := c.GetHeader("domain") fmt.Println("MessageList domain:", domain) - if (request.Direction == 0 && request.Recent == false) || (request.Direction > 0 && request.Recent == true) { + if (request.Direction == 0 && !request.Recent) || (request.Direction > 0 && request.Recent) { service.Error(c, errors.New("组合条件校验失败")) return } @@ -501,7 +501,7 @@ func (cr ChatHandler) UserMessageStat(c *gin.Context) { } } if result[i].Name == "" { - result[i].Name = beautifulZeroName(result[i].Name, result[i].UserId) + result[i].Name = beautifulZeroNameWithPhone(result[i].Name, result[i].UserId) } } reverse(result) @@ -563,6 +563,10 @@ func (cr ChatHandler) UserDetail(c *gin.Context) { return } } + //fmt.Printf("chatUser:%#v\n", chatUser) + //if chatUser.Origin == "fiee" { + // chatUser.Origin = "app" + //} resp, err := service.AccountFieeProvider.Info(c, &accountFiee.InfoRequest{ID: uint64(chatUser.OriginId), Domain: chatUser.Origin}) if err != nil { service.Error(c, err) @@ -588,3 +592,31 @@ func (cr ChatHandler) UserDetail(c *gin.Context) { func beautifulZeroName(name string, userId int64) string { return utils.IfGec(name == "", fmt.Sprintf("未实名用户:%d", userId), name) } + +var userIdMapPhone = make(map[int64]string) + +func beautifulZeroNameWithPhone(name string, userId int64) string { + var ctx = context.Background() + if name == "" { + telNum, ok := userIdMapPhone[userId] + if ok { + return telNum + } + chatUserRes, err := service.AccountFieeProvider.GetChatUserDetail(ctx, &accountFiee.GetChatUserByIdRequest{Id: userId}) + if err != nil { + return fmt.Sprintf("未实名用户:%d", userId) + } else { + if userRes, errs := service.AccountFieeProvider.Info(ctx, &accountFiee.InfoRequest{ + Domain: chatUserRes.Origin, + ID: uint64(chatUserRes.OriginId), + Scene: "", + }); errs != nil { + return fmt.Sprintf("未实名用户:%d", userId) + } else { + userIdMapPhone[userId] = userRes.TelNum + return userRes.TelNum + } + } + } + return name +}