Compare commits
3
Commits
9e9d7e2606
...
5871afc9aa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5871afc9aa | ||
|
|
af92c45e6a | ||
|
|
f697a8b634 |
@@ -32,6 +32,7 @@ def delete_tea(id:int|None,db=Depends(get_db)):
|
||||
@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)
|
||||
print(t)
|
||||
r = update_tea_dao(id=id, t=t, db=db)
|
||||
if r == 'NOT_FOUND':
|
||||
raise HTTPException(status_code=404, detail='老师不存在')
|
||||
@@ -39,6 +40,7 @@ def update_tea(id: int, tea: NewTeaRequest = Depends(), db=Depends(get_db)):
|
||||
raise HTTPException(status_code=400, detail='没有要更新的内容')
|
||||
if isinstance(r, str) and r.startswith('ERROR'):
|
||||
raise HTTPException(status_code=400, detail=r)
|
||||
#先确认是字符串再调用字符串方法判断是不是以错误开头,是就报错给前端
|
||||
return {'detail': '更新成功'}
|
||||
|
||||
#根据任意信息删除
|
||||
|
||||
@@ -39,7 +39,7 @@ def update_tea_dao(id, t, db):
|
||||
if not obj:
|
||||
return 'NOT_FOUND'
|
||||
for k, v in t.items():
|
||||
if hasattr(obj, k):
|
||||
if hasattr(obj, k) and v is not None and v != '':
|
||||
setattr(obj, k, v)
|
||||
db.commit()
|
||||
return 'OK'
|
||||
|
||||
+1
-1
@@ -1444,7 +1444,7 @@
|
||||
|
||||
<script>
|
||||
// API 基础地址
|
||||
const API_BASE = 'http://localhost:59000';
|
||||
const API_BASE = 'http://localhost:58000';
|
||||
|
||||
// 全局状态
|
||||
let currentPage = 'home';
|
||||
|
||||
@@ -37,9 +37,9 @@ if __name__ == "__main__":
|
||||
seed_test_data()
|
||||
|
||||
import uvicorn
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=59000)
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=58000)
|
||||
"""
|
||||
IPv4 地址 . . . . . . . . . . . . : 192.168.6.40
|
||||
子网掩码 . . . . . . . . . . . . : 255.255.255.0
|
||||
默认网关. . . . . . . . . . . . . : 192.168.6.1
|
||||
"""
|
||||
"""
|
||||
|
||||
@@ -234,7 +234,7 @@ seed_data.py → 新项目的根目录
|
||||
init_test_data.py → 新项目的根目录
|
||||
frontend/ → 新项目的根目录(整个文件夹)
|
||||
|
||||
要改的唯一参数: frontend/index.html 第 306 行
|
||||
要改的唯一参数: frontend/index.html
|
||||
|
||||
const API_BASE = 'http://localhost:59000';
|
||||
改成新项目实际运行的端口即可。
|
||||
|
||||
Reference in New Issue
Block a user