Add pagination for "my books" display
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user