feat: 更新内容相关接口,使用统一的分页响应结构

This commit is contained in:
2025-12-29 10:14:47 +08:00
parent 62262bbac2
commit d482905157
3 changed files with 13 additions and 21 deletions

View File

@@ -2,6 +2,7 @@ package v1
import (
"quyun/v2/app/http/v1/dto"
"quyun/v2/app/requests"
"quyun/v2/app/services"
"github.com/gofiber/fiber/v3"
@@ -23,7 +24,7 @@ type Content struct{}
// @Param tenantId query string false "Filter by creator"
// @Param sort query string false "Sort order" Enums(latest, hot, price_asc)
// @Param page query int false "Page number"
// @Success 200 {object} dto.ContentListResponse
// @Success 200 {object} requests.Pager{items=[]dto.ContentItem}
// @Bind keyword query
// @Bind genre query
// @Bind tenantId query
@@ -33,7 +34,7 @@ func (c *Content) List(
ctx fiber.Ctx,
keyword, genre, tenantId, sort string,
page int,
) (*dto.ContentListResponse, error) {
) (*requests.Pager, error) {
return services.Content.List(ctx.Context(), keyword, genre, tenantId, sort, page)
}
@@ -62,10 +63,10 @@ func (c *Content) Get(ctx fiber.Ctx, id string) (*dto.ContentDetail, error) {
// @Produce json
// @Param id path string true "Content ID"
// @Param page query int false "Page number"
// @Success 200 {object} dto.CommentListResponse
// @Success 200 {object} requests.Pager{items=[]dto.Comment}
// @Bind id path
// @Bind page query
func (c *Content) ListComments(ctx fiber.Ctx, id string, page int) (*dto.CommentListResponse, error) {
func (c *Content) ListComments(ctx fiber.Ctx, id string, page int) (*requests.Pager, error) {
return services.Content.ListComments(ctx.Context(), id, page)
}
@@ -112,4 +113,4 @@ func (c *Content) LikeComment(ctx fiber.Ctx, id string) error {
// @Success 200 {array} dto.Topic
func (c *Content) ListTopics(ctx fiber.Ctx) ([]dto.Topic, error) {
return services.Content.ListTopics(ctx.Context())
}
}

View File

@@ -51,21 +51,11 @@ type Comment struct {
ReplyTo string `json:"replyTo"`
}
type CommentListResponse struct {
Data []Comment `json:"data"`
Pagination requests.Pagination `json:"pagination"`
}
type CommentCreateForm struct {
Content string `json:"content"`
ReplyTo string `json:"replyTo"`
}
type ContentListResponse struct {
Data []ContentItem `json:"data"`
Pagination requests.Pagination `json:"pagination"`
}
type Topic struct {
ID string `json:"id"`
Title string `json:"title"`
@@ -81,4 +71,4 @@ type ContentPrice struct {
DiscountValue float64 `json:"discountValue"`
DiscountStartAt string `json:"discountStartAt"`
DiscountEndAt string `json:"discountEndAt"`
}
}