令牌分页

This commit is contained in:
CaIon
2023-11-03 22:47:55 +08:00
parent e06186fe0c
commit 3d87f868a3
2 changed files with 22 additions and 11 deletions

View File

@@ -11,10 +11,16 @@ import (
func GetAllTokens(c *gin.Context) {
userId := c.GetInt("id")
p, _ := strconv.Atoi(c.Query("p"))
size, _ := strconv.Atoi(c.Query("size"))
if p < 0 {
p = 0
}
tokens, err := model.GetAllUserTokens(userId, p*common.ItemsPerPage, common.ItemsPerPage)
if size <= 0 {
size = common.ItemsPerPage
} else if size > 100 {
size = 100
}
tokens, err := model.GetAllUserTokens(userId, p*size, size)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"success": false,