This commit is contained in:
aozhiwei 2024-03-22 12:02:39 +08:00
parent 1fcc4cf71b
commit 088f770c79

View File

@ -31,11 +31,7 @@ func (this *FriendMgr) IsFriend(accountId1 string, accountId2 string) bool {
} }
func (this *FriendMgr) HasFriend(accountId string) bool { func (this *FriendMgr) HasFriend(accountId string) bool {
myFriends := this.getFriends(accountId) return this.GetFriendNum(accountId) > 0
if myFriends != nil {
return len(*myFriends) > 0
}
return false
} }
func (this *FriendMgr) GetFriendNum(accountId string) int32 { func (this *FriendMgr) GetFriendNum(accountId string) int32 {
@ -46,6 +42,17 @@ func (this *FriendMgr) GetFriendNum(accountId string) int32 {
return 0 return 0
} }
func (this *FriendMgr) TraverseFriend(accountId string, cb func(string, int32) bool) {
myFriends := this.getFriends(accountId)
if myFriends != nil {
for a, t := range *myFriends {
if !cb(a, t) {
break
}
}
}
}
func (this *FriendMgr) getFriends(accountId string) *map[string]int32 { func (this *FriendMgr) getFriends(accountId string) *map[string]int32 {
if friends, ok := this.friendHash[accountId]; ok { if friends, ok := this.friendHash[accountId]; ok {
return friends return friends