🐛 Just forgot to add pagination data into response

This commit is contained in:
2024-08-03 22:45:50 +08:00
parent 75ab320bf1
commit c381b53a29
2 changed files with 30 additions and 3 deletions

View File

@@ -35,11 +35,20 @@ func listStickers(c *fiber.Ctx) error {
tx = tx.Where("pack_id = ?", val)
}
var count int64
if err := database.C.Model(&models.Sticker{}).Count(&count).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
var stickers []models.Sticker
if err := tx.Limit(take).Offset(offset).Preload("Attachment").Find(&stickers).Error; err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
return c.JSON(stickers)
return c.JSON(fiber.Map{
"count": count,
"data": stickers,
})
}
func getSticker(c *fiber.Ctx) error {