mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: import Sample SQL
This commit is contained in:
@@ -16,6 +16,7 @@ from apps.data_training.curd.data_training import page_data_training, create_tra
|
||||
from apps.data_training.models.data_training_model import DataTrainingInfo
|
||||
from common.core.config import settings
|
||||
from common.core.deps import SessionDep, CurrentUser, Trans
|
||||
from common.core.file import FileRequest
|
||||
from common.utils.data_format import DataFormat
|
||||
|
||||
router = APIRouter(tags=["DataTraining"], prefix="/system/data-training")
|
||||
@@ -214,11 +215,12 @@ async def upload_excel(trans: Trans, current_user: CurrentUser, file: UploadFile
|
||||
return await asyncio.to_thread(inner)
|
||||
|
||||
|
||||
@router.get("/download-fail-info/{filename}")
|
||||
async def download_excel(filename: str, trans: Trans):
|
||||
@router.post("/download-fail-info")
|
||||
async def download_excel(req: FileRequest):
|
||||
"""
|
||||
根据文件路径下载 Excel 文件
|
||||
"""
|
||||
filename = req.file
|
||||
file_path = os.path.join(path, filename)
|
||||
|
||||
# 检查文件是否存在
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from pydantic import BaseModel
|
||||
|
||||
class FileRequest(BaseModel):
|
||||
file: str
|
||||
@@ -16,8 +16,12 @@ export const trainingApi = {
|
||||
requestOptions: { customError: true },
|
||||
}),
|
||||
downloadError: (path: any) =>
|
||||
request.get(`/system/data-training/download-fail-info/${path}`, {
|
||||
responseType: 'blob',
|
||||
requestOptions: { customError: true },
|
||||
}),
|
||||
request.post(
|
||||
`/system/data-training/download-fail-info`,
|
||||
{ file: path },
|
||||
{
|
||||
responseType: 'blob',
|
||||
requestOptions: { customError: true },
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ const onSuccess = (response: any) => {
|
||||
})
|
||||
const link = document.createElement('a')
|
||||
link.href = URL.createObjectURL(blob)
|
||||
link.download = `${t('training.data_training')}_error.xlsx`
|
||||
link.download = response.data.error_excel_filename
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
|
||||
Reference in New Issue
Block a user