|
@@ -1,5 +1,5 @@
|
|
|
import xml.etree.ElementTree as ET
|
|
import xml.etree.ElementTree as ET
|
|
|
-from typing import Union
|
|
|
|
|
|
|
+from typing import Union, Annotated
|
|
|
from fastapi import FastAPI, HTTPException, status, Depends
|
|
from fastapi import FastAPI, HTTPException, status, Depends
|
|
|
import os
|
|
import os
|
|
|
import uuid
|
|
import uuid
|
|
@@ -29,7 +29,7 @@ from inmemory import InMemoryBackend
|
|
|
from fastapi_cache.decorator import cache
|
|
from fastapi_cache.decorator import cache
|
|
|
from contextlib import asynccontextmanager
|
|
from contextlib import asynccontextmanager
|
|
|
from fastapi import WebSocket, WebSocketDisconnect
|
|
from fastapi import WebSocket, WebSocketDisconnect
|
|
|
-from fastapi import UploadFile
|
|
|
|
|
|
|
+from fastapi import UploadFile, File, Form
|
|
|
from collections.abc import AsyncIterator
|
|
from collections.abc import AsyncIterator
|
|
|
|
|
|
|
|
from fastapi_login import LoginManager
|
|
from fastapi_login import LoginManager
|
|
@@ -213,33 +213,33 @@ async def read_qtxm2(info: InfoWithID, user=Depends(manager)):
|
|
|
return raw2
|
|
return raw2
|
|
|
|
|
|
|
|
@app.post("/zygczgj/")
|
|
@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)
|
|
return await db.getZygczgj(client, info.name, info.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/zanliejine2/")
|
|
@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)
|
|
return await db.getZlje(client, info.name, info.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/jirigong2/")
|
|
@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)
|
|
return await db.getJrg(client, info.name, info.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/zongchengbaofuwufei2/")
|
|
@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)
|
|
return await db.getZcbfwf(client, info.name, info.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/fabaorengongyingcailiao2/")
|
|
@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)
|
|
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/")
|
|
@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)
|
|
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)
|
|
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/")
|
|
@app.post("/zjcs/")
|
|
@@ -322,7 +310,7 @@ async def read_files2(user=Depends(manager)):
|
|
|
return result
|
|
return result
|
|
|
|
|
|
|
|
@app.post("/deleteFile/")
|
|
@app.post("/deleteFile/")
|
|
|
-async def delete(r: Info):
|
|
|
|
|
|
|
+async def delete(r: Info, user=Depends(manager)):
|
|
|
result = await db.delete_files(client, r.name)
|
|
result = await db.delete_files(client, r.name)
|
|
|
return result
|
|
return result
|
|
|
|
|
|
|
@@ -555,7 +543,7 @@ async def read_qufei(r: Info, user=Depends(manager)):
|
|
|
return await db.getQufei(client, r.name)
|
|
return await db.getQufei(client, r.name)
|
|
|
|
|
|
|
|
@app.post("/jiagongcai/")
|
|
@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)
|
|
return await db.getJiagongcai(client, r.name)
|
|
|
|
|
|
|
|
@app.get("/dexilie/{value}/{id}")
|
|
@app.get("/dexilie/{value}/{id}")
|
|
@@ -917,7 +905,7 @@ async def read_singledexilie(zhuanye: int, debh: str, mc: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/save/")
|
|
@app.post("/save/")
|
|
|
-async def save(r: Info):
|
|
|
|
|
|
|
+async def save(r: Info, user=Depends(manager)):
|
|
|
data = json.loads(r.name)
|
|
data = json.loads(r.name)
|
|
|
##print(data)
|
|
##print(data)
|
|
|
|
|
|
|
@@ -930,27 +918,27 @@ async def statistics(r: Info, user=Depends(manager)):
|
|
|
return await db.statistics(client, r.name)
|
|
return await db.statistics(client, r.name)
|
|
|
|
|
|
|
|
@app.post("/zujia/")
|
|
@app.post("/zujia/")
|
|
|
-async def zujia(r: Info):
|
|
|
|
|
|
|
+async def zujia(r: Info, user=Depends(manager)):
|
|
|
|
|
|
|
|
##print(data)
|
|
##print(data)
|
|
|
return await db.zujia(client, r.name)
|
|
return await db.zujia(client, r.name)
|
|
|
|
|
|
|
|
@app.post("/tuijian/")
|
|
@app.post("/tuijian/")
|
|
|
-async def tuijian(r: Info):
|
|
|
|
|
|
|
+async def tuijian(r: Info, user=Depends(manager)):
|
|
|
|
|
|
|
|
##print(data)
|
|
##print(data)
|
|
|
return await db.tuijian(chroma_client, r.name)
|
|
return await db.tuijian(chroma_client, r.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/frequency/")
|
|
@app.post("/frequency/")
|
|
|
-async def frequency(r: InfoWithID):
|
|
|
|
|
|
|
+async def frequency(r: InfoWithID, user=Depends(manager)):
|
|
|
|
|
|
|
|
##print(data)
|
|
##print(data)
|
|
|
return await db.frequency(client, r.name, r.id)
|
|
return await db.frequency(client, r.name, r.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/savedjcs/")
|
|
@app.post("/savedjcs/")
|
|
|
-async def savedjcs(r: Info):
|
|
|
|
|
|
|
+async def savedjcs(r: Info, user=Depends(manager)):
|
|
|
data = json.loads(r.name)
|
|
data = json.loads(r.name)
|
|
|
##print(data)
|
|
##print(data)
|
|
|
|
|
|
|
@@ -958,7 +946,7 @@ async def savedjcs(r: Info):
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/applyFL/")
|
|
@app.post("/applyFL/")
|
|
|
-async def applyFL(r: InfoWithID):
|
|
|
|
|
|
|
+async def applyFL(r: InfoWithID, user=Depends(manager)):
|
|
|
data = json.loads(r.name)
|
|
data = json.loads(r.name)
|
|
|
##print(data)
|
|
##print(data)
|
|
|
|
|
|
|
@@ -966,7 +954,7 @@ async def applyFL(r: InfoWithID):
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/tiaojia/")
|
|
@app.post("/tiaojia/")
|
|
|
-async def tiaojia(r: Tiaojia):
|
|
|
|
|
|
|
+async def tiaojia(r: Tiaojia, user=Depends(manager)):
|
|
|
##return []
|
|
##return []
|
|
|
glf = r.glf
|
|
glf = r.glf
|
|
|
lr = r.lr
|
|
lr = r.lr
|
|
@@ -983,14 +971,16 @@ async def searchde(r: SearchDe):
|
|
|
return await db.searchde(client, r.zhuanye, r.text)
|
|
return await db.searchde(client, r.zhuanye, r.text)
|
|
|
|
|
|
|
|
@app.post("/updatezjcs/")
|
|
@app.post("/updatezjcs/")
|
|
|
-async def updatezjcs(r: UpdateZjcs):
|
|
|
|
|
|
|
+async def updatezjcs(r: UpdateZjcs, user=Depends(manager)):
|
|
|
##return []
|
|
##return []
|
|
|
|
|
|
|
|
return await db.updatezjcs(client, r.biao_id, r.bh, r.mc, r.fl)
|
|
return await db.updatezjcs(client, r.biao_id, r.bh, r.mc, r.fl)
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.post("/upload/")
|
|
@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"):
|
|
if file.filename.endswith('13jz') or file.filename.endswith("13jt"):
|
|
|
content = await file.read()
|
|
content = await file.read()
|
|
|
string = content.decode('utf-8')
|
|
string = content.decode('utf-8')
|
|
@@ -1025,7 +1015,8 @@ async def upload(file: UploadFile):
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.get("/download/{item_id}")
|
|
@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())
|
|
tmp = str(uuid.uuid4())
|
|
|
file_path = "export/contacts.xml.b"
|
|
file_path = "export/contacts.xml.b"
|
|
|
# Create the root element
|
|
# Create the root element
|