Files
msh-system/.cursor/plans/egfr_fix_and_video_gen_9021ff8f.plan.md

5.9 KiB
Raw Permalink Blame History

name, overview, todos, isProject
name overview todos isProject
eGFR fix and video gen Fix the eGFR field not appearing in calculator results due to a Lombok/Jackson serialization mismatch, and ensure the check-in page correctly calls the KieAI API to generate sora videos when the toggle is enabled.
id content status
fix-egfr-serialization Add @JsonProperty("eGFR") to HealthData.eGFR field in NutritionCalculateResponse.java to fix JSON serialization mismatch completed
id content status
fix-nframes-hardcode Fix n_frames hardcoded value in ToolSora2ServiceImpl.java to use the request input value instead of always "15" completed
id content status
verify-checkin-video-flow Verify and fix the end-to-end video generation flow from checkin-publish.vue through KieAI API, ensuring taskId is properly stored in UserSign completed
id content status
improve-video-error-handling Improve error handling and user feedback in checkin-publish.vue for video generation failures completed
false

Fix eGFR Display and Check-in Video Generation

Issue 1: eGFR Not Showing in Calculator Results

Root Cause

The field private String eGFR in HealthData uses Lombok @Data, which generates the getter getEGFR(). Jackson follows Java Beans naming convention: when the first two characters after stripping "get" are both uppercase ("EG"), the property name stays as-is: "EGFR". The frontend expects data.healthData.eGFR but receives data.healthData.EGFR, resulting in undefined and displaying --.

sequenceDiagram
    participant FE as Frontend
    participant BE as Backend
    FE->>BE: GET /tool/calculator/result/{id}
    BE->>BE: buildResponse() sets healthData.setEGFR(...)
    BE-->>FE: JSON: {"healthData":{"EGFR":"7.9",...}}
    FE->>FE: healthData.eGFR is undefined
    FE->>FE: Displays "--"

Fix

Add @JsonProperty("eGFR") annotation to the eGFR field in NutritionCalculateResponse.java (line 55):

@JsonProperty("eGFR")
@ApiModelProperty(value = "eGFR数值ml/min/1.73m²)", example = "7.9")
private String eGFR;

This forces Jackson to use the exact field name "eGFR" in JSON output, matching the frontend's expectation.


Issue 2: Check-in Page Video Generation

Current State

The implementation already exists in checkin-publish.vue (lines 590-627). It calls api.createImageToVideoTask() / api.createTextToVideoTask() from models-api.js which hit the backend KieAIController.java endpoints at /api/front/kieai/image-to-video and /api/front/kieai/text-to-video.

Auth is not required (kieai endpoints are excluded from the interceptor in WebConfig.java line 98).

sequenceDiagram
    participant User
    participant CheckinPage as checkin-publish.vue
    participant ModelsAPI as models-api.js
    participant Backend as KieAIController
    participant Sora2 as ToolSora2ServiceImpl
    participant KieAI as KieAI API

    User->>CheckinPage: Toggle "生成打卡视频" ON, click 发布
    CheckinPage->>ModelsAPI: createImageToVideoTask({imageUrl, prompt, uid})
    ModelsAPI->>Backend: POST /api/front/kieai/image-to-video
    Backend->>Sora2: createImageToVideoTask(...)
    Sora2->>KieAI: Upload image to KieAI
    Sora2->>KieAI: POST /api/v1/jobs/createTask (sora-2-image-to-video)
    KieAI-->>Sora2: {taskId: "..."}
    Sora2->>Sora2: Save Article record with taskId
    Sora2-->>Backend: taskId
    Backend-->>ModelsAPI: CommonResult{code:200, data: taskId}
    ModelsAPI-->>CheckinPage: response
    CheckinPage->>CheckinPage: submitCheckin({...taskId...})

Issues to Fix

**a) Request parameter format bug in models-api.js**

The createImageToVideoTask function sends image_urls as [params.imageUrl] (single URL in array). However, the Sora2Request.Input.image_urls field is String[] -- this should work for deserialization, but the request body also sets uid as a potential number (from vuex). The Sora2Request.uid is String type. Jackson auto-coerces number -> String, so this is fine. No code change needed here.

b) n_frames hardcoded in backend

The backend ToolSora2ServiceImpl.java hardcodes input.put("n_frames", "15") at lines 44 and 109, ignoring the value sent by the frontend (5). For check-in videos, a shorter duration (5 frames ~ 5 seconds) is more appropriate. Change to use the value from the request input.

c) Video task result not linked to check-in in backend

Currently the video task creates an Article record but has no direct link to the UserSign (check-in) record. The frontend passes taskId in the submitCheckin request, but this linkage should be verified in the backend ToolCheckinServiceImpl to properly store and retrieve the video for the check-in.

d) Error handling improvement in frontend

The current error handling silently fails. Improve feedback to the user when video generation fails.

Changes

  • ToolSora2ServiceImpl.java: Use the n_frames value from the request input instead of hardcoding "15". Both createTextToVideoTask (line 44) and createImageToVideoTask (line 109) need this fix.
  • checkin-publish.vue: Improve video generation error handling and ensure proper prompt construction for nutritional video content.
  • Verify backend checkin service stores the taskId from the video task in the UserSign record correctly.