From d482905157acef161f3597af3e36d52cacfaf198 Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 29 Dec 2025 10:14:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E7=9A=84=E5=88=86=E9=A1=B5=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/http/v1/content.go | 11 ++++++----- backend/app/http/v1/dto/content.go | 12 +----------- backend/app/services/content.go | 11 ++++++----- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/backend/app/http/v1/content.go b/backend/app/http/v1/content.go index 4d8aecf..d9b8074 100644 --- a/backend/app/http/v1/content.go +++ b/backend/app/http/v1/content.go @@ -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()) -} +} \ No newline at end of file diff --git a/backend/app/http/v1/dto/content.go b/backend/app/http/v1/dto/content.go index 575c97d..2929183 100644 --- a/backend/app/http/v1/dto/content.go +++ b/backend/app/http/v1/dto/content.go @@ -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"` -} +} \ No newline at end of file diff --git a/backend/app/services/content.go b/backend/app/services/content.go index 15fda72..f1f8ba1 100644 --- a/backend/app/services/content.go +++ b/backend/app/services/content.go @@ -5,21 +5,22 @@ import ( content_dto "quyun/v2/app/http/v1/dto" user_dto "quyun/v2/app/http/v1/dto" + "quyun/v2/app/requests" ) // @provider type content struct{} -func (s *content) List(ctx context.Context, keyword, genre, tenantId, sort string, page int) (*content_dto.ContentListResponse, error) { - return &content_dto.ContentListResponse{}, nil +func (s *content) List(ctx context.Context, keyword, genre, tenantId, sort string, page int) (*requests.Pager, error) { + return &requests.Pager{}, nil } func (s *content) Get(ctx context.Context, id string) (*content_dto.ContentDetail, error) { return &content_dto.ContentDetail{}, nil } -func (s *content) ListComments(ctx context.Context, id string, page int) (*content_dto.CommentListResponse, error) { - return &content_dto.CommentListResponse{}, nil +func (s *content) ListComments(ctx context.Context, id string, page int) (*requests.Pager, error) { + return &requests.Pager{}, nil } func (s *content) CreateComment(ctx context.Context, id string, form *content_dto.CommentCreateForm) error { @@ -60,4 +61,4 @@ func (s *content) RemoveLike(ctx context.Context, contentId string) error { func (s *content) ListTopics(ctx context.Context) ([]content_dto.Topic, error) { return []content_dto.Topic{}, nil -} +} \ No newline at end of file