瀏覽代碼

finish_login

Xiaopeng Zhang 3 月之前
父節點
當前提交
3741e87f5f
共有 1 個文件被更改,包括 23 次插入32 次删除
  1. 23 32
      main.py

+ 23 - 32
main.py

@@ -1,5 +1,5 @@
 import xml.etree.ElementTree as ET
-from typing import Union
+from typing import Union, Annotated
 from fastapi import FastAPI, HTTPException, status, Depends
 import os
 import uuid
@@ -29,7 +29,7 @@ from inmemory import InMemoryBackend
 from fastapi_cache.decorator import cache
 from contextlib import asynccontextmanager
 from fastapi import WebSocket, WebSocketDisconnect
-from fastapi import UploadFile
+from fastapi import UploadFile, File, Form
 from collections.abc import AsyncIterator
 
 from fastapi_login import LoginManager
@@ -213,33 +213,33 @@ async def read_qtxm2(info: InfoWithID, user=Depends(manager)):
     return raw2
 
 @app.post("/zygczgj/")
-async def zygczgj(info: InfoWithID):
+async def zygczgj(info: InfoWithID, user=Depends(manager)):
     return await db.getZygczgj(client, info.name, info.id)
 
 
 
 
 @app.post("/zanliejine2/")
-async def read_zlje2(info: InfoWithID):
+async def read_zlje2(info: InfoWithID, user=Depends(manager)):
     return await db.getZlje(client, info.name, info.id)
 
 
 
 @app.post("/jirigong2/")
-async def read_jrg2(info: InfoWithID):
+async def read_jrg2(info: InfoWithID, user=Depends(manager)):
     return await db.getJrg(client, info.name, info.id)
 
 
 
 @app.post("/zongchengbaofuwufei2/")
-async def read_zcbfwf2(info: InfoWithID):
+async def read_zcbfwf2(info: InfoWithID, user=Depends(manager)):
     return await db.getZcbfwf(client, info.name, info.id)
 
 
 
 
 @app.post("/fabaorengongyingcailiao2/")
-async def read_fbrgycl2(info: InfoWithID):
+async def read_fbrgycl2(info: InfoWithID, user=Depends(manager)):
     return await db.getFbrgycl(client, info.name, info.id)
 
 
@@ -260,16 +260,11 @@ async def read_qdxm2(info: InfoWithID, user=Depends(manager)):
 
 
 @app.post("/qingdanmingxi/")
-async def read_qdmx(item : Item):
+async def read_qdmx(item : Item, user=Depends(manager)):
 
     return await db.getQdmx(client, item.name, item.bh, item.bt)
 
-@app.post("/qingdanrcj/")
-async def read_rcj(item : Rcj):
 
-    if item.bt == "Djcs":
-        return await db.getDjcsQingdanrcj(client, item.name, item.bh, item.bt, item.bm)
-    return await db.getQingdanrcj(client, item.name, item.bh, item.bt, item.bm)
 
 
 
@@ -282,13 +277,6 @@ async def read_tuijian(bm: str):
     return service.getQingdanTuijian("", "", bm)
 
 
-@app.post("/dingercj/")
-async def read_dercj(item : Dercj):
-    if item.bt == "Djcs":
-        return await db.getDjcsDingercj(client, item.name, item.bh, item.bt, item.qdbm, item.debm)
-
-    
-    return await db.getDingercj(client, item.name, item.bh, item.bt, item.qdbm, item.debm)
 
 
 @app.post("/zjcs/")
@@ -322,7 +310,7 @@ async def read_files2(user=Depends(manager)):
     return result
 
 @app.post("/deleteFile/")
-async def delete(r: Info):
+async def delete(r: Info, user=Depends(manager)):
     result = await db.delete_files(client, r.name)
     return result
 
@@ -555,7 +543,7 @@ async def read_qufei(r: Info, user=Depends(manager)):
     return await db.getQufei(client, r.name)
 
 @app.post("/jiagongcai/")
-async def read_jiagongcai(r: Info):
+async def read_jiagongcai(r: Info, user=Depends(manager)):
     return await db.getJiagongcai(client, r.name)
 
 @app.get("/dexilie/{value}/{id}")
@@ -917,7 +905,7 @@ async def read_singledexilie(zhuanye: int, debh: str, mc: str):
 
 
 @app.post("/save/")
-async def save(r: Info):
+async def save(r: Info, user=Depends(manager)):
     data = json.loads(r.name)
     ##print(data)
  
@@ -930,27 +918,27 @@ async def statistics(r: Info, user=Depends(manager)):
     return await db.statistics(client, r.name)
 
 @app.post("/zujia/")
-async def zujia(r: Info):
+async def zujia(r: Info, user=Depends(manager)):
     
     ##print(data)
     return await db.zujia(client, r.name)
 
 @app.post("/tuijian/")
-async def tuijian(r: Info):
+async def tuijian(r: Info, user=Depends(manager)):
     
     ##print(data)
     return await db.tuijian(chroma_client, r.name)
 
 
 @app.post("/frequency/")
-async def frequency(r: InfoWithID):
+async def frequency(r: InfoWithID, user=Depends(manager)):
     
     ##print(data)
     return await db.frequency(client, r.name, r.id)
 
 
 @app.post("/savedjcs/")
-async def savedjcs(r: Info):
+async def savedjcs(r: Info, user=Depends(manager)):
     data = json.loads(r.name)
     ##print(data)
  
@@ -958,7 +946,7 @@ async def savedjcs(r: Info):
 
 
 @app.post("/applyFL/")
-async def applyFL(r: InfoWithID):
+async def applyFL(r: InfoWithID, user=Depends(manager)):
     data = json.loads(r.name)
     ##print(data)
  
@@ -966,7 +954,7 @@ async def applyFL(r: InfoWithID):
 
 
 @app.post("/tiaojia/")
-async def tiaojia(r: Tiaojia):
+async def tiaojia(r: Tiaojia, user=Depends(manager)):
     ##return []
     glf = r.glf
     lr = r.lr
@@ -983,14 +971,16 @@ async def searchde(r: SearchDe):
     return await db.searchde(client, r.zhuanye, r.text)
 
 @app.post("/updatezjcs/")
-async def updatezjcs(r: UpdateZjcs):
+async def updatezjcs(r: UpdateZjcs, user=Depends(manager)):
     ##return []
     
     return await db.updatezjcs(client, r.biao_id, r.bh, r.mc, r.fl)
 
 
 @app.post("/upload/")
-async def upload(file: UploadFile):
+async def upload(file: Annotated[UploadFile, File()], token: Annotated[str, Form()]):
+    user = await manager.get_current_user(token)
+    print(user)
     if file.filename.endswith('13jz') or file.filename.endswith("13jt"):
         content = await file.read()
         string = content.decode('utf-8')
@@ -1025,7 +1015,8 @@ async def upload(file: UploadFile):
         
         
 @app.get("/download/{item_id}")
-async def download_file(item_id):
+async def download_file(item_id, user=Depends(manager)):
+    print(user)
     tmp = str(uuid.uuid4())
     file_path = "export/contacts.xml.b"
     # Create the root element