diff --git a/backend/main.py b/backend/main.py
index 8308576..6bdf449 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -1659,12 +1659,21 @@ def update_oil_plan(plan_id: int, body: dict, user=Depends(get_current_user)):
if not plan:
conn.close()
raise HTTPException(404, "方案不存在")
- if plan["teacher_id"] != user["id"] and user["role"] != "admin":
+ is_teacher = plan["teacher_id"] == user["id"] or user["role"] == "admin"
+ is_owner = plan["user_id"] == user["id"]
+ if not is_teacher and not is_owner:
conn.close()
raise HTTPException(403, "无权操作")
- if "title" in body:
+ if "health_desc" in body and is_owner:
+ conn.execute("UPDATE oil_plans SET health_desc = ? WHERE id = ?", (body["health_desc"], plan_id))
+ who = user.get("display_name") or user["username"]
+ conn.execute(
+ "INSERT INTO notifications (target_role, title, body, target_user_id) VALUES (?, ?, ?, ?)",
+ ("admin", "📋 方案需求已更新", f"{who} 更新了健康需求:{body['health_desc'][:50]}", plan["teacher_id"])
+ )
+ if "title" in body and is_teacher:
conn.execute("UPDATE oil_plans SET title = ? WHERE id = ?", (body["title"], plan_id))
- if "status" in body:
+ if "status" in body and is_teacher:
old_status = plan["status"]
conn.execute("UPDATE oil_plans SET status = ? WHERE id = ?", (body["status"], plan_id))
if body["status"] == "active" and old_status != "active":
diff --git a/frontend/src/components/UserMenu.vue b/frontend/src/components/UserMenu.vue
index fa74e53..48088e1 100644
--- a/frontend/src/components/UserMenu.vue
+++ b/frontend/src/components/UserMenu.vue
@@ -38,6 +38,8 @@