fix: 增加筛选过滤

This commit is contained in:
徐俊杰 2025-06-19 14:39:42 +08:00
parent 301e94808d
commit bc17428bd6
3 changed files with 58 additions and 36 deletions

View File

@ -24,7 +24,6 @@ import (
"fonchain-fiee/pkg/service/asChat/logic" "fonchain-fiee/pkg/service/asChat/logic"
"fonchain-fiee/pkg/service/asChat/robot" "fonchain-fiee/pkg/service/asChat/robot"
"fonchain-fiee/pkg/service/upload" "fonchain-fiee/pkg/service/upload"
"fonchain-fiee/pkg/utils"
"fonchain-fiee/pkg/utils/stime" "fonchain-fiee/pkg/utils/stime"
"io" "io"
"log" "log"
@ -503,9 +502,22 @@ func (cr ChatHandler) UserMessageStat(c *gin.Context) {
} }
} }
if result[i].Name == "" { if result[i].Name == "" {
result[i].Name = beautifulZeroNameWithPhone(result[i].Name, result[i].UserId) result[i].Name = logic.BeautifulZeroNameWithPhone(result[i].Name, result[i].UserId)
} }
} }
//筛选
if request.Account != "" || request.Name != "" {
newData := []dto.UserMsgStatic{}
for _, v := range listRes.List {
for _, vv := range result {
if v.UserId == vv.UserId {
vv := vv
newData = append(newData, vv)
}
}
}
result = newData
}
reverse(result) reverse(result)
if chatUser.Role == 1 { if chatUser.Role == 1 {
userSessionId := fmt.Sprintf("%d", chatUser.ID) userSessionId := fmt.Sprintf("%d", chatUser.ID)
@ -600,36 +612,3 @@ func (cr ChatHandler) UserDetail(c *gin.Context) {
service.Success(c, detail) service.Success(c, detail)
} }
// 对没有名字的name进行优化
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
}

View File

@ -54,7 +54,8 @@ func NewMessage(ctx context.Context, cache *chatCache.ChatCache, sender *account
//存储入库 //存储入库
if sender.NickName == "" { if sender.NickName == "" {
sender.NickName = fmt.Sprintf("未知用户(%d)", sender.ID) //sender.NickName = fmt.Sprintf("未知用户(%d)", sender.ID)
sender.NickName = BeautifulZeroNameWithPhone(sender.NickName, sender.ID)
} }
fmt.Println("NewMessage 3333333333333333333333333333333333") fmt.Println("NewMessage 3333333333333333333333333333333333")
var data = accountFiee.ChatRecordData{ var data = accountFiee.ChatRecordData{

View File

@ -0,0 +1,42 @@
package logic
import (
"context"
"fmt"
"fonchain-fiee/api/accountFiee"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/utils"
)
// 对没有名字的name进行优化
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
}