feat: add medias

This commit is contained in:
Rogee
2024-12-02 17:48:46 +08:00
parent 2b4cfb1a1e
commit 9e7b35e3c9
17 changed files with 806 additions and 11 deletions

View File

@@ -0,0 +1,30 @@
package medias
import (
"backend/common/errorx"
"github.com/gofiber/fiber/v3"
. "github.com/spf13/cast"
)
// @provider
type Controller struct {
svc *Service
}
// List
func (c *Controller) List(ctx fiber.Ctx) error {
filter := ListFilter{}
if err := ctx.Bind().Body(&filter); err != nil {
return ctx.Status(fiber.StatusBadRequest).JSON(errorx.RequestParseError)
}
tenantId, userId := ToInt64(ctx.Locals("tenantId")), ToInt64(ctx.Locals("userId"))
items, err := c.svc.List(ctx.Context(), tenantId, userId, &filter)
if err != nil {
return ctx.Status(fiber.StatusInternalServerError).JSON(errorx.InternalError)
}
return ctx.JSON(items)
}