41 lines
886 B
Go
41 lines
886 B
Go
package admin
|
|
|
|
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/admin/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)
|
|
}
|
|
|
|
// Create
|
|
// @Router /v1/admin/posts [post]
|
|
// @Bind form body
|
|
func (ctl *posts) Create(ctx fiber.Ctx, form *model.Posts) error {
|
|
return nil
|
|
}
|
|
|
|
// Update posts
|
|
// @Router /v1/admin/posts/:id [put]
|
|
// @Bind id path
|
|
// @Bind form body
|
|
func (ctl *posts) Update(ctx fiber.Ctx, id int64, form *model.Posts) error {
|
|
return nil
|
|
}
|