|
|
@@ -115,12 +115,13 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/create")
|
|
|
public Result<HealthReport> createReport(
|
|
|
@RequestBody Map<String, Object> params,
|
|
|
- @RequestAttribute("userId") Long userId) {
|
|
|
+ @RequestAttribute("userId") Long userId,
|
|
|
+ @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
|
|
|
String reportType = (String) params.get("reportType");
|
|
|
@@ -130,7 +131,7 @@ public class HealthReportController {
|
|
|
|
|
|
// 构建报告主体
|
|
|
HealthReport report = new HealthReport();
|
|
|
- report.setUserId(childId);
|
|
|
+ report.setUserId(memberId);
|
|
|
report.setReportType(reportType);
|
|
|
report.setOverallScore(params.get("overallScore") != null
|
|
|
? Integer.valueOf(params.get("overallScore").toString()) : null);
|
|
|
@@ -192,13 +193,14 @@ public class HealthReportController {
|
|
|
@Operation(summary = "获取最新健康报告")
|
|
|
@PostMapping("/report/latest")
|
|
|
public Result<HealthReport> getLatestReport(
|
|
|
- @RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ @RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- HealthReport report = healthReportService.getLatestReport(childId);
|
|
|
+ HealthReport report = healthReportService.getLatestReport(memberId);
|
|
|
return Result.success(report);
|
|
|
}
|
|
|
|
|
|
@@ -208,13 +210,14 @@ public class HealthReportController {
|
|
|
@Operation(summary = "获取健康报告列表")
|
|
|
@PostMapping("/report/list")
|
|
|
public Result<List<HealthReport>> listReports(
|
|
|
- @RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ @RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- List<HealthReport> reports = healthReportService.getUserReports(childId);
|
|
|
+ List<HealthReport> reports = healthReportService.getUserReports(memberId);
|
|
|
return Result.success(reports);
|
|
|
}
|
|
|
|
|
|
@@ -253,13 +256,14 @@ public class HealthReportController {
|
|
|
@Operation(summary = "获取身体维度数据详情")
|
|
|
@PostMapping("/body/detail")
|
|
|
public Result<List<HealthIndicator>> getBodyDetail(
|
|
|
- @RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ @RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId) {
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- List<HealthIndicator> detail = healthReportService.getBodyDetail(childId);
|
|
|
+ List<HealthIndicator> detail = healthReportService.getBodyDetail(memberId);
|
|
|
return Result.success(detail);
|
|
|
}
|
|
|
|
|
|
@@ -407,14 +411,13 @@ public class HealthReportController {
|
|
|
@RequestParam(value = "type", defaultValue = "auto") String type,
|
|
|
@RequestParam(value = "familyId", required = false) Long familyId,
|
|
|
@RequestParam(value = "memberId", required = false) Long memberId,
|
|
|
- @RequestParam(value = "childId", required = false) Long childId,
|
|
|
@RequestAttribute("userId") Long userId) {
|
|
|
|
|
|
if ("tongue".equals(type)) {
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId is required for tongue diagnosis");
|
|
|
}
|
|
|
- Map<String, Object> result = tongueDiagnosisService.parsePreview(file, memberId, childId);
|
|
|
+ Map<String, Object> result = tongueDiagnosisService.parsePreview(file, memberId);
|
|
|
return Result.success(result);
|
|
|
}
|
|
|
|
|
|
@@ -757,14 +760,14 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/deficiency")
|
|
|
public Result<List<NutritionDeficiencyRecord>> getDeficiencyAnalysis(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
Long reportId = params.get("reportId") != null
|
|
|
? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
- List<NutritionDeficiencyRecord> records = nutritionDeficiencyService.analyzeDeficiency(childId, reportId);
|
|
|
+ List<NutritionDeficiencyRecord> records = nutritionDeficiencyService.analyzeDeficiency(memberId, reportId);
|
|
|
return Result.success(records);
|
|
|
}
|
|
|
|
|
|
@@ -772,12 +775,12 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/profile")
|
|
|
public Result<Map<String, Object>> getNutritionProfile(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- Map<String, Object> profile = childNutritionProfileService.getProfile(childId);
|
|
|
+ Map<String, Object> profile = childNutritionProfileService.getProfile(memberId);
|
|
|
return Result.success(profile);
|
|
|
}
|
|
|
|
|
|
@@ -785,12 +788,12 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/deficiency-summary")
|
|
|
public Result<Map<String, Object>> getDeficiencySummary(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- Map<String, Object> summary = childNutritionProfileService.getDeficiencySummary(childId);
|
|
|
+ Map<String, Object> summary = childNutritionProfileService.getDeficiencySummary(memberId);
|
|
|
return Result.success(summary);
|
|
|
}
|
|
|
|
|
|
@@ -798,12 +801,12 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/trend")
|
|
|
public Result<Map<String, Object>> getReportTrendData(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- Map<String, Object> trend = childNutritionProfileService.getReportTrendData(childId);
|
|
|
+ Map<String, Object> trend = childNutritionProfileService.getReportTrendData(memberId);
|
|
|
return Result.success(trend);
|
|
|
}
|
|
|
|
|
|
@@ -811,13 +814,13 @@ public class HealthReportController {
|
|
|
@PostMapping("/analysis")
|
|
|
public Result<Map<String, Object>> getHealthAnalysis(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long childId = params.get("childId") != null
|
|
|
- ? Long.valueOf(params.get("childId").toString()) : null;
|
|
|
- if (childId == null) {
|
|
|
- return Result.error("childId不能为空");
|
|
|
+ Long memberId = params.get("memberId") != null
|
|
|
+ ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ if (memberId == null) {
|
|
|
+ return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- HealthAnalysisResult analysisResult = healthAnalysisService.analyzeLatestByUser(childId);
|
|
|
- List<NutritionDeficiencyRecord> deficiencyRecords = nutritionDeficiencyService.analyzeDeficiency(childId, null);
|
|
|
+ HealthAnalysisResult analysisResult = healthAnalysisService.analyzeLatestByUser(memberId);
|
|
|
+ List<NutritionDeficiencyRecord> deficiencyRecords = nutritionDeficiencyService.analyzeDeficiency(memberId, null);
|
|
|
|
|
|
Map<String, Object> result = new java.util.HashMap<>();
|
|
|
result.put("analysis", analysisResult);
|