feat(table): 表格排序与搜索改为后端处理
This commit is contained in:
@@ -14,3 +14,22 @@ func paginationResultFromTotal(total int64, params pagination.PaginationParams)
|
||||
Pages: pages,
|
||||
}
|
||||
}
|
||||
|
||||
func paginateSlice[T any](items []T, params pagination.PaginationParams) []T {
|
||||
if len(items) == 0 {
|
||||
return []T{}
|
||||
}
|
||||
|
||||
offset := params.Offset()
|
||||
if offset >= len(items) {
|
||||
return []T{}
|
||||
}
|
||||
|
||||
limit := params.Limit()
|
||||
end := offset + limit
|
||||
if end > len(items) {
|
||||
end = len(items)
|
||||
}
|
||||
|
||||
return items[offset:end]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user