refactor: 移除不必要的上下文调用,简化服务方法参数
This commit is contained in:
@@ -30,7 +30,7 @@ func (c *Content) List(
|
||||
ctx fiber.Ctx,
|
||||
filter *dto.ContentListFilter,
|
||||
) (*requests.Pager, error) {
|
||||
return services.Content.List(ctx.Context(), filter)
|
||||
return services.Content.List(ctx, filter)
|
||||
}
|
||||
|
||||
// Get content detail
|
||||
@@ -45,7 +45,7 @@ func (c *Content) List(
|
||||
// @Success 200 {object} dto.ContentDetail
|
||||
// @Bind id path
|
||||
func (c *Content) Get(ctx fiber.Ctx, id string) (*dto.ContentDetail, error) {
|
||||
return services.Content.Get(ctx.Context(), id)
|
||||
return services.Content.Get(ctx, id)
|
||||
}
|
||||
|
||||
// Get comments for a content
|
||||
@@ -62,7 +62,7 @@ func (c *Content) Get(ctx fiber.Ctx, id string) (*dto.ContentDetail, error) {
|
||||
// @Bind id path
|
||||
// @Bind page query
|
||||
func (c *Content) ListComments(ctx fiber.Ctx, id string, page int) (*requests.Pager, error) {
|
||||
return services.Content.ListComments(ctx.Context(), id, page)
|
||||
return services.Content.ListComments(ctx, id, page)
|
||||
}
|
||||
|
||||
// Post a comment
|
||||
@@ -79,7 +79,7 @@ func (c *Content) ListComments(ctx fiber.Ctx, id string, page int) (*requests.Pa
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Content) CreateComment(ctx fiber.Ctx, id string, form *dto.CommentCreateForm) error {
|
||||
return services.Content.CreateComment(ctx.Context(), id, form)
|
||||
return services.Content.CreateComment(ctx, id, form)
|
||||
}
|
||||
|
||||
// Like a comment
|
||||
@@ -94,7 +94,7 @@ func (c *Content) CreateComment(ctx fiber.Ctx, id string, form *dto.CommentCreat
|
||||
// @Success 200 {string} string "Liked"
|
||||
// @Bind id path
|
||||
func (c *Content) LikeComment(ctx fiber.Ctx, id string) error {
|
||||
return services.Content.LikeComment(ctx.Context(), id)
|
||||
return services.Content.LikeComment(ctx, id)
|
||||
}
|
||||
|
||||
// List curated topics
|
||||
@@ -107,5 +107,5 @@ func (c *Content) LikeComment(ctx fiber.Ctx, id string) error {
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.Topic
|
||||
func (c *Content) ListTopics(ctx fiber.Ctx) ([]dto.Topic, error) {
|
||||
return services.Content.ListTopics(ctx.Context())
|
||||
return services.Content.ListTopics(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user