Browse Source

add new

master
panda 7 months ago
parent
commit
7de12a052e
  1. 2
      internal/models.py
  2. 4
      routers/commentmanage.py

2
internal/models.py

@ -140,7 +140,7 @@ class Comment(BaseModel):
commentname:Annotated[str,Field( commentname:Annotated[str,Field(
title="评论用户", title="评论用户",
description="评论用户不允许为空" description="评论用户不允许为空"
)]
)]=None
email:Annotated[str,Field( email:Annotated[str,Field(
title="评论用户邮箱", title="评论用户邮箱",
description="评论用户邮箱不允许为空" description="评论用户邮箱不允许为空"

4
routers/commentmanage.py

@ -11,9 +11,9 @@ router = APIRouter(
# 新增 # 新增
@router.post("/add") @router.post("/add")
@limiter.limit("10/minute")
@limiter.limit("1/minute")
async def comment_add(request: Request,comment:Comment): 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) insert_value=(comment.parent_id,comment.blog_id,comment.commentname,comment.email,comment.commenturl,comment.commentcontent)
execute_query(insert_query,insert_value) execute_query(insert_query,insert_value)
return response_success(data=comment,message="comment create success") return response_success(data=comment,message="comment create success")

Loading…
Cancel
Save