feat: Enhance Swagger documentation with new admin and user endpoints
Some checks failed
build quyun / Build (push) Failing after 2m1s

- 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.
This commit is contained in:
2025-12-19 23:43:46 +08:00
parent 49072ddd79
commit 7b18a6a0e6
14 changed files with 4180 additions and 120 deletions

View File

@@ -38,10 +38,16 @@ type posts struct {
// List posts
//
// @Router /posts [get]
// @Bind pagination query
// @Bind query query
// @Bind user local
// @Summary 作品列表
// @Tags Posts
// @Produce json
// @Param pagination query requests.Pagination false "分页参数"
// @Param query query ListQuery false "筛选条件"
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
// @Router /posts [get]
// @Bind pagination query
// @Bind query query
// @Bind user local
func (ctl *posts) List(
ctx fiber.Ctx,
pagination *requests.Pagination,
@@ -123,9 +129,14 @@ type PostItem struct {
// Show
//
// @Router /posts/:id/show [get]
// @Bind id path
// @Bind user local
// @Summary 作品详情
// @Tags Posts
// @Produce json
// @Param id path int64 true "作品 ID"
// @Success 200 {object} PostItem "成功"
// @Router /posts/:id/show [get]
// @Bind id path
// @Bind user local
func (ctl *posts) Show(ctx fiber.Ctx, id int64, user *models.User) (*PostItem, error) {
log.Infof("Fetching post with ID: %d", id)
@@ -179,9 +190,14 @@ type PlayUrl struct {
// Play
//
// @Router /posts/:id/play [get]
// @Bind id path
// @Bind user local
// @Summary 获取播放地址
// @Tags Posts
// @Produce json
// @Param id path int64 true "作品 ID"
// @Success 200 {object} PlayUrl "成功"
// @Router /posts/:id/play [get]
// @Bind id path
// @Bind user local
func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *models.User) (*PlayUrl, error) {
log := log.WithField("PlayPostID", strconv.FormatInt(id, 10))
// return &PlayUrl{
@@ -230,10 +246,16 @@ func (ctl *posts) Play(ctx fiber.Ctx, id int64, user *models.User) (*PlayUrl, er
// Mine posts
//
// @Router /posts/mine [get]
// @Bind pagination query
// @Bind query query
// @Bind user local
// @Summary 我的已购作品
// @Tags Posts
// @Produce json
// @Param pagination query requests.Pagination false "分页参数"
// @Param query query ListQuery false "筛选条件"
// @Success 200 {object} requests.Pager{items=PostItem} "成功"
// @Router /posts/mine [get]
// @Bind pagination query
// @Bind query query
// @Bind user local
func (ctl *posts) Mine(
ctx fiber.Ctx,
pagination *requests.Pagination,
@@ -292,9 +314,14 @@ func (ctl *posts) Mine(
// Buy
//
// @Router /posts/:id/buy [post]
// @Bind id path
// @Bind user local
// @Summary 购买作品
// @Tags Posts
// @Produce json
// @Param id path int64 true "作品 ID"
// @Success 200 {object} wechat.JSAPIPayParams "成功(余额支付返回 AppId=balance"
// @Router /posts/:id/buy [post]
// @Bind id path
// @Bind user local
func (ctl *posts) Buy(ctx fiber.Ctx, id int64, user *models.User) (*wechat.JSAPIPayParams, error) {
bought, err := services.Users.HasBought(ctx, user.ID, id)
if err != nil {