feat: 支持主列表选择每页条数 (#242)

This commit is contained in:
chengma
2026-08-15 15:15:38 +08:00
parent 8c09023434
commit b4558537d5
37 changed files with 479 additions and 160 deletions
+8 -2
View File
@@ -34,15 +34,21 @@ func ParseCatalogStatus(raw string) model.CatalogImportStatus {
}
func ListCatalogHistory(q repository.Execer, source, statusRaw string, page int) (CatalogHistoryResult, error) {
return ListCatalogHistoryWithPageSize(q, source, statusRaw, page, DefaultPageSize)
}
// ListCatalogHistoryWithPageSize 按白名单页容量返回商品目录导入记录。
func ListCatalogHistoryWithPageSize(q repository.Execer, source, statusRaw string, page, pageSize int) (CatalogHistoryResult, error) {
pageSize = NormalizePageSize(pageSize)
status := ParseCatalogStatus(statusRaw)
totalPages := 1
_, total, err := repository.ListCatalogImportRuns(q, strings.TrimSpace(source), status, 1, 0)
if err != nil {
return CatalogHistoryResult{}, err
}
totalPages = TotalPages(total)
totalPages = TotalPages(total, pageSize)
page = ClampPage(page, totalPages)
runs, _, err := repository.ListCatalogImportRuns(q, strings.TrimSpace(source), status, PageSize, (page-1)*PageSize)
runs, _, err := repository.ListCatalogImportRuns(q, strings.TrimSpace(source), status, pageSize, (page-1)*pageSize)
if err != nil {
return CatalogHistoryResult{}, err
}