添加一些注释

This commit is contained in:
2026-09-23 12:23:41 +08:00
parent fc522c14c3
commit 8b26d3b239
2 changed files with 3 additions and 0 deletions
+1
View File
@@ -15,6 +15,7 @@ def add_tea(tea: NewTeaRequest=Depends(),db=Depends(get_db)):
if not r:
raise HTTPException(status_code=500,detail='添加失败!')
return TeaResponse(totals=1,data=tea.model_dump())
@tea_api.get('/tea',response_model=TeaResponse,summary='查询老师',description='任意选择输入的信息数量,不输入则查询全部老师')
def get_tea(t:TeaRequest=Depends(),db=Depends(get_db)): #开启会话窗口
r = get_tea_dao(t.model_dump(),db=db)
+2
View File
@@ -14,7 +14,9 @@ def add_tea_dao(t,db):
if existing:
for key,value in t.items():
if hasattr(existing,key) and value is not None and value != '':
#hasattr(existing,key)统计有没有key,返回值是True或False
setattr(existing,key,value)
#将value的值赋值到existing的key中,配合循环,让所有输入的信息都覆盖原信息
existing.is_delete = False
db.commit()
return '恢复修改成功'