|
|
@@ -108,17 +108,25 @@ public class ArticleService {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Page<Article> p = new Page<>(page, size);
|
|
|
- Page<Article> result = articleMapper.selectPage(p, wrapper);
|
|
|
+ // 先查全量(不含分页),内存中做权限过滤后再手动分页。
|
|
|
+ // 原因:可见性过滤规则含 JSON visible_to,无法下推 SQL;
|
|
|
+ // 若先 selectPage 后过滤,total 会被设为本页过滤后条数(<= size),
|
|
|
+ // 前端 noMore = 已加载数 >= total 恒为真,导致只显示一页、无法加载更多。
|
|
|
+ List<Article> all = articleMapper.selectList(wrapper);
|
|
|
|
|
|
- List<Article> visible = articlePermissionService.filterVisible(
|
|
|
- result.getRecords(), userId, familyId, vendorType);
|
|
|
+ List<Article> visible = articlePermissionService.filterVisible(all, userId, familyId, vendorType);
|
|
|
|
|
|
enrichTotalDurationSeconds(visible);
|
|
|
|
|
|
+ // 手动分页(与 getFeatured 相同模式),total 为过滤后的真实总数
|
|
|
+ int total = visible.size();
|
|
|
+ int fromIndex = Math.min((page - 1) * size, total);
|
|
|
+ int toIndex = Math.min(fromIndex + size, total);
|
|
|
+ List<Article> pageList = visible.subList(fromIndex, toIndex);
|
|
|
+
|
|
|
Page<Article> filtered = new Page<>(page, size);
|
|
|
- filtered.setTotal(visible.size());
|
|
|
- filtered.setRecords(visible);
|
|
|
+ filtered.setTotal(total);
|
|
|
+ filtered.setRecords(new ArrayList<>(pageList));
|
|
|
return filtered;
|
|
|
}
|
|
|
|