|
@@ -270,16 +270,28 @@ public class HealthReportController {
|
|
|
Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
|
|
Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
|
|
|
if (memberId != null) {
|
|
if (memberId != null) {
|
|
|
List<HealthReport> reports = healthReportService.getUserReports(memberId);
|
|
List<HealthReport> reports = healthReportService.getUserReports(memberId);
|
|
|
- return Result.success(reports);
|
|
|
|
|
|
|
+ // 小程序健康页仅展示最近 3 条,后台只返回 3 条,避免前端截断与多余数据传输
|
|
|
|
|
+ return Result.success(limitLatest(reports, 3));
|
|
|
}
|
|
}
|
|
|
// 未指定 memberId 时,回退到家庭报告列表
|
|
// 未指定 memberId 时,回退到家庭报告列表
|
|
|
if (familyId != null) {
|
|
if (familyId != null) {
|
|
|
List<HealthReport> reports = healthReportService.getFamilyReports(familyId);
|
|
List<HealthReport> reports = healthReportService.getFamilyReports(familyId);
|
|
|
- return Result.success(reports);
|
|
|
|
|
|
|
+ // 同上,仅返回最近 3 条
|
|
|
|
|
+ return Result.success(limitLatest(reports, 3));
|
|
|
}
|
|
}
|
|
|
return Result.error("memberId不能为空");
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 截取列表前 N 条(列表已按报告日期倒序,取最近 N 条)
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<HealthReport> limitLatest(List<HealthReport> reports, int max) {
|
|
|
|
|
+ if (reports == null || reports.size() <= max) {
|
|
|
|
|
+ return reports;
|
|
|
|
|
+ }
|
|
|
|
|
+ return new ArrayList<>(reports.subList(0, max));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Operation(summary = "获取全家健康报告列表(方案页选择用)")
|
|
@Operation(summary = "获取全家健康报告列表(方案页选择用)")
|
|
|
@PostMapping("/reports/family")
|
|
@PostMapping("/reports/family")
|
|
|
public Result<List<HealthReport>> listFamilyReports(
|
|
public Result<List<HealthReport>> listFamilyReports(
|