@gt6/sdk 1.0.27 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,7 +104,7 @@ class ArticlesAPI {
104
104
  return this.client.request(`/articles/${articleId}.json`);
105
105
  }
106
106
  /**
107
- * 1.1 根据文章ID获取文章详情(使用上级平台ID)
107
+ * 1.1 根据文章ID获取文章详情(平台使用)
108
108
  */
109
109
  async getArticle_p(articleId) {
110
110
  return this.client.request(`/parentarticles/${articleId}.json`);
@@ -292,6 +292,40 @@ class ArticlesAPI {
292
292
  limit
293
293
  };
294
294
  }
295
+ /**
296
+ * 4.3 根据分类ID获取文章列表(使用大型分类静态文件)
297
+ * 只支持单个分类ID,从大型分类静态文件获取文章ID列表
298
+ */
299
+ async getArticlesByCategory_a(categoryId, options) {
300
+ // 从大型分类静态文件获取该分类的文章ID列表
301
+ const categoryData = await this.client.request(`/big-article-categories/${categoryId}.json`);
302
+ if (!categoryData || !categoryData.articleIds || categoryData.articleIds.length === 0) {
303
+ return {
304
+ articles: [],
305
+ total: 0,
306
+ page: options?.page || 1,
307
+ limit: options?.limit || 10
308
+ };
309
+ }
310
+ // 应用分页
311
+ const page = options?.page || 1;
312
+ const limit = options?.limit || 10;
313
+ const offset = (page - 1) * limit;
314
+ const paginatedArticleIds = categoryData.articleIds.slice(offset, offset + limit);
315
+ // 获取文章详情(使用上级平台数据)
316
+ const articles = await Promise.all(paginatedArticleIds.map(articleId => this.getArticle_p(articleId)));
317
+ // 应用状态过滤
318
+ let filteredArticles = articles;
319
+ if (options?.status) {
320
+ filteredArticles = articles.filter(article => article.status === options.status);
321
+ }
322
+ return {
323
+ articles: filteredArticles,
324
+ total: categoryData.articleIds.length,
325
+ page,
326
+ limit
327
+ };
328
+ }
295
329
  /**
296
330
  * 5. 根据标签ID获取文章列表
297
331
  * 支持单个标签ID或标签ID数组
@@ -871,6 +905,40 @@ class ProductsAPI {
871
905
  limit
872
906
  };
873
907
  }
908
+ /**
909
+ * 4.3. 根据大分类ID获取平台产品列表
910
+ * 先从big-product-categories/${categoryId}.json获取产品ID,再分页后用getProduct_p获取详情
911
+ */
912
+ async getProductsByCategory_b(categoryId, options) {
913
+ // 从大型分类静态文件获取该分类的产品ID列表
914
+ const categoryData = await this.client.request(`/big-product-categories/${categoryId}.json`);
915
+ if (!categoryData || !categoryData.productIds || categoryData.productIds.length === 0) {
916
+ return {
917
+ products: [],
918
+ total: 0,
919
+ page: options?.page || 1,
920
+ limit: options?.limit || 10
921
+ };
922
+ }
923
+ // 应用分页
924
+ const page = options?.page || 1;
925
+ const limit = options?.limit || 10;
926
+ const offset = (page - 1) * limit;
927
+ const paginatedProductIds = categoryData.productIds.slice(offset, offset + limit);
928
+ // 获取产品详情(使用上级平台数据)
929
+ const products = await Promise.all(paginatedProductIds.map(productId => this.getProduct_p(productId)));
930
+ // 应用状态过滤
931
+ let filteredProducts = products;
932
+ if (options?.status !== undefined) {
933
+ filteredProducts = products.filter(product => product.status === options.status);
934
+ }
935
+ return {
936
+ products: filteredProducts,
937
+ total: categoryData.productIds.length,
938
+ page,
939
+ limit
940
+ };
941
+ }
874
942
  /**
875
943
  * 5. 根据标签ID获取产品列表
876
944
  * 支持单个标签ID或标签ID数组
@@ -2609,6 +2677,12 @@ class GT6SDK {
2609
2677
  async getArticlesByCategory_t(categoryId, options) {
2610
2678
  return this.articles.getArticlesByCategory_t(categoryId, options);
2611
2679
  }
2680
+ /**
2681
+ * 4.3. 便捷方法:根据分类ID获取文章列表(从大型静态JSON文件获取)
2682
+ */
2683
+ async getArticlesByCategory_a(categoryId, options) {
2684
+ return this.articles.getArticlesByCategory_a(categoryId, options);
2685
+ }
2612
2686
  /**
2613
2687
  * 5. 便捷方法:根据标签ID获取文章列表
2614
2688
  */
@@ -2699,6 +2773,12 @@ class GT6SDK {
2699
2773
  async getProductsByCategory_t(categoryId, options) {
2700
2774
  return this.products.getProductsByCategory_t(categoryId, options);
2701
2775
  }
2776
+ /**
2777
+ * 11.3. 便捷方法:根据大分类ID获取平台产品列表(从big-product-categories静态JSON获取)
2778
+ */
2779
+ async getProductsByCategory_b(categoryId, options) {
2780
+ return this.products.getProductsByCategory_b(categoryId, options);
2781
+ }
2702
2782
  /**
2703
2783
  * 12. 便捷方法:根据标签ID获取产品列表
2704
2784
  */