Skip to content

Commit 42c4996

Browse files
authored
[feat]: 添加好友群组可通过id查询 (#326)
1 parent 900f899 commit 42c4996

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

relations.go

+10
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func (f Friends) SearchByRemarkName(limit int, remarkName string) (results Frien
8585
return f.Search(limit, func(friend *Friend) bool { return friend.User.RemarkName == remarkName })
8686
}
8787

88+
// SearchByID 根据ID查找好友
89+
func (f Friends) SearchByID(id string) Friends {
90+
return f.Search(1, func(friend *Friend) bool { return friend.User.ID() == id })
91+
}
92+
8893
// Search 根据自定义条件查找好友
8994
func (f Friends) Search(limit int, searchFuncList ...func(friend *Friend) bool) (results Friends) {
9095
return f.AsMembers().Search(limit, func(user *User) bool {
@@ -304,6 +309,11 @@ func (g Groups) SearchByNickName(limit int, nickName string) (results Groups) {
304309
return g.Search(limit, func(group *Group) bool { return group.NickName == nickName })
305310
}
306311

312+
// SearchByID 根据ID查找群组
313+
func (g Groups) SearchByID(id string) Groups {
314+
return g.Search(1, func(group *Group) bool { return group.ID() == id })
315+
}
316+
307317
// Search 根据自定义条件查找群组
308318
func (g Groups) Search(limit int, searchFuncList ...func(group *Group) bool) (results Groups) {
309319
return g.AsMembers().Search(limit, func(user *User) bool {

0 commit comments

Comments
 (0)