diff --git a/internal/models.py b/internal/models.py index 7cccda9..59732c1 100644 --- a/internal/models.py +++ b/internal/models.py @@ -140,7 +140,7 @@ class Comment(BaseModel): commentname:Annotated[str,Field( title="评论用户", description="评论用户不允许为空" - )] + )]=None email:Annotated[str,Field( title="评论用户邮箱", description="评论用户邮箱不允许为空" diff --git a/routers/commentmanage.py b/routers/commentmanage.py index 9db782c..eac1b0e 100644 --- a/routers/commentmanage.py +++ b/routers/commentmanage.py @@ -11,9 +11,9 @@ router = APIRouter( # 新增 @router.post("/add") -@limiter.limit("10/minute") +@limiter.limit("1/minute") async def comment_add(request: Request,comment:Comment): - insert_query="""INSERT INTO comments (parent_id,blog_id,commentname,email,commenturl,commentcontent) VALUES(%s,%s,%s,%s)""" + insert_query="""INSERT INTO comments (parent_id,blog_id,commentname,email,commenturl,commentcontent) VALUES(%s,%s,%s,%s,%s,%s)""" insert_value=(comment.parent_id,comment.blog_id,comment.commentname,comment.email,comment.commenturl,comment.commentcontent) execute_query(insert_query,insert_value) return response_success(data=comment,message="comment create success")