Add pagination for "my books" display

This commit is contained in:
2025-11-10 20:44:47 +01:00
parent 870158e489
commit 87f6daef18
13 changed files with 355 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package appcontext
import (
"errors"
"strconv"
"git.artlef.fr/PersonalLibraryManager/internal/config"
"git.artlef.fr/PersonalLibraryManager/internal/model"
@@ -26,3 +27,21 @@ func (ac AppContext) GetAuthenticatedUser() (model.User, error) {
res := ac.Db.Where("name = ?", username).First(&user)
return user, res.Error
}
func (ac AppContext) GetQueryLimit() (int, error) {
l := ac.C.Query("limit")
if l != "" {
return strconv.Atoi(l)
} else {
return ac.Config.Limit, nil
}
}
func (ac AppContext) GetQueryOffset() (int, error) {
o := ac.C.Query("offset")
if o != "" {
return strconv.Atoi(o)
} else {
return 0, nil
}
}