fix: 新增配方去重+编辑者权限+共享去重统一
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Failing after 52s

新增去重:
- 新增配方保存前检查公共库和个人配方同名
- 完全相同提示已有,内容不同显示差异可改名

编辑者权限:
- editor可编辑所有公共配方(前端+后端)
- editor不能编辑精油价目(已有)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 20:12:10 +00:00
parent 480e843316
commit 6d2620eb6a
3 changed files with 35 additions and 7 deletions

View File

@@ -824,9 +824,7 @@ def _check_recipe_permission(conn, recipe_id, user):
row = conn.execute("SELECT owner_id, name FROM recipes WHERE id = ?", (recipe_id,)).fetchone()
if not row:
raise HTTPException(404, "Recipe not found")
if user["role"] in ("admin", "senior_editor"):
return row
if user["role"] in ("editor",) and row["owner_id"] == user.get("id"):
if user["role"] in ("admin", "senior_editor", "editor"):
return row
raise HTTPException(403, "权限不足")