fix: 解决冲突
This commit is contained in:
commit
e03bd54b11
@ -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"
|
||||||
@ -506,9 +505,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)
|
||||||
@ -603,36 +615,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
|
|
||||||
}
|
|
||||||
|
@ -40,7 +40,7 @@ func NewMessage(ctx context.Context, cache *chatCache.ChatCache, sender *account
|
|||||||
cacheMap[request.AtUserId] = request
|
cacheMap[request.AtUserId] = request
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(request.LocalStamp - msgRecord.LocalStamp)
|
fmt.Println(request.LocalStamp - msgRecord.LocalStamp)
|
||||||
if msgRecord.Message.Text == request.Message.Text && request.LocalStamp-msgRecord.LocalStamp < 1 {
|
if msgRecord.Message.Text == request.Message.Text && request.LocalStamp-msgRecord.LocalStamp < 1 { //秒级
|
||||||
cacheMap[request.AtUserId] = request
|
cacheMap[request.AtUserId] = request
|
||||||
fmt.Println("\n\n跳过消息发送\n\t跳过消息发送\n\t\t跳过消息发送\n\n")
|
fmt.Println("\n\n跳过消息发送\n\t跳过消息发送\n\t\t跳过消息发送\n\n")
|
||||||
return nil
|
return nil
|
||||||
@ -55,7 +55,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{
|
||||||
|
42
pkg/service/asChat/logic/utils.go
Normal file
42
pkg/service/asChat/logic/utils.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user