Explorar o código

增加审核状态 psot请求格式

AnlaAnla hai 2 semanas
pai
achega
5250fc99d4
Modificáronse 2 ficheiros con 9 adicións e 4 borrados
  1. 3 2
      app/api/cards.py
  2. 6 2
      app/utils/scheme.py

+ 3 - 2
app/api/cards.py

@@ -10,7 +10,7 @@ from app.core.logger import get_logger
 from app.core.database_loader import get_db_connection
 from app.core.database_loader import get_db_connection
 from app.utils.scheme import (
 from app.utils.scheme import (
     CardDetailResponse, CardListDetailResponse, CardType, SortBy,
     CardDetailResponse, CardListDetailResponse, CardType, SortBy,
-    SortOrder, CardListResponseWrapper, CardListWithTotal
+    SortOrder, CardListResponseWrapper, CardListWithTotal, ReviewUpdate
 )
 )
 from app.crud import crud_card
 from app.crud import crud_card
 
 
@@ -220,7 +220,7 @@ def delete_card(id: int, db_conn: PooledMySQLConnection = db_dependency):
 @router.put("/review_state/{id}", status_code=200, summary="修改卡牌的审核状态")
 @router.put("/review_state/{id}", status_code=200, summary="修改卡牌的审核状态")
 def update_review_state(
 def update_review_state(
         id: int,
         id: int,
-        review_state: int = Query(..., ge=1, le=4, description="审核状态 (1待复检, 2已复检, 3审核未通过, 4审核通过)"),
+        data: ReviewUpdate,
         db_conn: PooledMySQLConnection = db_dependency
         db_conn: PooledMySQLConnection = db_dependency
 ):
 ):
     """
     """
@@ -232,6 +232,7 @@ def update_review_state(
     - 3: 审核未通过
     - 3: 审核未通过
     - 4: 审核通过
     - 4: 审核通过
     """
     """
+    review_state = data.review_state
     try:
     try:
         with db_conn.cursor() as cursor:
         with db_conn.cursor() as cursor:
             # 更新指定 card_id 的 review_state 字段
             # 更新指定 card_id 的 review_state 字段

+ 6 - 2
app/utils/scheme.py

@@ -2,7 +2,7 @@ import json
 from datetime import datetime
 from datetime import datetime
 from pathlib import Path
 from pathlib import Path
 from typing import Optional, Dict, Any, List
 from typing import Optional, Dict, Any, List
-from pydantic import BaseModel, field_validator
+from pydantic import BaseModel, field_validator, Field
 from enum import Enum
 from enum import Enum
 
 
 
 
@@ -166,4 +166,8 @@ class CardListWithTotal(BaseModel):
 
 
 
 
 class CardListResponseWrapper(BaseModel):
 class CardListResponseWrapper(BaseModel):
-    data: CardListWithTotal
+    data: CardListWithTotal
+
+
+class ReviewUpdate(BaseModel):
+    review_state: int = Field(..., ge=1, le=4, description="审核状态 (1待复检, 2已复检, 3审核未通过, 4审核通过)")