🐛 Fix pagination fetch channel members does not include total count

This commit is contained in:
2024-12-01 00:17:43 +08:00
parent 40ef26f75d
commit e82f100b67
2 changed files with 20 additions and 1 deletions

View File

@ -31,10 +31,18 @@ func listChannelMembers(c *fiber.Ctx) error {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
count, err := services.CountChannelMember(channel.ID)
if err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
if members, err := services.ListChannelMember(channel.ID, take, offset); err != nil {
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
} else {
return c.JSON(members)
return c.JSON(fiber.Map{
"count": count,
"data": members,
})
}
}