Skip to content

Commit 9dd4b72

Browse files
committed
Merge branch 'main' of https://github.com/dataease/SQLBot
2 parents f94b9ea + 5449db3 commit 9dd4b72

File tree

14 files changed

+83
-35
lines changed

14 files changed

+83
-35
lines changed

backend/apps/db/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def exec_sql(ds: CoreDatasource | AssistantOutDsSchema, sql: str):
253253
with get_session(ds) as session:
254254
with session.execute(text(sql)) as result:
255255
try:
256-
columns = result.keys()._keys
256+
columns = [item.lower() for item in result.keys()._keys]
257257
res = result.fetchall()
258258
result_list = [
259259
{columns[i]: float(value) if isinstance(value, Decimal) else value for i, value in

backend/apps/system/api/login.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from fastapi.security import OAuth2PasswordRequestForm
44
from apps.system.schemas.system_schema import BaseUserDTO
55
from common.core.deps import SessionDep, Trans
6+
from common.utils.crypto import sqlbot_decrypt
67
from ..crud.user import authenticate
78
from common.core.security import create_access_token
89
from datetime import timedelta
@@ -11,12 +12,14 @@
1112
router = APIRouter(tags=["login"], prefix="/login")
1213

1314
@router.post("/access-token")
14-
def local_login(
15+
async def local_login(
1516
session: SessionDep,
1617
trans: Trans,
1718
form_data: Annotated[OAuth2PasswordRequestForm, Depends()]
1819
) -> Token:
19-
user: BaseUserDTO = authenticate(session=session, account=form_data.username, password=form_data.password)
20+
origin_account = await sqlbot_decrypt(form_data.username)
21+
origin_pwd = await sqlbot_decrypt(form_data.password)
22+
user: BaseUserDTO = authenticate(session=session, account=origin_account, password=origin_pwd)
2023
if not user:
2124
raise HTTPException(status_code=400, detail=trans('i18n_login.account_pwd_error'))
2225
if not user.oid or user.oid == 0:

backend/common/utils/crypto.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from sqlbot_xpack.core import sqlbot_decrypt as xpack_sqlbot_decrypt
2+
3+
async def sqlbot_decrypt(text: str) -> str:
4+
return await xpack_sqlbot_decrypt(text)

backend/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ async def lifespan(app: FastAPI):
2929
init_sqlbot_cache()
3030
init_dynamic_cors(app)
3131
SQLBotLogUtil.info("✅ SQLBot 初始化完成")
32+
await sqlbot_xpack.core.clean_xpack_cache()
3233
yield
3334
SQLBotLogUtil.info("SQLBot 应用关闭")
3435

backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies = [
3636
"pyyaml (>=6.0.2,<7.0.0)",
3737
"fastapi-mcp (>=0.3.4,<0.4.0)",
3838
"tabulate>=0.9.0",
39-
"sqlbot-xpack==0.0.3.8",
39+
"sqlbot-xpack==0.0.3.9",
4040
"fastapi-cache2>=0.2.2",
4141
"sqlparse>=0.5.3",
4242
"redis>=6.2.0",

frontend/auto-imports.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ export {}
88
declare global {
99
const ElMessage: typeof import('element-plus-secondary/es')['ElMessage']
1010
const ElMessageBox: typeof import('element-plus-secondary/es')['ElMessageBox']
11+
const LicenseGenerator: any
1112
}

frontend/src/api/login.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
import { request } from '@/utils/request'
2-
32
export const AuthApi = {
4-
login: (credentials: { username: string; password: string }) =>
5-
request.post<{
3+
login: (credentials: { username: string; password: string }) => {
4+
const entryCredentials = {
5+
username: LicenseGenerator.sqlbotEncrypt(credentials.username),
6+
password: LicenseGenerator.sqlbotEncrypt(credentials.password),
7+
}
8+
return request.post<{
69
data: any
710
token: string
8-
}>('/login/access-token', credentials, {
11+
}>('/login/access-token', entryCredentials, {
912
headers: {
1013
'Content-Type': 'application/x-www-form-urlencoded',
1114
},
12-
}),
15+
})
16+
},
1317
logout: () => request.post('/auth/logout'),
1418
info: () => request.get('/user/info'),
1519
}

frontend/src/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"password_reset_successful": "Password reset successful"
3737
},
3838
"dashboard": {
39+
"add_dashboard_name_tips": "Please Input Dashboard Name",
40+
"existing_dashboard": "Existing Dashboard",
3941
"add_success": "Add Success",
4042
"no_data": "No Relevant Content Found",
4143
"new_tab": "New Tab",

frontend/src/i18n/zh-CN.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"or": "或者"
4040
},
4141
"dashboard": {
42+
"add_dashboard_name_tips": "请输入仪表板名称",
43+
"existing_dashboard": "存量仪表板",
4244
"add_success": "添加成功",
4345
"no_data": "没找到相关内容",
4446
"new_tab": "新建Tab",

frontend/src/router/watch.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,10 @@ const loadXpackStatic = () => {
5050
if (document.getElementById('sqlbot_xpack_static')) {
5151
return Promise.resolve()
5252
}
53-
const url = '/xpack_static/license-generator.umd.js'
53+
const url = `/xpack_static/license-generator.umd.js?t=${Date.now()}`
5454
return new Promise((resolve, reject) => {
5555
request
5656
.loadRemoteScript(url, 'sqlbot_xpack_static', () => {
57-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
58-
// @ts-ignore
5957
LicenseGenerator?.init(import.meta.env.VITE_API_BASE_URL).then(() => {
6058
resolve(true)
6159
})

0 commit comments

Comments
 (0)