From ef2eb3e73e514f038430240f157230a086a39ad9 Mon Sep 17 00:00:00 2001 From: CyJaySong Date: Mon, 17 Jul 2023 15:44:18 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E8=8E=B7=E5=8F=96=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E6=97=B6=EF=BC=8C=E6=94=AF=E6=8C=81=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/client.go b/client/client.go index 828f4dca6..51e47db89 100644 --- a/client/client.go +++ b/client/client.go @@ -92,8 +92,6 @@ func (c *GorseClient) ListFeedbacks(ctx context.Context, feedbackType, userId st return request[[]Feedback, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/user/%s/feedback/%s", userId, feedbackType), nil) } -////// - func (c *GorseClient) GetItemLatest(ctx context.Context, userid string, n, offset int) ([]Score, error) { return request[[]Score, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/latest?user-id=%s&n=%d&offset=%d", userid, n, offset), nil) } @@ -110,16 +108,20 @@ func (c *GorseClient) GetItemPopularWithCategory(ctx context.Context, userid, ca return request[[]Score, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/popular/%s?user-id=%s&n=%d&offset=%d", category, userid, n, offset), nil) } -func (c *GorseClient) GetItemRecommend(ctx context.Context, userId string, writeBackType, writeBackDelay string, n, offset int) ([]string, error) { - return request[[]string, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/recommend/%s?write-back-type=%s&write-back-delay=%s&n=%d&offset=%d", userId, writeBackType, writeBackDelay, n, offset), nil) +func (c *GorseClient) GetItemRecommend(ctx context.Context, userId string, categories []string, writeBackType, writeBackDelay string, n, offset int) ([]string, error) { + var queryCategories string + if len(categories) > 0 { + queryCategories = "&category=" + strings.Join(categories, "&category=") + } + return request[[]string, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/recommend/%s?write-back-type=%s&write-back-delay=%s&n=%d&offset=%d%s", userId, writeBackType, writeBackDelay, n, offset, queryCategories), nil) } -func (c *GorseClient) GetItemRecommendWithCategory(ctx context.Context, userId string, category, writeBackType, writeBackDelay string, n, offset int) ([]string, error) { +func (c *GorseClient) GetItemRecommendWithCategory(ctx context.Context, userId, category, writeBackType, writeBackDelay string, n, offset int) ([]string, error) { return request[[]string, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/recommend/%s/%s?write-back-type=%s&write-back-delay=%s&n=%d&offset=%d", userId, category, writeBackType, writeBackDelay, n, offset), nil) } // Deprecated: GetItemRecommendWithCategory instead -func (c *GorseClient) GetRecommend(ctx context.Context, userId string, category string, n int) ([]string, error) { +func (c *GorseClient) GetRecommend(ctx context.Context, userId, category string, n int) ([]string, error) { return request[[]string, any](ctx, c, "GET", c.entryPoint+fmt.Sprintf("/api/recommend/%s/%s?n=%d", userId, category, n), nil) }