fix version 1
This commit is contained in:
@@ -21,9 +21,9 @@ func GetrelationInfoDetailCard(identity string) (card *pb.RelationItem, err erro
|
||||
return
|
||||
}
|
||||
|
||||
// 根据id数组获取多条会员信息卡片
|
||||
func GetrelationInfoDetailCardById(ids []uint) (cards []*pb.RelationItem, err error) {
|
||||
err = impl.DBService.Table("relation_extend").Select(Filed).Where("relation_id in ?", ids).Find(&cards).Error
|
||||
// 根据identity数组获取多条会员信息卡片
|
||||
func GetrelationInfoDetailCardById(identities []string) (cards []*pb.RelationItem, err error) {
|
||||
err = impl.DBService.Table("relation_extend").Select(Filed).Where("relation_identity in ?", identities).Find(&cards).Error
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func UniqueSessionID(s1, s2 string) string {
|
||||
func CollectionFriendApply(id uint) (reply *pb.ApplyFetchReply, err error) {
|
||||
var (
|
||||
version int64
|
||||
ids []uint
|
||||
identities []string
|
||||
last_msg_ids []uint
|
||||
maxSize int = 50
|
||||
applys = make([]*models.FriendApply, 0)
|
||||
@@ -57,11 +57,12 @@ func CollectionFriendApply(id uint) (reply *pb.ApplyFetchReply, err error) {
|
||||
}
|
||||
|
||||
for _, item := range applys {
|
||||
ids = append(ids, item.FromID)
|
||||
identities = append(identities, item.FromIdentity)
|
||||
last_msg_ids = append(last_msg_ids, item.LastMessageID)
|
||||
}
|
||||
|
||||
result, err := GetrelationInfoDetailCardById(ids)
|
||||
// 按申请人身份取资料卡
|
||||
result, err := GetrelationInfoDetailCardById(identities)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -107,41 +108,61 @@ func CollectionFriendApply(id uint) (reply *pb.ApplyFetchReply, err error) {
|
||||
// 根据用户ID,找到用户的好友信息和分组信息
|
||||
func CollectionFriendData(id uint) (reply *pb.FriendsReply, err error) {
|
||||
var (
|
||||
version int64
|
||||
ids []uint
|
||||
version int64
|
||||
identities []string
|
||||
|
||||
relationFriend = make([]models.RelationFriend, 0)
|
||||
mapRelationFrend = make(map[uint]models.RelationFriend)
|
||||
mapRelationFrend = make(map[string]models.RelationFriend)
|
||||
|
||||
friendInTag = make([]models.FriendInTag, 0)
|
||||
mapFriendInTag = make(map[string][]string)
|
||||
mapTagTotal = make(map[string]int64)
|
||||
)
|
||||
reply = &pb.FriendsReply{}
|
||||
impl.DBService.Where("relation_id=?", id).Order("id desc").Find(&relationFriend)
|
||||
// 好友条目归属列是 passport_id,好友身份是 friend_relation_identity
|
||||
err = impl.DBService.Where("passport_id=?", id).Order("id desc").Find(&relationFriend).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, item := range relationFriend {
|
||||
ids = append(ids, item.ID)
|
||||
mapRelationFrend[item.ID] = item
|
||||
identities = append(identities, item.FriendrelationIdentity)
|
||||
mapRelationFrend[item.FriendrelationIdentity] = item
|
||||
version = int64(item.ID)
|
||||
}
|
||||
|
||||
impl.DBService.Where("relation_id=?", id).Find(&friendInTag)
|
||||
err = impl.DBService.Where("passport_id=?", id).Find(&friendInTag).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, item := range friendInTag {
|
||||
mapFriendInTag[item.FriendIdentity] = append(mapFriendInTag[item.FriendIdentity], item.TagIdentity)
|
||||
mapTagTotal[item.TagIdentity]++
|
||||
}
|
||||
|
||||
err = impl.DBService.Model(models.FriendTag{}).Where("relation_id=?", id).Order("id asc").Scan(&reply.Tags).Error
|
||||
// 标签列表按归属过滤并补齐标签名
|
||||
err = impl.DBService.Model(models.FriendTag{}).Select("id, identity, name as tag_name").Where("passport_id=?", id).Order("id asc").Scan(&reply.Tags).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 补齐每个标签的成员数
|
||||
for idx := range reply.Tags {
|
||||
reply.Tags[idx].FriendTotal = mapTagTotal[reply.Tags[idx].Identity]
|
||||
}
|
||||
|
||||
reply.Friends, err = GetrelationInfoDetailCardById(ids)
|
||||
for idx, item := range reply.Friends {
|
||||
reply.Friends[idx].RemarkName = item.RemarkName
|
||||
reply.Friends[idx].Popular = item.Popular
|
||||
if _, ok := mapFriendInTag[item.Identity]; ok {
|
||||
reply.Friends[idx].Tags = mapFriendInTag[item.Identity]
|
||||
// 按好友身份装配资料卡,并回填备注与置顶
|
||||
reply.Friends, err = GetrelationInfoDetailCardById(identities)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for idx := range reply.Friends {
|
||||
if item, ok := mapRelationFrend[reply.Friends[idx].Identity]; ok {
|
||||
reply.Friends[idx].RemarkName = item.RemarkName
|
||||
reply.Friends[idx].Popular = int32(item.Popular)
|
||||
}
|
||||
if tags, ok := mapFriendInTag[reply.Friends[idx].Identity]; ok {
|
||||
reply.Friends[idx].Tags = tags
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +175,7 @@ func CollectionFriendData(id uint) (reply *pb.FriendsReply, err error) {
|
||||
func GetrelationInfoDetailCardByMatch(relation_identity string, offset, limit int) (cards []*pb.RelationItem, err error) {
|
||||
sql := `Select
|
||||
pe.relation_identity as identity,
|
||||
pe.name,
|
||||
pe.nickname,
|
||||
pe.avatar,
|
||||
pe.birthday,
|
||||
pe.sex,
|
||||
@@ -163,13 +184,13 @@ func GetrelationInfoDetailCardByMatch(relation_identity string, offset, limit in
|
||||
pe.area,
|
||||
pe.sign,
|
||||
rm.status as foreign_status
|
||||
From relation_match as rm,relation_extend as pe
|
||||
Left join pe on pe.relation_identity=rm.recommend_identity
|
||||
From relation_match as rm
|
||||
Join relation_extend as pe on pe.relation_identity=rm.recommend_identity
|
||||
Where rm.relation_identity=?
|
||||
Offset ?
|
||||
Order by rm.id Desc
|
||||
Limit ?
|
||||
Order by rm.id Desc`
|
||||
err = impl.DBService.Raw(sql, relation_identity, offset, limit).Scan(&cards).Error
|
||||
Offset ?`
|
||||
err = impl.DBService.Raw(sql, relation_identity, limit, offset).Scan(&cards).Error
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user