@gt6/sdk 1.0.38 → 1.0.40
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.
- package/dist/gt6-sdk.cjs.js +141 -0
- package/dist/gt6-sdk.cjs.js.map +1 -1
- package/dist/gt6-sdk.esm.js +141 -0
- package/dist/gt6-sdk.esm.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/modules/articles.d.ts +38 -0
- package/dist/modules/articles.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/gt6-sdk.esm.js
CHANGED
|
@@ -644,6 +644,144 @@ class ArticlesAPI {
|
|
|
644
644
|
const limit = options?.limit || 10;
|
|
645
645
|
const offset = (page - 1) * limit;
|
|
646
646
|
const paginatedArticleIds = categoryData.articleIds.slice(offset, offset + limit);
|
|
647
|
+
// 获取文章详情 - 修复:提取 articleId 字段
|
|
648
|
+
const articles = await Promise.all(paginatedArticleIds.map(articleObj => this.getArticle_all(articleObj.articleId)));
|
|
649
|
+
// 应用状态过滤
|
|
650
|
+
let filteredArticles = articles;
|
|
651
|
+
if (options?.status) {
|
|
652
|
+
filteredArticles = articles.filter(article => article.status === options.status);
|
|
653
|
+
}
|
|
654
|
+
return {
|
|
655
|
+
articles: filteredArticles,
|
|
656
|
+
total: categoryData.articleIds.length,
|
|
657
|
+
page,
|
|
658
|
+
limit
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* 1.2.2 根据分类ID获取文章列表(支持搜索过滤)
|
|
663
|
+
*/
|
|
664
|
+
async getArticlesByCategory_all_search(categoryId, searchOptions) {
|
|
665
|
+
// 从大型分类静态文件获取该分类的文章ID列表
|
|
666
|
+
const categoryData = await this.client.request(`/big-article-categories/${categoryId}.json`);
|
|
667
|
+
if (!categoryData || !categoryData.articleIds || categoryData.articleIds.length === 0) {
|
|
668
|
+
return {
|
|
669
|
+
articles: [],
|
|
670
|
+
total: 0,
|
|
671
|
+
page: searchOptions?.page || 1,
|
|
672
|
+
limit: searchOptions?.limit || 10,
|
|
673
|
+
filteredTotal: 0
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
// 应用搜索过滤
|
|
677
|
+
let filteredArticleIds = categoryData.articleIds.filter(articleObj => {
|
|
678
|
+
// 1. regionId 过滤
|
|
679
|
+
if (searchOptions?.regionIds && searchOptions.regionIds.length > 0) {
|
|
680
|
+
if (!articleObj.regionId || !searchOptions.regionIds.includes(articleObj.regionId)) {
|
|
681
|
+
return false;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
// 2. price 范围过滤
|
|
685
|
+
if (searchOptions?.priceRange) {
|
|
686
|
+
const price = parseFloat(articleObj.price || '0');
|
|
687
|
+
if (searchOptions.priceRange.min !== undefined && price < searchOptions.priceRange.min) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
if (searchOptions.priceRange.max !== undefined && price > searchOptions.priceRange.max) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
// 3. propertyArea 范围过滤
|
|
695
|
+
if (searchOptions?.propertyAreaRange) {
|
|
696
|
+
const propertyArea = parseFloat(articleObj.propertyArea || '0');
|
|
697
|
+
if (searchOptions.propertyAreaRange.min !== undefined && propertyArea < searchOptions.propertyAreaRange.min) {
|
|
698
|
+
return false;
|
|
699
|
+
}
|
|
700
|
+
if (searchOptions.propertyAreaRange.max !== undefined && propertyArea > searchOptions.propertyAreaRange.max) {
|
|
701
|
+
return false;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
// 4. plotArea 范围过滤
|
|
705
|
+
if (searchOptions?.plotAreaRange) {
|
|
706
|
+
const plotArea = parseFloat(articleObj.plotArea || '0');
|
|
707
|
+
if (searchOptions.plotAreaRange.min !== undefined && plotArea < searchOptions.plotAreaRange.min) {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
if (searchOptions.plotAreaRange.max !== undefined && plotArea > searchOptions.plotAreaRange.max) {
|
|
711
|
+
return false;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
// 5. tagIds 过滤
|
|
715
|
+
if (searchOptions?.tagIds && searchOptions.tagIds.length > 0) {
|
|
716
|
+
if (!articleObj.tagIds || articleObj.tagIds.length === 0) {
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
if (searchOptions.requireAllTags) {
|
|
720
|
+
// 要求包含所有指定的 tagIds
|
|
721
|
+
const hasAllTags = searchOptions.tagIds.every(tagId => articleObj.tagIds.includes(tagId));
|
|
722
|
+
if (!hasAllTags) {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
// 包含任意一个指定的 tagId 即可
|
|
728
|
+
const hasAnyTag = searchOptions.tagIds.some(tagId => articleObj.tagIds.includes(tagId));
|
|
729
|
+
if (!hasAnyTag) {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
return true;
|
|
735
|
+
});
|
|
736
|
+
const filteredTotal = filteredArticleIds.length;
|
|
737
|
+
if (filteredTotal === 0) {
|
|
738
|
+
return {
|
|
739
|
+
articles: [],
|
|
740
|
+
total: categoryData.articleIds.length,
|
|
741
|
+
page: searchOptions?.page || 1,
|
|
742
|
+
limit: searchOptions?.limit || 10,
|
|
743
|
+
filteredTotal: 0
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
// 应用分页
|
|
747
|
+
const page = searchOptions?.page || 1;
|
|
748
|
+
const limit = searchOptions?.limit || 10;
|
|
749
|
+
const offset = (page - 1) * limit;
|
|
750
|
+
const paginatedArticleIds = filteredArticleIds.slice(offset, offset + limit);
|
|
751
|
+
// 获取文章详情
|
|
752
|
+
const articles = await Promise.all(paginatedArticleIds.map(articleObj => this.getArticle_all(articleObj.articleId)));
|
|
753
|
+
// 应用状态过滤
|
|
754
|
+
let finalArticles = articles;
|
|
755
|
+
if (searchOptions?.status) {
|
|
756
|
+
finalArticles = articles.filter(article => article.status === searchOptions.status);
|
|
757
|
+
}
|
|
758
|
+
return {
|
|
759
|
+
articles: finalArticles,
|
|
760
|
+
total: categoryData.articleIds.length, // 原始总数
|
|
761
|
+
page,
|
|
762
|
+
limit,
|
|
763
|
+
filteredTotal // 过滤后的总数
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* 1.2.1 根据平台ID获取文章列表(平台用户都可以使用)
|
|
768
|
+
*/
|
|
769
|
+
async getArticlesByplatform_all(platformId, options) {
|
|
770
|
+
// 从大型分类静态文件获取该分类的文章ID列表
|
|
771
|
+
const categoryData = await this.client.request(`/platform-advertise/platform-${platformId}.json`);
|
|
772
|
+
if (!categoryData || !categoryData.articleIds || categoryData.articleIds.length === 0) {
|
|
773
|
+
return {
|
|
774
|
+
articles: [],
|
|
775
|
+
total: 0,
|
|
776
|
+
page: options?.page || 1,
|
|
777
|
+
limit: options?.limit || 10
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
// 应用分页
|
|
781
|
+
const page = options?.page || 1;
|
|
782
|
+
const limit = options?.limit || 10;
|
|
783
|
+
const offset = (page - 1) * limit;
|
|
784
|
+
const paginatedArticleIds = categoryData.articleIds.slice(offset, offset + limit);
|
|
647
785
|
// 获取文章详情
|
|
648
786
|
const articles = await Promise.all(paginatedArticleIds.map(articleId => this.getArticle_all(articleId)));
|
|
649
787
|
// 应用状态过滤
|
|
@@ -3077,6 +3215,9 @@ class GT6SDK {
|
|
|
3077
3215
|
async getArticlesByCategory_all(categoryId, options) {
|
|
3078
3216
|
return this.articles.getArticlesByCategory_all(categoryId, options);
|
|
3079
3217
|
}
|
|
3218
|
+
async getArticlesByplatform_all(platformId, options) {
|
|
3219
|
+
return this.articles.getArticlesByplatform_all(platformId, options);
|
|
3220
|
+
}
|
|
3080
3221
|
/**
|
|
3081
3222
|
* 4.2. 便捷方法:获取文章分类列表
|
|
3082
3223
|
*/
|