feat: add medias
This commit is contained in:
30
backend/modules/medias/controller.go
Normal file
30
backend/modules/medias/controller.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user