✨ Able to get sticker pack by id
This commit is contained in:
parent
fa997a19a1
commit
fdadebbeab
@ -26,6 +26,7 @@ func MapAPIs(app *fiber.App, baseURL string) {
|
||||
api.Get("/stickers/lookup", lookupStickerBatch)
|
||||
api.Get("/stickers/lookup/:alias", lookupSticker)
|
||||
api.Get("/stickers/packs", listStickerPacks)
|
||||
api.Get("/stickers/packs/:packId", getStickerPack)
|
||||
api.Post("/stickers/packs", createStickerPack)
|
||||
api.Put("/stickers/packs/:packId", updateStickerPack)
|
||||
api.Delete("/stickers/packs/:packId", deleteStickerPack)
|
||||
|
@ -44,6 +44,16 @@ func listStickerPacks(c *fiber.Ctx) error {
|
||||
})
|
||||
}
|
||||
|
||||
func getStickerPack(c *fiber.Ctx) error {
|
||||
id, _ := c.ParamsInt("packId", 0)
|
||||
pack, err := services.GetStickerPack(uint(id))
|
||||
if err != nil {
|
||||
return fiber.NewError(fiber.StatusNotFound, err.Error())
|
||||
}
|
||||
|
||||
return c.JSON(pack)
|
||||
}
|
||||
|
||||
func createStickerPack(c *fiber.Ctx) error {
|
||||
if err := gap.H.EnsureAuthenticated(c); err != nil {
|
||||
return err
|
||||
|
@ -6,6 +6,14 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetStickerPack(id uint) (models.StickerPack, error) {
|
||||
var pack models.StickerPack
|
||||
if err := database.C.Where("id = ?", id).First(&pack).Error; err != nil {
|
||||
return pack, err
|
||||
}
|
||||
return pack, nil
|
||||
}
|
||||
|
||||
func GetStickerPackWithUser(id, userId uint) (models.StickerPack, error) {
|
||||
var pack models.StickerPack
|
||||
if err := database.C.Where("id = ? AND account_id = ?", id, userId).First(&pack).Error; err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user