|
|
@ -19,6 +19,7 @@ import com.youlai.boot.admin.service.ContentAuditConfigService; |
|
|
import com.youlai.boot.admin.service.ContentAuditService; |
|
|
import com.youlai.boot.admin.service.ContentAuditService; |
|
|
import com.youlai.boot.admin.service.ContentAuditTaskService; |
|
|
import com.youlai.boot.admin.service.ContentAuditTaskService; |
|
|
import com.youlai.boot.common.exception.MsgException; |
|
|
import com.youlai.boot.common.exception.MsgException; |
|
|
|
|
|
import com.youlai.boot.common.util.CursorEncryptUtil; |
|
|
import com.youlai.boot.common.util.FileUtils; |
|
|
import com.youlai.boot.common.util.FileUtils; |
|
|
import com.youlai.boot.common.util.JavaVCUtils; |
|
|
import com.youlai.boot.common.util.JavaVCUtils; |
|
|
import com.youlai.boot.common.util.RandomNumberUtils; |
|
|
import com.youlai.boot.common.util.RandomNumberUtils; |
|
|
@ -791,7 +792,7 @@ public class UserPostServiceImpl extends ServiceImpl<MiniUserPostMapper, MiniUse |
|
|
int fetchSize = pageSize * 3; |
|
|
int fetchSize = pageSize * 3; |
|
|
|
|
|
|
|
|
// 1. 从DB取原始数据(仅按id降序,不含可见性过滤)
|
|
|
// 1. 从DB取原始数据(仅按id降序,不含可见性过滤)
|
|
|
List<UserPostVO> rawList = baseMapper.getWaterfall(query.getCursor(), fetchSize, userId); |
|
|
List<UserPostVO> rawList = baseMapper.getWaterfall(CursorEncryptUtil.decode(query.getCursor()), fetchSize, userId); |
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(rawList)) { |
|
|
if (CollUtil.isEmpty(rawList)) { |
|
|
return WaterfallResult.of(Collections.emptyList(), null, true); |
|
|
return WaterfallResult.of(Collections.emptyList(), null, true); |
|
|
@ -811,17 +812,14 @@ public class UserPostServiceImpl extends ServiceImpl<MiniUserPostMapper, MiniUse |
|
|
// 4. 截取 pageSize 条作为本页结果
|
|
|
// 4. 截取 pageSize 条作为本页结果
|
|
|
List<UserPostVO> resultList = afterVisibility.stream().limit(pageSize).toList(); |
|
|
List<UserPostVO> resultList = afterVisibility.stream().limit(pageSize).toList(); |
|
|
|
|
|
|
|
|
// 5. 游标逻辑:
|
|
|
// 5. 游标逻辑
|
|
|
// - 过滤后还有 ≥ pageSize 条 → 用最后一条的ID作为下页游标
|
|
|
Long nextCursorId = null; |
|
|
// - 过滤后不够,但DB原始数据是满的 → 用resultList最后一条ID(给被过滤帖子二次曝光机会)
|
|
|
|
|
|
// - 否则最后一页
|
|
|
|
|
|
Long nextCursor = null; |
|
|
|
|
|
boolean isLastPage = true; |
|
|
boolean isLastPage = true; |
|
|
if (resultList.size() >= pageSize) { |
|
|
if (resultList.size() >= pageSize) { |
|
|
nextCursor = resultList.get(pageSize - 1).getId(); |
|
|
nextCursorId = resultList.get(pageSize - 1).getId(); |
|
|
isLastPage = false; |
|
|
isLastPage = false; |
|
|
} else if (hasMore) { |
|
|
} else if (hasMore) { |
|
|
nextCursor = CollUtil.isNotEmpty(resultList) |
|
|
nextCursorId = CollUtil.isNotEmpty(resultList) |
|
|
? resultList.get(resultList.size() - 1).getId() |
|
|
? resultList.get(resultList.size() - 1).getId() |
|
|
: rawList.get(rawList.size() - 1).getId(); |
|
|
: rawList.get(rawList.size() - 1).getId(); |
|
|
isLastPage = false; |
|
|
isLastPage = false; |
|
|
@ -836,7 +834,7 @@ public class UserPostServiceImpl extends ServiceImpl<MiniUserPostMapper, MiniUse |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return WaterfallResult.of(resultList, nextCursor, isLastPage); |
|
|
return WaterfallResult.of(resultList, CursorEncryptUtil.encode(nextCursorId), isLastPage); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private String getDefaultCoverHost() { |
|
|
private String getDefaultCoverHost() { |
|
|
|