🎨 Re-orgnize api index

This commit is contained in:
LittleSheep 2024-12-28 22:04:48 +08:00
parent d59966a03e
commit b73f5e1912
2 changed files with 42 additions and 26 deletions

View File

@ -17,34 +17,50 @@ func MapAPIs(app *fiber.App, baseURL string) {
boost.Put("/:id", sec.ValidatorMiddleware, updateBoost) boost.Put("/:id", sec.ValidatorMiddleware, updateBoost)
} }
api.Get("/pools", listPost) pools := api.Get("/pools").Name("Pools API")
api.Get("/pools/:id", getPool) {
api.Post("/pools", sec.ValidatorMiddleware, createPool) pools.Get("/", listPool)
api.Put("/pools/:id", sec.ValidatorMiddleware, updatePool) pools.Get("/:id", getPool)
api.Delete("/pools/:id", sec.ValidatorMiddleware, deletePool) pools.Post("/", sec.ValidatorMiddleware, createPool)
pools.Put("/:id", sec.ValidatorMiddleware, updatePool)
pools.Delete("/:id", sec.ValidatorMiddleware, deletePool)
}
api.Get("/attachments", listAttachment) attachments := api.Get("/attachments").Name("Attachments API")
api.Get("/attachments/:id/meta", getAttachmentMeta) {
api.Get("/attachments/:id", openAttachment) attachments.Get("/", listAttachment)
api.Post("/attachments", sec.ValidatorMiddleware, createAttachmentDirectly) attachments.Get("/:id/meta", getAttachmentMeta)
api.Put("/attachments/:id", sec.ValidatorMiddleware, updateAttachmentMeta) attachments.Get("/:id", openAttachment)
api.Delete("/attachments/:id", sec.ValidatorMiddleware, deleteAttachment) attachments.Post("/", sec.ValidatorMiddleware, createAttachmentDirectly)
attachments.Put("/:id", sec.ValidatorMiddleware, updateAttachmentMeta)
attachments.Delete("/:id", sec.ValidatorMiddleware, deleteAttachment)
}
api.Post("/fragments", sec.ValidatorMiddleware, createAttachmentFragment) fragments := api.Get("/fragments").Name("Fragments API")
api.Post("/fragments/:file/:chunk", sec.ValidatorMiddleware, uploadFragmentChunk) {
fragments.Post("/", sec.ValidatorMiddleware, createAttachmentFragment)
fragments.Post("/:file/:chunk", sec.ValidatorMiddleware, uploadFragmentChunk)
}
api.Get("/stickers/lookup", lookupStickerBatch) stickers := api.Get("/stickers").Name("Stickers API")
api.Get("/stickers/lookup/:alias", lookupSticker) {
api.Get("/stickers/packs", listStickerPacks) stickers.Get("/lookup", lookupStickerBatch)
api.Get("/stickers/packs/:packId", getStickerPack) stickers.Get("/lookup/:alias", lookupSticker)
api.Post("/stickers/packs", sec.ValidatorMiddleware, createStickerPack)
api.Put("/stickers/packs/:packId", sec.ValidatorMiddleware, updateStickerPack)
api.Delete("/stickers/packs/:packId", sec.ValidatorMiddleware, deleteStickerPack)
api.Get("/stickers", listStickers) stickers.Get("/", listStickers)
api.Get("/stickers/:stickerId", getSticker) stickers.Get("/:stickerId", getSticker)
api.Post("/stickers", sec.ValidatorMiddleware, createSticker) stickers.Post("/", sec.ValidatorMiddleware, createSticker)
api.Put("/stickers/:stickerId", sec.ValidatorMiddleware, updateSticker) stickers.Put("/:stickerId", sec.ValidatorMiddleware, updateSticker)
api.Delete("/stickers/:stickerId", sec.ValidatorMiddleware, deleteSticker) stickers.Delete("/:stickerId", sec.ValidatorMiddleware, deleteSticker)
packs := stickers.Group("/packs").Name("Sticker Packs API")
{
packs.Get("/", listStickerPacks)
packs.Get("/:packId", getStickerPack)
packs.Post("/", sec.ValidatorMiddleware, createStickerPack)
packs.Put("/:packId", sec.ValidatorMiddleware, updateStickerPack)
packs.Delete("/:packId", sec.ValidatorMiddleware, deleteStickerPack)
}
}
} }
} }

View File

@ -9,7 +9,7 @@ import (
"gorm.io/datatypes" "gorm.io/datatypes"
) )
func listPost(c *fiber.Ctx) error { func listPool(c *fiber.Ctx) error {
pools, err := services.ListAttachmentPool() pools, err := services.ListAttachmentPool()
if err != nil { if err != nil {
return fiber.NewError(fiber.StatusBadRequest, err.Error()) return fiber.NewError(fiber.StatusBadRequest, err.Error())