Files
quyun/backend_v1/app/http/v1/demo.go
Rogee 7b18a6a0e6
Some checks failed
build quyun / Build (push) Failing after 2m1s
feat: Enhance Swagger documentation with new admin and user endpoints
- Added definitions for admin authentication, media, posts, orders, and user management.
- Implemented new API paths for admin functionalities including authentication, media management, order processing, and user statistics.
- Updated existing endpoints to improve clarity and structure in the Swagger documentation.
- Introduced new response schemas for various operations to standardize API responses.
2025-12-19 23:43:46 +08:00

77 lines
1.8 KiB
Go

package v1
import (
"mime/multipart"
"quyun/v2/app/requests"
"quyun/v2/providers/jwt"
"github.com/gofiber/fiber/v3"
)
// @provider
type demo struct{}
type FooUploadReq struct {
Folder string `json:"folder" form:"folder"` // 上传到指定文件夹
}
type FooQuery struct {
Search string `query:"search"` // 搜索关键词
}
type FooHeader struct {
ContentType string `header:"Content-Type"` // 内容类型
}
type Filter struct {
Name string `query:"name"` // 名称
Age int `query:"age"` // 年龄
}
type ResponseItem struct{}
// Foo 演示端点:展示 Fiber 参数绑定与 Swagger 注释写法。
//
// @Summary 演示接口
// @Tags Demo
// @Accept multipart/form-data
// @Produce json
//
// @Param id path int true "ID"
// @Param pager query requests.Pagination false "分页参数"
// @Param query query FooQuery false "查询参数"
// @Param Content-Type header string false "内容类型"
// @Param folder formData string false "上传到指定文件夹"
// @Param file formData file true "上传文件"
// @Success 200 {object} requests.Pager{items=ResponseItem} "成功"
//
// @Router /v1/medias/:id [post]
// @Bind query query
// @Bind pager query
// @Bind header header
// @Bind id path
// @Bind req body
// @Bind file file
// @Bind claim local
func (d *demo) Foo(
ctx fiber.Ctx,
id int,
pager *requests.Pagination,
query *FooQuery,
header *FooHeader,
claim *jwt.Claims,
file *multipart.FileHeader,
req *FooUploadReq,
) error {
// _, err := services.Test.Test(ctx)
// if err != nil {
// // 示例:在控制器层自定义错误消息/附加数据
// appErr := errorx.Wrap(err).
// WithMsg("获取测试失败").
// WithData(fiber.Map{"route": "/v1/test"}).
// WithParams("handler", "Test.Hello")
// return appErr
// }
return nil
}