|
|
@@ -68,6 +68,7 @@ import java.util.UUID;
|
|
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
+import com.etotem.cfc.util.ParamUtils;
|
|
|
|
|
|
/**
|
|
|
* 健康检测报告接口 — 体检报告/菌群检测报告的录入与查询
|
|
|
@@ -164,8 +165,7 @@ public class HealthReportController {
|
|
|
return Result.noFamily("请先创建或加入家庭");
|
|
|
}
|
|
|
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -245,8 +245,7 @@ public class HealthReportController {
|
|
|
if (familyId == null) {
|
|
|
return Result.noFamily("请先创建或加入家庭");
|
|
|
}
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -263,8 +262,7 @@ public class HealthReportController {
|
|
|
@RequestBody Map<String, Object> params,
|
|
|
@RequestAttribute(value = "currentMemberId", required = false) Long currentMemberId,
|
|
|
@RequestAttribute(value = "familyId", required = false) Long familyId) {
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : currentMemberId;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
|
|
|
if (memberId != null) {
|
|
|
List<HealthReport> reports = healthReportService.getUserReports(memberId);
|
|
|
return Result.success(reports);
|
|
|
@@ -308,8 +306,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/indicator/list")
|
|
|
public Result<List<HealthIndicator>> listIndicators(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
if (reportId == null) {
|
|
|
return Result.error("reportId不能为空");
|
|
|
}
|
|
|
@@ -325,8 +322,7 @@ public class HealthReportController {
|
|
|
public Result<List<HealthIndicator>> getBodyDetail(
|
|
|
@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;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"), currentMemberId);
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -341,8 +337,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/detail")
|
|
|
public Result<Map<String, Object>> getReportDetail(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
if (reportId == null) {
|
|
|
return Result.error("reportId不能为空");
|
|
|
}
|
|
|
@@ -359,13 +354,11 @@ public class HealthReportController {
|
|
|
@RequestBody Map<String, Object> params,
|
|
|
@RequestAttribute("userId") Long userId) {
|
|
|
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
if (reportId == null) {
|
|
|
return Result.error("reportId不能为空");
|
|
|
}
|
|
|
- Long subjectId = params.get("subjectId") != null
|
|
|
- ? Long.valueOf(params.get("subjectId").toString()) : null;
|
|
|
+ Long subjectId = ParamUtils.getLong(params.get("subjectId"));
|
|
|
if (subjectId == null) {
|
|
|
return Result.error("subjectId不能为空");
|
|
|
}
|
|
|
@@ -550,8 +543,7 @@ public class HealthReportController {
|
|
|
@RequestAttribute(value = "familyId", required = false) Long familyId,
|
|
|
@RequestAttribute("userId") Long userId) {
|
|
|
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
if (draftId == null) {
|
|
|
return Result.error("draftId不能为空");
|
|
|
}
|
|
|
@@ -876,15 +868,14 @@ public class HealthReportController {
|
|
|
@RequestAttribute("userId") Long userId) {
|
|
|
|
|
|
if ("tongue".equals(type)) {
|
|
|
- Long recordId = Long.valueOf(params.get("recordId").toString());
|
|
|
+ Long recordId = ParamUtils.getLong(params.get("recordId"));
|
|
|
@SuppressWarnings("unchecked")
|
|
|
List<Map<String, Object>> indicators = (List<Map<String, Object>>) params.getOrDefault("indicators", null);
|
|
|
Map<String, Object> result = tongueDiagnosisService.confirm(recordId, indicators);
|
|
|
return Result.success(result);
|
|
|
}
|
|
|
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
if (draftId == null) {
|
|
|
return Result.error("draftId不能为空");
|
|
|
}
|
|
|
@@ -909,8 +900,7 @@ public class HealthReportController {
|
|
|
payload = objectMapper.readValue(payloadJson, ParsedReportPayload.Payload.class);
|
|
|
}
|
|
|
|
|
|
- Long subjectId = params.get("subjectId") != null
|
|
|
- ? Long.valueOf(params.get("subjectId").toString()) : null;
|
|
|
+ Long subjectId = ParamUtils.getLong(params.get("subjectId"));
|
|
|
|
|
|
HealthReport report = buildReportFromPayload(draft, payload, subjectId);
|
|
|
|
|
|
@@ -998,13 +988,12 @@ public class HealthReportController {
|
|
|
@RequestAttribute("userId") Long userId) {
|
|
|
|
|
|
if ("tongue".equals(type)) {
|
|
|
- Long recordId = Long.valueOf(params.get("recordId").toString());
|
|
|
+ Long recordId = ParamUtils.getLong(params.get("recordId"));
|
|
|
tongueDiagnosisService.discard(recordId);
|
|
|
return Result.success("草稿已删除");
|
|
|
}
|
|
|
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
if (draftId == null) {
|
|
|
return Result.error("draftId不能为空");
|
|
|
}
|
|
|
@@ -1028,10 +1017,8 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/bind")
|
|
|
public Result<String> bindReport(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
- Long subjectId = params.get("subjectId") != null
|
|
|
- ? Long.valueOf(params.get("subjectId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
+ Long subjectId = ParamUtils.getLong(params.get("subjectId"));
|
|
|
if (reportId == null || subjectId == null) {
|
|
|
return Result.error("reportId和subjectId不能为空");
|
|
|
}
|
|
|
@@ -1060,10 +1047,8 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/permission/add")
|
|
|
public Result<String> addReportPermission(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
- Long targetUserId = params.get("userId") != null
|
|
|
- ? Long.valueOf(params.get("userId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
+ Long targetUserId = ParamUtils.getLong(params.get("userId"));
|
|
|
if (reportId == null || targetUserId == null) {
|
|
|
return Result.error("reportId和userId不能为空");
|
|
|
}
|
|
|
@@ -1078,10 +1063,8 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/permission/remove")
|
|
|
public Result<String> removeReportPermission(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
- Long targetUserId = params.get("userId") != null
|
|
|
- ? Long.valueOf(params.get("userId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
+ Long targetUserId = ParamUtils.getLong(params.get("userId"));
|
|
|
if (reportId == null || targetUserId == null) {
|
|
|
return Result.error("reportId和userId不能为空");
|
|
|
}
|
|
|
@@ -1096,10 +1079,8 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/permission/check")
|
|
|
public Result<Boolean> checkReportPermission(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
- Long targetUserId = params.get("userId") != null
|
|
|
- ? Long.valueOf(params.get("userId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
+ Long targetUserId = ParamUtils.getLong(params.get("userId"));
|
|
|
if (reportId == null || targetUserId == null) {
|
|
|
return Result.error("reportId和userId不能为空");
|
|
|
}
|
|
|
@@ -1111,13 +1092,11 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/deficiency")
|
|
|
public Result<List<NutritionDeficiencyRecord>> getDeficiencyAnalysis(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"));
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
List<NutritionDeficiencyRecord> records = nutritionDeficiencyService.analyzeDeficiency(memberId, reportId);
|
|
|
return Result.success(records);
|
|
|
}
|
|
|
@@ -1126,8 +1105,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/profile")
|
|
|
public Result<Map<String, Object>> getNutritionProfile(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"));
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -1139,8 +1117,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/deficiency-summary")
|
|
|
public Result<Map<String, Object>> getDeficiencySummary(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"));
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -1152,8 +1129,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/nutrition/trend")
|
|
|
public Result<Map<String, Object>> getReportTrendData(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"));
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -1165,8 +1141,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/analysis")
|
|
|
public Result<Map<String, Object>> getHealthAnalysis(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long memberId = params.get("memberId") != null
|
|
|
- ? Long.valueOf(params.get("memberId").toString()) : null;
|
|
|
+ Long memberId = ParamUtils.getLong(params.get("memberId"));
|
|
|
if (memberId == null) {
|
|
|
return Result.error("memberId不能为空");
|
|
|
}
|
|
|
@@ -1203,7 +1178,7 @@ public class HealthReportController {
|
|
|
@Operation(summary = "删除指标-营养素映射")
|
|
|
@PostMapping("/nutrition/mapping/delete")
|
|
|
public Result<?> deleteMapping(@RequestBody Map<String, Object> params) {
|
|
|
- Long id = params.get("id") != null ? Long.valueOf(params.get("id").toString()) : null;
|
|
|
+ Long id = ParamUtils.getLong(params.get("id"));
|
|
|
if (id == null) {
|
|
|
return Result.error("id不能为空");
|
|
|
}
|
|
|
@@ -1214,8 +1189,7 @@ public class HealthReportController {
|
|
|
@Operation(summary = "获取食材推荐列表")
|
|
|
@PostMapping("/foods")
|
|
|
public Result<List<Food>> listFoods(@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
if (reportId == null) {
|
|
|
return Result.error("reportId不能为空");
|
|
|
}
|
|
|
@@ -1230,8 +1204,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/archive")
|
|
|
public Result<String> archiveReport(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
if (reportId == null) {
|
|
|
return Result.error("reportId不能为空");
|
|
|
}
|
|
|
@@ -1239,6 +1212,23 @@ public class HealthReportController {
|
|
|
return Result.success("报告已归档");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量归档报告(软删除)— 管理端选中删除
|
|
|
+ */
|
|
|
+ @Operation(summary = "批量归档健康报告(软删除)")
|
|
|
+ @PostMapping("/report/archive-batch")
|
|
|
+ public Result<String> archiveReportsBatch(
|
|
|
+ @RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute(value = "role", required = false) String role) {
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<Long> reportIds = (List<Long>) params.get("reportIds");
|
|
|
+ if (reportIds == null || reportIds.isEmpty()) {
|
|
|
+ return Result.error("reportIds不能为空");
|
|
|
+ }
|
|
|
+ int archived = healthReportService.archiveReportsBatch(reportIds);
|
|
|
+ return Result.success("已归档 " + archived + " 份报告");
|
|
|
+ }
|
|
|
+
|
|
|
@Operation(summary = "获取家庭成员食材推荐(含完整营养数据)")
|
|
|
@PostMapping("/foods/by-family")
|
|
|
public Result<Map<String, Object>> getFoodsByFamily(@RequestAttribute(value = "familyId", required = false) Long familyId) {
|
|
|
@@ -1321,8 +1311,7 @@ public class HealthReportController {
|
|
|
String gender = (String) params.get("gender");
|
|
|
Object ageObj = params.get("age");
|
|
|
Integer age = ageObj != null ? Integer.parseInt(ageObj.toString()) : null;
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
|
|
|
if (name == null || name.trim().isEmpty()) {
|
|
|
return Result.error("姓名不能为空");
|
|
|
@@ -1380,10 +1369,8 @@ public class HealthReportController {
|
|
|
public Result<Map<String, Object>> auditConfirm(
|
|
|
@RequestBody Map<String, Object> params,
|
|
|
@RequestAttribute("userId") Long auditorId) {
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
- Long subjectId = params.get("subjectId") != null
|
|
|
- ? Long.valueOf(params.get("subjectId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
+ Long subjectId = ParamUtils.getLong(params.get("subjectId"));
|
|
|
|
|
|
if (draftId == null) {
|
|
|
return Result.error("draftId不能为空");
|
|
|
@@ -1405,8 +1392,7 @@ public class HealthReportController {
|
|
|
@PostMapping("/report/audit/discard")
|
|
|
public Result<String> auditDiscard(
|
|
|
@RequestBody Map<String, Object> params) {
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
|
|
|
if (draftId == null) {
|
|
|
return Result.error("draftId不能为空");
|
|
|
@@ -1844,8 +1830,7 @@ public class HealthReportController {
|
|
|
if (contentObj == null || contentObj.toString().trim().isEmpty()) {
|
|
|
return Result.error("反馈内容不能为空");
|
|
|
}
|
|
|
- Long reportId = params.get("reportId") != null
|
|
|
- ? Long.valueOf(params.get("reportId").toString()) : null;
|
|
|
+ Long reportId = ParamUtils.getLong(params.get("reportId"));
|
|
|
String type = params.get("type") != null ? params.get("type").toString() : "其他";
|
|
|
String content = contentObj.toString().trim();
|
|
|
if (content.length() > 500) {
|
|
|
@@ -1973,10 +1958,8 @@ public class HealthReportController {
|
|
|
return Result.error("无权限");
|
|
|
}
|
|
|
|
|
|
- Long draftId = params.get("draftId") != null
|
|
|
- ? Long.valueOf(params.get("draftId").toString()) : null;
|
|
|
- Long subjectId = params.get("subjectId") != null
|
|
|
- ? Long.valueOf(params.get("subjectId").toString()) : null;
|
|
|
+ Long draftId = ParamUtils.getLong(params.get("draftId"));
|
|
|
+ Long subjectId = ParamUtils.getLong(params.get("subjectId"));
|
|
|
|
|
|
if (draftId == null) {
|
|
|
return Result.error("draftId不能为空");
|