feat: 复习 Feed 随机取样改用主键区间并固定 actuator 清单

This commit is contained in:
2026-10-09 15:51:50 +08:00
parent cb450b6f47
commit 251a46887c
8 changed files with 262 additions and 6 deletions
@@ -0,0 +1,26 @@
package com.guo.learningprogresstracker.dto;
import lombok.Data;
/**
* 主键区间的聚合结果(复习-03)。
* <p>随机取样需要知道 id 的跨度,才能用「随机起点 + 顺序取窗口」替代 {@code ORDER BY RAND()}。
* 单列聚合可用 {@code selectObjs},这里需要 MIN 与 MAX 两列,因此用显式结果类 + 自定义 SQL。</p>
*/
@Data
public class IdRange {
private Integer minId;
private Integer maxId;
/** 区间内是否存在记录 */
public boolean isEmpty() {
return minId == null || maxId == null;
}
/** 区间宽度(含两端);空区间返回 0 */
public long span() {
return isEmpty() ? 0L : (long) maxId - minId + 1L;
}
}