feat: Update project structure and configuration files
This commit is contained in:
32
backend/app/http/posts.go
Normal file
32
backend/app/http/posts.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"quyun/app/models"
|
||||
"quyun/app/requests"
|
||||
"quyun/database/schemas/public/model"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
type ListQuery struct {
|
||||
Key *string `query:"key"`
|
||||
}
|
||||
|
||||
// @provider
|
||||
type posts struct{}
|
||||
|
||||
// List posts
|
||||
// @Router /v1/posts [get]
|
||||
// @Bind pagination query
|
||||
// @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/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