|
@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -60,9 +61,28 @@ public class AssessmentReportController {
|
|
|
@Operation(summary = "获取用户已生成的测评方案列表")
|
|
@Operation(summary = "获取用户已生成的测评方案列表")
|
|
|
@PostMapping("/plans/list")
|
|
@PostMapping("/plans/list")
|
|
|
public Result<List<TaskPlanInstance>> getMyPlans(
|
|
public Result<List<TaskPlanInstance>> getMyPlans(
|
|
|
- @RequestParam("familyId") Long familyId,
|
|
|
|
|
- @RequestParam(value = "childId", required = false) Long childId) {
|
|
|
|
|
|
|
+ @RequestParam(value = "familyId", required = false) Long familyId,
|
|
|
|
|
+ @RequestParam(value = "childId", required = false) Long childId,
|
|
|
|
|
+ @RequestBody(required = false) Map<String, Object> body,
|
|
|
|
|
+ HttpServletRequest request) {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 参数兼容:优先查询参数,其次 JSON body,最后回退 JWT 注入的 familyId
|
|
|
|
|
+ if (familyId == null && body != null && body.get("familyId") != null) {
|
|
|
|
|
+ familyId = ((Number) body.get("familyId")).longValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (childId == null && body != null && body.get("childId") != null) {
|
|
|
|
|
+ childId = ((Number) body.get("childId")).longValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (familyId == null) {
|
|
|
|
|
+ Object attr = request.getAttribute("familyId");
|
|
|
|
|
+ if (attr instanceof Number) {
|
|
|
|
|
+ familyId = ((Number) attr).longValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (familyId == null) {
|
|
|
|
|
+ return Result.error("缺少familyId参数且无法从登录态获取家庭信息");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 如果传了 childId,只查该孩子的方案;否则查整个家庭的方案
|
|
// 如果传了 childId,只查该孩子的方案;否则查整个家庭的方案
|
|
|
List<TaskPlanInstance> plans;
|
|
List<TaskPlanInstance> plans;
|
|
|
if (childId != null) {
|
|
if (childId != null) {
|