修更新的bud

This commit is contained in:
2026-09-23 00:50:59 +08:00
parent 079a7cf351
commit b67e3cd547
3 changed files with 26 additions and 15 deletions
+11 -7
View File
@@ -28,13 +28,17 @@ def delete_tea(id:int|None,db=Depends(get_db)):
raise HTTPException(status_code=500,detail='删除失败!')
return {'detail':'删除成功!'}
@tea_api.put('/tea/{id}',summary='更新老师信息',description='输入更改的信息,可以为空')
def update_tea(id:int,tea:NewTeaRequest,db=Depends(get_db)):
t = tea.model_dump(exclude_unset= True)
r = update_tea_dao(id=id,t=t,db=db)
if not r:
raise HTTPException(status_code=404,detail='老师不存在')
return {'detail':'更新成功'}
@tea_api.put('/tea/{id}', summary='更新老师信息', description='输入更改的信息,可以为空')
def update_tea(id: int, tea: NewTeaRequest = Depends(), db=Depends(get_db)):
t = tea.model_dump(exclude_unset=True)
r = update_tea_dao(id=id, t=t, db=db)
if r == 'NOT_FOUND':
raise HTTPException(status_code=404, detail='老师不存在')
if r == 'NO_CHANGE':
raise HTTPException(status_code=400, detail='没有要更新的内容')
if isinstance(r, str) and r.startswith('ERROR'):
raise HTTPException(status_code=400, detail=r)
return {'detail': '更新成功'}
#根据任意信息删除
@tea_api.delete('/tea',summary='根据任意信息逻辑删除',description='输入任意信息删除')