|
|
@@ -80,20 +80,43 @@ func MySelfList(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
imUserIds := make([]int64, len(resp.List)) |
|
|
|
var userIds []int64 |
|
|
|
for i, friendCircle := range resp.List { |
|
|
|
imUserIds[i] = friendCircle.ImUid |
|
|
|
if friendCircle.ImUid != 0 { |
|
|
|
imUserIds[i] = friendCircle.ImUid |
|
|
|
} else { |
|
|
|
userIds[i] = friendCircle.Uid |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
nicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(imUserIds) |
|
|
|
imNicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(imUserIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
// IM 未上线兼容朋友圈头像及昵称 使用 app 昵称头像替代 |
|
|
|
appNicknameAndAvatarMap := make(map[int64]friend_circles.FriendCircleNicknameAndAvatar) |
|
|
|
if len(userIds) > 0 { |
|
|
|
appNicknameAndAvatarMap, err = svc2.GetAppUserNickNameAndAvatar(userIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for _, friendCircle := range resp.List { |
|
|
|
val, ok := nicknameAndAvatarMap[friendCircle.ImUid] |
|
|
|
val, ok := imNicknameAndAvatarMap[friendCircle.ImUid] |
|
|
|
if ok { |
|
|
|
friendCircle.ImNickname = val.NickName |
|
|
|
friendCircle.ImAvatar = val.Avatar |
|
|
|
} else { |
|
|
|
// 获取不到就尝试获取 app 的昵称和头像 |
|
|
|
appVal, appOk := appNicknameAndAvatarMap[friendCircle.Uid] |
|
|
|
if appOk { |
|
|
|
friendCircle.ImNickname = appVal.NickName |
|
|
|
friendCircle.ImAvatar = appVal.Avatar |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -168,6 +191,7 @@ func FriendCircleLikeList(c *gin.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
var docs []*md.EggFriendCircleLikeEs |
|
|
|
var docImUserIds []int64 |
|
|
|
var docUserIds []int64 |
|
|
|
var total int64 |
|
|
|
// 检查是否有结果 |
|
|
@@ -180,16 +204,29 @@ func FriendCircleLikeList(c *gin.Context) { |
|
|
|
if err != nil { |
|
|
|
return |
|
|
|
} |
|
|
|
docUserIds = append(docUserIds, like.ImUid) |
|
|
|
if like.ImUid != 0 { |
|
|
|
docImUserIds = append(docImUserIds, like.ImUid) |
|
|
|
} else { |
|
|
|
docUserIds = append(docUserIds, like.Uid) |
|
|
|
} |
|
|
|
docs = append(docs, &like) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
nicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(docUserIds) |
|
|
|
imNicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(docImUserIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR_DB_ORM, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
// IM 未上线兼容朋友圈头像及昵称 使用 app 昵称头像替代 |
|
|
|
appNicknameAndAvatarMap := make(map[int64]friend_circles.FriendCircleNicknameAndAvatar) |
|
|
|
if len(docUserIds) > 0 { |
|
|
|
appNicknameAndAvatarMap, err = svc2.GetAppUserNickNameAndAvatar(docUserIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
var list []*friend_circles.FriendCircleLikeEsStruct |
|
|
|
for _, like := range docs { |
|
|
|
temp := friend_circles.FriendCircleLikeEsStruct{ |
|
|
@@ -197,10 +234,17 @@ func FriendCircleLikeList(c *gin.Context) { |
|
|
|
ImUid: like.ImUid, |
|
|
|
CircleId: like.CircleId, |
|
|
|
} |
|
|
|
val, ok := nicknameAndAvatarMap[like.ImUid] |
|
|
|
val, ok := imNicknameAndAvatarMap[like.ImUid] |
|
|
|
if ok { |
|
|
|
temp.ImNickname = val.NickName |
|
|
|
temp.ImAvatar = val.Avatar |
|
|
|
} else { |
|
|
|
// 获取不到就尝试获取 app 的昵称和头像 |
|
|
|
appVal, appOk := appNicknameAndAvatarMap[temp.Uid] |
|
|
|
if appOk { |
|
|
|
temp.ImNickname = appVal.NickName |
|
|
|
temp.ImAvatar = appVal.Avatar |
|
|
|
} |
|
|
|
} |
|
|
|
list = append(list, &temp) |
|
|
|
} |
|
|
@@ -314,20 +358,41 @@ func RecommendList(c *gin.Context) { |
|
|
|
} |
|
|
|
|
|
|
|
imUserIds := make([]int64, len(resp.List)) |
|
|
|
var userIds []int64 |
|
|
|
for i, friendCircle := range resp.List { |
|
|
|
imUserIds[i] = friendCircle.ImUid |
|
|
|
if friendCircle.ImUid != 0 { |
|
|
|
imUserIds[i] = friendCircle.ImUid |
|
|
|
} else { |
|
|
|
userIds[i] = friendCircle.Uid |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
nicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(imUserIds) |
|
|
|
imNicknameAndAvatarMap, err := svc2.GetImUserNicknameAndAvatar(imUserIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
// IM 未上线兼容朋友圈头像及昵称 使用 app 昵称头像替代 |
|
|
|
appNicknameAndAvatarMap := make(map[int64]friend_circles.FriendCircleNicknameAndAvatar) |
|
|
|
if len(userIds) > 0 { |
|
|
|
appNicknameAndAvatarMap, err = svc2.GetAppUserNickNameAndAvatar(userIds) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, e.ERR, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
for _, friendCircle := range resp.List { |
|
|
|
val, ok := nicknameAndAvatarMap[friendCircle.ImUid] |
|
|
|
val, ok := imNicknameAndAvatarMap[friendCircle.ImUid] |
|
|
|
if ok { |
|
|
|
friendCircle.ImNickname = val.NickName |
|
|
|
friendCircle.ImAvatar = val.Avatar |
|
|
|
} else { |
|
|
|
// 获取不到就尝试获取 app 的昵称和头像 |
|
|
|
appVal, appOk := appNicknameAndAvatarMap[friendCircle.Uid] |
|
|
|
if appOk { |
|
|
|
friendCircle.ImNickname = appVal.NickName |
|
|
|
friendCircle.ImAvatar = appVal.Avatar |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
e.OutSuc(c, resp, nil) |
|
|
|