✨ Pagination bots api
This commit is contained in:
@ -14,12 +14,23 @@ func listBotKeys(c *fiber.Ctx) error {
|
||||
}
|
||||
user := c.Locals("user").(models.Account)
|
||||
|
||||
var keys []models.ApiKey
|
||||
if err := database.C.Where("account_id = ?", user.ID).Find(&keys).Error; err != nil {
|
||||
tx := database.C.Where("account_id = ?", user.ID)
|
||||
|
||||
countTx := tx
|
||||
var count int64
|
||||
if err := countTx.Model(&models.ApiKey{}).Count(&count).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(keys)
|
||||
var keys []models.ApiKey
|
||||
if err := tx.Find(&keys).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": keys,
|
||||
})
|
||||
}
|
||||
|
||||
func getBotKey(c *fiber.Ctx) error {
|
||||
|
@ -18,12 +18,23 @@ func listBots(c *fiber.Ctx) error {
|
||||
}
|
||||
user := c.Locals("user").(models.Account)
|
||||
|
||||
var bots []models.Account
|
||||
if err := database.C.Where("automated_id = ?", user.AutomatedID).Find(&bots).Error; err != nil {
|
||||
tx := database.C.Where("automated_id = ?", user.AutomatedID)
|
||||
|
||||
countTx := tx
|
||||
var count int64
|
||||
if err := countTx.Model(&models.Account{}).Count(&count).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(bots)
|
||||
var bots []models.Account
|
||||
if err := tx.Find(&bots).Error; err != nil {
|
||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(fiber.Map{
|
||||
"count": count,
|
||||
"data": bots,
|
||||
})
|
||||
}
|
||||
|
||||
func createBot(c *fiber.Ctx) error {
|
||||
|
Reference in New Issue
Block a user