state transfer limit and offset
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"gitea.tbdevent.eu/TBD/reforger_crawler_main/initializers"
|
||||
"gitea.tbdevent.eu/TBD/reforger_crawler_main/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func CreateAddon(c *gin.Context) {
|
||||
@@ -34,10 +35,25 @@ func CreateAddon(c *gin.Context) {
|
||||
}
|
||||
c.JSON(200, gin.H{"status": "success"})
|
||||
}
|
||||
|
||||
func GetCurrentState(c *gin.Context) {
|
||||
offsetStr := c.Query("offset")
|
||||
limitStr := c.Query("limit")
|
||||
|
||||
offset := 0
|
||||
limit := 0
|
||||
if offsetStr != "" {
|
||||
if val, err := strconv.Atoi(offsetStr); err == nil {
|
||||
offset = val
|
||||
}
|
||||
}
|
||||
if limitStr != "" {
|
||||
if val, err := strconv.Atoi(limitStr); err == nil {
|
||||
limit = val
|
||||
}
|
||||
}
|
||||
|
||||
var addons []models.Addon
|
||||
initializers.DB.Find(&addons)
|
||||
initializers.DB.Limit(limit).Offset(offset).Find(&addons)
|
||||
|
||||
c.JSON(200, addons)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user