@gt6/sdk 1.0.28 → 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.
@@ -108,7 +108,7 @@ class ArticlesAPI {
108
108
  return this.client.request(`/articles/${articleId}.json`);
109
109
  }
110
110
  /**
111
- * 1.1 根据文章ID获取文章详情(使用上级平台ID)
111
+ * 1.1 根据文章ID获取文章详情(平台使用)
112
112
  */
113
113
  async getArticle_p(articleId) {
114
114
  return this.client.request(`/parentarticles/${articleId}.json`);
@@ -909,6 +909,40 @@ class ProductsAPI {
909
909
  limit
910
910
  };
911
911
  }
912
+ /**
913
+ * 4.3. 根据大分类ID获取平台产品列表
914
+ * 先从big-product-categories/${categoryId}.json获取产品ID,再分页后用getProduct_p获取详情
915
+ */
916
+ async getProductsByCategory_b(categoryId, options) {
917
+ // 从大型分类静态文件获取该分类的产品ID列表
918
+ const categoryData = await this.client.request(`/big-product-categories/${categoryId}.json`);
919
+ if (!categoryData || !categoryData.productIds || categoryData.productIds.length === 0) {
920
+ return {
921
+ products: [],
922
+ total: 0,
923
+ page: options?.page || 1,
924
+ limit: options?.limit || 10
925
+ };
926
+ }
927
+ // 应用分页
928
+ const page = options?.page || 1;
929
+ const limit = options?.limit || 10;
930
+ const offset = (page - 1) * limit;
931
+ const paginatedProductIds = categoryData.productIds.slice(offset, offset + limit);
932
+ // 获取产品详情(使用上级平台数据)
933
+ const products = await Promise.all(paginatedProductIds.map(productId => this.getProduct_p(productId)));
934
+ // 应用状态过滤
935
+ let filteredProducts = products;
936
+ if (options?.status !== undefined) {
937
+ filteredProducts = products.filter(product => product.status === options.status);
938
+ }
939
+ return {
940
+ products: filteredProducts,
941
+ total: categoryData.productIds.length,
942
+ page,
943
+ limit
944
+ };
945
+ }
912
946
  /**
913
947
  * 5. 根据标签ID获取产品列表
914
948
  * 支持单个标签ID或标签ID数组
@@ -2743,6 +2777,12 @@ class GT6SDK {
2743
2777
  async getProductsByCategory_t(categoryId, options) {
2744
2778
  return this.products.getProductsByCategory_t(categoryId, options);
2745
2779
  }
2780
+ /**
2781
+ * 11.3. 便捷方法:根据大分类ID获取平台产品列表(从big-product-categories静态JSON获取)
2782
+ */
2783
+ async getProductsByCategory_b(categoryId, options) {
2784
+ return this.products.getProductsByCategory_b(categoryId, options);
2785
+ }
2746
2786
  /**
2747
2787
  * 12. 便捷方法:根据标签ID获取产品列表
2748
2788
  */