fix: 统一商务表格展示并修正筛选和全量排序

This commit is contained in:
Yvan
2026-11-05 01:48:09 +08:00
parent dc97690eb1
commit 10600d1bc9
38 changed files with 356 additions and 145 deletions
+21
View File
@@ -147,3 +147,24 @@ func TestLedgerChannelNicknameAndLiteralFuzzyFilter(t *testing.T) {
t.Fatal("模糊搜索不得扩大商务范围")
}
}
func TestSpendIDSortIsGlobalAndStableAcrossPages(t *testing.T) {
db, repo, scope, filter := prepareLedgerData(t)
if err := db.Exec("UPDATE tab_spend SET pay_time=1999 WHERE id=901").Error; err != nil {
t.Fatal(err)
}
filter.SortField, filter.Ascending = "id", true
first, err := repo.Spends(context.Background(), scope, filter, business.LedgerListOptions{Limit: 2})
if err != nil {
t.Fatal(err)
}
second, err := repo.Spends(context.Background(), scope, filter, business.LedgerListOptions{Offset: 2, Limit: 2})
if err != nil || len(first.Rows) != 2 || len(second.Rows) != 2 || first.Rows[1].ID >= second.Rows[0].ID {
t.Fatal("ascending sort must be applied before pagination")
}
filter.Ascending = false
last, err := repo.Spends(context.Background(), scope, filter, business.LedgerListOptions{Limit: 2})
if err != nil || last.Rows[0].ID != 909 || last.Rows[1].ID != 904 {
t.Fatalf("ID ordering must not fall back to timestamps: %+v %v", last, err)
}
}