feat: update module

This commit is contained in:
rogeecn
2025-03-22 19:42:43 +08:00
parent f06073e89a
commit 1d66f95397
11 changed files with 156 additions and 48 deletions

View File

@@ -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)