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