From 8bebbdc293de35f39b23fdb4380cf57439eb3a1e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 30 Mar 2024 09:58:22 +0800 Subject: [PATCH] 1 --- server/imserver_new/friend/friendmgr.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/imserver_new/friend/friendmgr.go b/server/imserver_new/friend/friendmgr.go index 6dec8c50..35c158f6 100644 --- a/server/imserver_new/friend/friendmgr.go +++ b/server/imserver_new/friend/friendmgr.go @@ -148,7 +148,7 @@ func (this *friendMgr) getBlacks(accountId string) *map[string]int32 { return nil } -func (this *friendMgr) AsyncGetApplyList(idx int64, accountId string, cb func(int32, string, int64, []string)) { +func (this *friendMgr) AsyncGetApplyList(lastIdx int64, accountId string, cb func(int32, string, int64, []string)) { f5.GetJsStyleDb().PageQuery( constant.FRIEND_DB, 50, @@ -156,13 +156,24 @@ func (this *friendMgr) AsyncGetApplyList(idx int64, accountId string, cb func(in "SELECT * FROM t_friend_apply", []string{}, f5.GetDbFilter().Comp( - f5.GetDbFilter().GT("idx", q5.ToString(idx)).And(), + f5.GetDbFilter().GT("idx", q5.ToString(lastIdx)).And(), f5.GetDbFilter().EQ("target_id", accountId).And(), f5.GetDbFilter().EQ("status", "0"), ), "", func (err error, pg *f5.Pagination) { - + var lastSinceId int64 + if err != nil { + cb(500, "", lastSinceId, []string{}) + } + if pg.Rows.Next() { + idx := q5.ToInt64(pg.Rows.GetByName("idx")) + if idx > lastSinceId { + lastSinceId = idx + } else { + panic(fmt.Sprintf("AsyncGetApply idx error:%s %s", idx, lastSinceId)) + } + } }) }