Initial commit.

This commit is contained in:
2025-08-12 18:10:43 +02:00
commit 25a0db9b1e
44 changed files with 8121 additions and 0 deletions

37
utils/pagination.go Normal file
View File

@ -0,0 +1,37 @@
package utils
type OffsetPaginationError struct {
Page int
Pages int
NextPage int
LastPage int
}
func (p *OffsetPaginationError) Error() string {
return "Not an error, just for offsetbased pagination."
}
func NewOffsetPaginationError(page int, pages int) error {
var nextPage int
if page+1 <= pages {
nextPage = page + 1
} else {
nextPage = -1
}
return &OffsetPaginationError{Page: page, Pages: pages, NextPage: nextPage, LastPage: page - 1}
}
type KeysetPaginationError struct {
Key int
NextKey int
PreviousKey int
}
func (p *KeysetPaginationError) Error() string {
return "Not an error, just for Keysetbased pagination."
}
func NewKeysetPaginationError(key int, next int, previous int) error {
return &KeysetPaginationError{Key: key, NextKey: next, PreviousKey: previous}
}