refactor(app): 观看历史统一分页契约并移除 limit
This commit is contained in:
1 parent
7b694938c6
commit
c5468a669b
5 files changed
+19
-34
No files matched your search
+2
-9
@@ -42,7 +42,6 @@ import java.util.Objects;
|
||||
public class WatchProgressService {
|
||||
|
||||
private static final long FINISH_THRESHOLD_MS = 1000L;
|
||||
private static final int DEFAULT_PAGE_SIZE = 20;
|
||||
private static final int MAX_PAGE_SIZE = 100;
|
||||
|
||||
private final WatchProgressMapper progressMapper;
|
||||
@@ -116,13 +115,7 @@ public class WatchProgressService {
|
||||
return progress == null ? null : toResp(progress);
|
||||
}
|
||||
|
||||
/** 最近观看列表("我的-观看记录")。 */
|
||||
public List<ProgressRespVO> recent(Long userId, int limit) {
|
||||
int safeLimit = limit <= 0 || limit > MAX_PAGE_SIZE ? DEFAULT_PAGE_SIZE : limit;
|
||||
return recentPage(userId, 1, safeLimit).getList();
|
||||
}
|
||||
|
||||
/** 分页查询最近观看,按更新时间与 dramaId 稳定倒序。 */
|
||||
/** 分页查询最近观看,按更新时间倒序并以 id 兜底保证稳定。 */
|
||||
public PageResult<ProgressRespVO> recentPage(Long userId, int pageIndex, int pageSize) {
|
||||
int safeIndex = Math.max(pageIndex, 1);
|
||||
int safeSize = Math.min(Math.max(pageSize, 1), MAX_PAGE_SIZE);
|
||||
@@ -131,7 +124,7 @@ public class WatchProgressService {
|
||||
Wrappers.<WatchProgress>lambdaQuery()
|
||||
.eq(WatchProgress::getUserId, userId)
|
||||
.orderByDesc(WatchProgress::getUpdatedAt)
|
||||
.orderByDesc(WatchProgress::getDramaId));
|
||||
.orderByDesc(WatchProgress::getId));
|
||||
return new PageResult<>(result.getTotal(), enrichDisplay(result.getRecords()));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user