feat: update module
This commit is contained in:
@@ -8,20 +8,24 @@ import (
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type ListQuery struct {
|
||||
Key *string `query:"key"`
|
||||
}
|
||||
|
||||
// @provider
|
||||
type posts struct{}
|
||||
|
||||
// List posts
|
||||
// @Router /v1/medias [get]
|
||||
// @Router /v1/posts [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)
|
||||
// @Bind query query
|
||||
func (ctl *posts) List(ctx fiber.Ctx, pagination *requests.Pagination, query *ListQuery) (*requests.Pager, error) {
|
||||
cond := models.Posts.BuildConditionWithKey(query.Key)
|
||||
return models.Posts.List(ctx.Context(), pagination, cond)
|
||||
}
|
||||
|
||||
// Show
|
||||
// @Router /v1/medias/:id [get]
|
||||
// @Router /v1/posts/:id [get]
|
||||
// @Bind id path
|
||||
func (ctl *posts) Show(ctx fiber.Ctx, id int64) (*model.Posts, error) {
|
||||
return models.Posts.GetByID(ctx.Context(), id)
|
||||
|
||||
Reference in New Issue
Block a user