Files
quyun/app/http/posts.go
2025-03-22 19:34:25 +08:00

29 lines
665 B
Go

package http
import (
"quyun/app/models"
"quyun/app/requests"
"quyun/database/schemas/public/model"
"github.com/gofiber/fiber/v3"
)
// @provider
type posts struct{}
// List posts
// @Router /v1/medias [get]
// @Bind pagination query
// @bind key query
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, key *string) (*requests.Pager, error) {
cond := models.Posts.BuildConditionWithKey(key)
return models.Posts.List(ctx.Context(), pagination, cond)
}
// Show
// @Router /v1/medias/:id [get]
// @Bind id path
func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*model.Posts, error) {
return models.Posts.GetByID(ctx.Context(), id)
}