diff --git a/AI/Text2Sql/Model/biModel.py b/AI/Text2Sql/Model/biModel.py index 4cf652b9..2b326ff8 100644 --- a/AI/Text2Sql/Model/biModel.py +++ b/AI/Text2Sql/Model/biModel.py @@ -69,6 +69,7 @@ def update_question_by_id(db: PostgreSQLUtil, question_id: str, **kwargs): print(f"更新失败: {e}") return False + # 根据 问题id 查询 sql def get_question_by_id(db, question_id: str): select_sql = """ @@ -76,3 +77,32 @@ def get_question_by_id(db, question_id: str): """ _data = db.execute_query(select_sql, (question_id,)) return _data + + +# 保存系统推荐 +def model_set_system_recommend(db, question_id: str, flag: str): + sql = f""" + UPDATE t_bi_question + SET is_system =%s WHERE id = %s + """ + # 执行更新 + try: + db.execute_query(sql, int(flag), question_id) + return True + except Exception as e: + print(f"更新失败: {e}") + return False + +# 设置用户收藏 +def model_set_user_collect(db, question_id: str, flag: str): + sql = f""" + UPDATE t_bi_question + SET is_collect =%s WHERE id = %s + """ + # 执行更新 + try: + db.execute_query(sql, int(flag), question_id) + return True + except Exception as e: + print(f"更新失败: {e}") + return False \ No newline at end of file diff --git a/AI/Text2Sql/__pycache__/app.cpython-310.pyc b/AI/Text2Sql/__pycache__/app.cpython-310.pyc index 3b103c15..77c190e6 100644 Binary files a/AI/Text2Sql/__pycache__/app.cpython-310.pyc and b/AI/Text2Sql/__pycache__/app.cpython-310.pyc differ diff --git a/AI/Text2Sql/app.py b/AI/Text2Sql/app.py index 77e3e1b0..81dc3718 100644 --- a/AI/Text2Sql/app.py +++ b/AI/Text2Sql/app.py @@ -67,7 +67,6 @@ def get_excel(question_id: str = Form(...), question_str: str = Form(...), db: P # http://10.10.21.20:8000/questions/get_docx_stream?question_id_get=af15d834-e7f5-46b4-a0f6-15f1f888f443 - @app.api_route("/questions/get_docx_stream", methods=["POST", "GET"]) async def get_docx_stream( question_id: str = Form(None, description="问题ID(POST请求)"), # POST 请求参数 @@ -155,11 +154,14 @@ async def get_docx_stream( media_type="text/plain; charset=utf-8", # 明确指定字符编码为 UTF-8 headers={ "Cache-Control": "no-cache", # 禁用缓存 - "Content-Type": "text/plain; charset=utf-8", # 设置内容类型和字符编码 + "Content-Type": "text/event-stream; charset=utf-8", # 设置内容类型和字符编码 + "Transfer-Encoding": "chunked", + "Connection": "keep-alive", "X-Accel-Buffering": "no", # 禁用 Nginx 缓冲(如果使用 Nginx) } ) + # 返回生成的Word文件下载地址 # http://10.10.21.20:8000/questions/get_docx_file?question_id_get=af15d834-e7f5-46b4-a0f6-15f1f888f443 @app.api_route("/questions/get_docx_file", methods=["POST", "GET"]) @@ -183,6 +185,21 @@ async def get_docx_file( return {"success": True, "message": "Word文件生成成功", "download_url": f"{docx_file_name}"} +# 设置问题为系统推荐问题 ,0:取消,1:设置 +@app.post("/questions/set_system_recommend") +def set_system_recommend(question_id: str = Form(...), flag: str = Form(...), db: PostgreSQLUtil = Depends(get_db)): + model_set_system_recommend(db, question_id, flag) + # 提示保存成功 + return {"success": True, "message": "保存成功"} + +# 设置问题为用户收藏问题 ,0:取消,1:设置 +@app.post("/questions/set_user_collect") +def set_user_collect(question_id: str = Form(...), flag: str = Form(...), db: PostgreSQLUtil = Depends(get_db)): + model_set_user_collect(db, question_id, flag) + # 提示保存成功 + return {"success": True, "message": "保存成功"} + + # 确保直接运行脚本时启动 FastAPI 应用 if __name__ == "__main__": uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True) diff --git a/AI/Text2Sql/static/28b67191-7440-4775-bad0-bf7ff9ecd74d.docx b/AI/Text2Sql/static/28b67191-7440-4775-bad0-bf7ff9ecd74d.docx new file mode 100644 index 00000000..b46c7372 Binary files /dev/null and b/AI/Text2Sql/static/28b67191-7440-4775-bad0-bf7ff9ecd74d.docx differ diff --git a/AI/Text2Sql/static/2acc1542-5301-4004-817b-45ac77920db8.docx b/AI/Text2Sql/static/2acc1542-5301-4004-817b-45ac77920db8.docx new file mode 100644 index 00000000..083edf21 Binary files /dev/null and b/AI/Text2Sql/static/2acc1542-5301-4004-817b-45ac77920db8.docx differ diff --git a/AI/Text2Sql/static/41b0aabb-6ef0-4e6a-b041-e2ad5427b2bb.docx b/AI/Text2Sql/static/41b0aabb-6ef0-4e6a-b041-e2ad5427b2bb.docx new file mode 100644 index 00000000..65b29c96 Binary files /dev/null and b/AI/Text2Sql/static/41b0aabb-6ef0-4e6a-b041-e2ad5427b2bb.docx differ diff --git a/AI/Text2Sql/static/47c4e4db-e623-4dca-813d-40cc8e5cc737.docx b/AI/Text2Sql/static/47c4e4db-e623-4dca-813d-40cc8e5cc737.docx new file mode 100644 index 00000000..b7bfc437 Binary files /dev/null and b/AI/Text2Sql/static/47c4e4db-e623-4dca-813d-40cc8e5cc737.docx differ diff --git a/AI/Text2Sql/static/4b16e16f-c1e9-471d-98c5-36aa22cd3841.docx b/AI/Text2Sql/static/4b16e16f-c1e9-471d-98c5-36aa22cd3841.docx new file mode 100644 index 00000000..330fd88f Binary files /dev/null and b/AI/Text2Sql/static/4b16e16f-c1e9-471d-98c5-36aa22cd3841.docx differ diff --git a/AI/Text2Sql/static/4bbbd966-fd86-4ee2-a234-87766bb9c466.docx b/AI/Text2Sql/static/4bbbd966-fd86-4ee2-a234-87766bb9c466.docx new file mode 100644 index 00000000..ba9736a3 Binary files /dev/null and b/AI/Text2Sql/static/4bbbd966-fd86-4ee2-a234-87766bb9c466.docx differ diff --git a/AI/Text2Sql/static/5318a73b-dcf9-4619-911c-4663270cb7dd.docx b/AI/Text2Sql/static/5318a73b-dcf9-4619-911c-4663270cb7dd.docx new file mode 100644 index 00000000..19af5945 Binary files /dev/null and b/AI/Text2Sql/static/5318a73b-dcf9-4619-911c-4663270cb7dd.docx differ diff --git a/AI/Text2Sql/static/8aeae647-b0fd-48ea-9d13-6aba8c97156c.docx b/AI/Text2Sql/static/8aeae647-b0fd-48ea-9d13-6aba8c97156c.docx new file mode 100644 index 00000000..e87cb386 Binary files /dev/null and b/AI/Text2Sql/static/8aeae647-b0fd-48ea-9d13-6aba8c97156c.docx differ diff --git a/AI/Text2Sql/static/99ecaed2-2881-4434-84fb-ed010bdcae4b.docx b/AI/Text2Sql/static/99ecaed2-2881-4434-84fb-ed010bdcae4b.docx new file mode 100644 index 00000000..628968c6 Binary files /dev/null and b/AI/Text2Sql/static/99ecaed2-2881-4434-84fb-ed010bdcae4b.docx differ diff --git a/AI/Text2Sql/static/e1a9749e-a5fb-4bec-97b6-2ed3b533df49.docx b/AI/Text2Sql/static/e1a9749e-a5fb-4bec-97b6-2ed3b533df49.docx new file mode 100644 index 00000000..78927aad Binary files /dev/null and b/AI/Text2Sql/static/e1a9749e-a5fb-4bec-97b6-2ed3b533df49.docx differ diff --git a/AI/Text2Sql/static/fb3eea17-5820-4bff-9c23-217bbb87f350.docx b/AI/Text2Sql/static/fb3eea17-5820-4bff-9c23-217bbb87f350.docx new file mode 100644 index 00000000..ec75753c Binary files /dev/null and b/AI/Text2Sql/static/fb3eea17-5820-4bff-9c23-217bbb87f350.docx differ