|
|
@@ -235,13 +235,15 @@ def update_review_state(
|
|
|
review_state = data.review_state
|
|
|
try:
|
|
|
with db_conn.cursor() as cursor:
|
|
|
+
|
|
|
+ cursor.execute(f"SELECT 1 FROM {settings.DB_CARD_TABLE_NAME} WHERE id = %s", (id,))
|
|
|
+ if not cursor.fetchone():
|
|
|
+ raise HTTPException(status_code=404, detail=f"ID为 {id} 的卡牌未找到。")
|
|
|
+
|
|
|
# 更新指定 card_id 的 review_state 字段
|
|
|
query_update = f"UPDATE {settings.DB_CARD_TABLE_NAME} SET review_state = %s WHERE id = %s"
|
|
|
cursor.execute(query_update, (review_state, id))
|
|
|
|
|
|
- if cursor.rowcount == 0:
|
|
|
- raise HTTPException(status_code=404, detail=f"ID为 {id} 的卡牌未找到。")
|
|
|
-
|
|
|
db_conn.commit()
|
|
|
logger.info(f"卡牌 ID {id} 的审核状态已成功修改为 {review_state}。")
|
|
|
|