Skip to content

Commit aa0b319

Browse files
perf: API Optimization for Multi-Domain Validation in Embedded Advanced Assistants
1 parent 282d94f commit aa0b319

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

backend/apps/system/crud/assistant.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
import re
23
import urllib
34
from typing import Optional
45

@@ -142,15 +143,20 @@ def get_ds_from_api(self):
142143
raise Exception(f"Failed to get datasource list from {endpoint}, error: {result_json.get('message')}")
143144
else:
144145
raise Exception(f"Failed to get datasource list from {endpoint}, status code: {res.status_code}")
145-
146+
147+
def get_first_element(self, text: str):
148+
parts = re.split(r'[,;]', text.strip())
149+
first_domain = parts[0].strip()
150+
return first_domain
151+
146152
def get_complete_endpoint(self, endpoint: str) -> str | None:
147153
if endpoint.startswith("http://") or endpoint.startswith("https://"):
148154
return endpoint
149155
domain_text = self.assistant.domain
150156
if not domain_text:
151157
return None
152-
if ',' in domain_text:
153-
return (self.request_origin.strip('/') if self.request_origin else domain_text.split(',')[0].strip('/')) + endpoint
158+
if ',' in domain_text or ';' in domain_text:
159+
return (self.request_origin.strip('/') if self.request_origin else self.get_first_element(domain_text).strip('/')) + endpoint
154160
else:
155161
return f"{domain_text}{endpoint}"
156162

frontend/src/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@
764764
"ou_placeholder": "Example: ou=users,dc=example,dc=com",
765765
"user_filter": "User Filter",
766766
"user_filter_placeholder": "Example: uid",
767-
"ldap_field_mapping_placeholder": "Example: {\"account\": \"ldapAccount\", \"name\": \"ldapName\", \"email\": \"mail\"}"
767+
"ldap_field_mapping_placeholder": "Example: {\"account\": \"ldapAccount\", \"name\": \"ldapName\", \"email\": \"mail\"}",
768+
"be_turned_on": "Once the test connection is confirmed to be effective, it can be enabled"
768769
},
769770
"login": {
770771
"default_login": "Default",

frontend/src/i18n/ko-KR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@
764764
"ou_placeholder": "예: ou=users,dc=example,dc=com",
765765
"user_filter": "사용자 필터",
766766
"user_filter_placeholder": "예: uid",
767-
"ldap_field_mapping_placeholder": "예: {\"account\": \"ldapAccount\", \"name\": \"ldapName\", \"email\": \"mail\"}"
767+
"ldap_field_mapping_placeholder": "예: {\"account\": \"ldapAccount\", \"name\": \"ldapName\", \"email\": \"mail\"}",
768+
"be_turned_on": "테스트 연결이 유효한 것으로 확인되면 활성화할 수 있습니다"
768769
},
769770
"login": {
770771
"default_login": "기본값",

frontend/src/i18n/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,8 @@
764764
"ou_placeholder": "例如:ou=users,dc=example,dc=com",
765765
"user_filter": "用户过滤器",
766766
"user_filter_placeholder": "例如:uid",
767-
"ldap_field_mapping_placeholder": "例如:{'{'}\"account\": \"ldapAccount\", \"name\": \"ldapName\", \"email\": \"mail\"{'}'}"
767+
"ldap_field_mapping_placeholder": "例如:{'{'}\"account\": \"ldapAccount\", \"name\": \"ldapName\", \"email\": \"mail\"{'}'}",
768+
"be_turned_on": "测试连接有效后,可开启"
768769
},
769770
"login": {
770771
"default_login": "默认",

frontend/src/views/system/authentication/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
v-if="!item.valid"
2424
class="box-item"
2525
effect="dark"
26-
:content="t('system.be_turned_on')"
26+
:content="t('authentication.be_turned_on')"
2727
placement="top"
2828
>
2929
<el-switch

0 commit comments

Comments
 (0)