From 0977cd3b1f25facb7ea87e75fd1b1cd266333255 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sun, 24 Nov 2024 00:38:13 -0500 Subject: [PATCH] add missing file --- internal/common/pagination.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 internal/common/pagination.go diff --git a/internal/common/pagination.go b/internal/common/pagination.go new file mode 100644 index 0000000..d6996d9 --- /dev/null +++ b/internal/common/pagination.go @@ -0,0 +1,15 @@ +package common + +type Pagination struct { + Page *int `json:"page"` + PerPage *int `json:"perPage"` +} + +func (p Pagination) OffsetPerPage(perPageDefault int) (offset int32, perPage int32) { + page := int32(DefaultIfNilOrZero(p.Page, 1)) + perPage = int32(DefaultIfNilOrZero(p.PerPage, perPageDefault)) + + offset = (page - 1) * perPage + + return +}