💥 Unified the publisher api

This commit is contained in:
2024-11-09 00:47:19 +08:00
parent f9a01bff70
commit 615fe3ff6c
4 changed files with 19 additions and 12 deletions

View File

@ -14,8 +14,8 @@ func MapAPIs(app *fiber.App, baseURL string) {
publishers.Post("/organization", createOrganizationPublisher)
publishers.Get("/:name/pins", listPinnedPost)
publishers.Get("/:name", getPublisher)
publishers.Put("/:publisherId", editPublisher)
publishers.Delete("/:publisherId", deletePublisher)
publishers.Put("/:name", editPublisher)
publishers.Delete("/:name", deletePublisher)
}
recommendations := api.Group("/recommendations").Name("Recommendations API")

View File

@ -109,8 +109,8 @@ func editPublisher(c *fiber.Ctx) error {
}
user := c.Locals("user").(authm.Account)
id, _ := c.ParamsInt("publisherId", 0)
publisher, err := services.GetPublisher(uint(id), user.ID)
name := c.Params("name")
publisher, err := services.GetPublisherByName(name, user.ID)
if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}
@ -150,8 +150,8 @@ func deletePublisher(c *fiber.Ctx) error {
}
user := c.Locals("user").(authm.Account)
id, _ := c.ParamsInt("publisherId", 0)
publisher, err := services.GetPublisher(uint(id), user.ID)
name := c.Params("name")
publisher, err := services.GetPublisherByName(name, user.ID)
if err != nil {
return fiber.NewError(fiber.StatusNotFound, err.Error())
}