mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: support export with filter
This commit is contained in:
@@ -76,9 +76,11 @@ async def enable(session: SessionDep, id: int, enabled: bool, trans: Trans):
|
||||
@router.get("/export", summary=f"{PLACEHOLDER_PREFIX}export_dt")
|
||||
@system_log(LogConfig(operation_type=OperationType.EXPORT, module=OperationModules.DATA_TRAINING))
|
||||
async def export_excel(session: SessionDep, trans: Trans, current_user: CurrentUser,
|
||||
question: Optional[str] = Query(None, description="搜索术语(可选)")):
|
||||
question: Optional[str] = Query(None, description="搜索术语(可选)"),
|
||||
ds_list: Optional[list[int]] = Query(None, description="数据集ID集合(可选)"),
|
||||
adv_list: Optional[list[int]] = Query(None, description="高级应用ID集合(可选)")):
|
||||
def inner():
|
||||
_list = get_all_data_training(session, question, oid=current_user.oid)
|
||||
_list = get_all_data_training(session, question, oid=current_user.oid, ds_list=ds_list, adv_list=adv_list)
|
||||
|
||||
data_list = []
|
||||
for obj in _list:
|
||||
|
||||
@@ -154,12 +154,13 @@ def page_data_training(session: SessionDep, current_page: int = 1, page_size: in
|
||||
return current_page, page_size, total_count, total_pages, _list
|
||||
|
||||
|
||||
def get_all_data_training(session: SessionDep, name: Optional[str] = None, oid: Optional[int] = 1):
|
||||
def get_all_data_training(session: SessionDep, name: Optional[str] = None, oid: Optional[int] = 1,
|
||||
ds_list: Optional[list[int]] = None, adv_list: Optional[list[int]] = None):
|
||||
"""
|
||||
获取所有数据训练(不分页)
|
||||
"""
|
||||
stmt, total_count, total_pages, current_page, page_size = build_data_training_query(
|
||||
session, oid, name, False
|
||||
session, oid, name, False, ds_list=ds_list, adv_list=adv_list
|
||||
)
|
||||
_list = execute_data_training_query(session, stmt)
|
||||
|
||||
|
||||
@@ -71,9 +71,11 @@ async def enable(session: SessionDep, id: int, enabled: bool, trans: Trans):
|
||||
@router.get("/export", summary=f"{PLACEHOLDER_PREFIX}export_term")
|
||||
@system_log(LogConfig(operation_type=OperationType.EXPORT, module=OperationModules.TERMINOLOGY))
|
||||
async def export_excel(session: SessionDep, trans: Trans, current_user: CurrentUser,
|
||||
word: Optional[str] = Query(None, description="搜索术语(可选)")):
|
||||
word: Optional[str] = Query(None, description="搜索术语(可选)"),
|
||||
ds_list: Optional[list[int]] = Query(None, description="数据集ID集合(可选)"),
|
||||
adv_list: Optional[list[int]] = Query(None, description="高级应用ID集合(可选)")):
|
||||
def inner():
|
||||
_list = get_all_terminology(session, word, oid=current_user.oid)
|
||||
_list = get_all_terminology(session, word, oid=current_user.oid, ds_list=ds_list, adv_list=adv_list)
|
||||
|
||||
data_list = []
|
||||
for obj in _list:
|
||||
|
||||
@@ -230,12 +230,13 @@ def page_terminology(session: SessionDep, current_page: int = 1, page_size: int
|
||||
return current_page, page_size, total_count, total_pages, _list
|
||||
|
||||
|
||||
def get_all_terminology(session: SessionDep, name: Optional[str] = None, oid: Optional[int] = 1):
|
||||
def get_all_terminology(session: SessionDep, name: Optional[str] = None, oid: Optional[int] = 1,
|
||||
ds_list: Optional[list[int]] = None, adv_list: Optional[list[int]] = None):
|
||||
"""
|
||||
获取所有术语(不分页)
|
||||
"""
|
||||
stmt, total_count, total_pages, current_page, page_size = build_terminology_query(
|
||||
session, oid, name, False
|
||||
session, oid, name, False, ds_list=ds_list, adv_list=adv_list
|
||||
)
|
||||
_list = execute_terminology_query(session, stmt)
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ export const professionalApi = {
|
||||
getOne: (id: any) => request.get(`/system/terminology/${id}`),
|
||||
enable: (id: any, enabled: any) => request.get(`/system/terminology/${id}/enable/${enabled}`),
|
||||
export2Excel: (params: any) =>
|
||||
request.get(`/system/terminology/export`, {
|
||||
params,
|
||||
request.get(`/system/terminology/export${params}`, {
|
||||
responseType: 'blob',
|
||||
requestOptions: { customError: true },
|
||||
}),
|
||||
|
||||
@@ -7,8 +7,7 @@ export const promptApi = {
|
||||
deleteEmbedded: (params: any) => request.delete('/system/custom_prompt', { data: params }),
|
||||
getOne: (id: any) => request.get(`/system/custom_prompt/${id}`),
|
||||
export2Excel: (type: any, params: any) =>
|
||||
request.get(`/system/custom_prompt/${type}/export`, {
|
||||
params,
|
||||
request.post(`/system/custom_prompt/${type}/export`, params, {
|
||||
responseType: 'blob',
|
||||
requestOptions: { customError: true },
|
||||
}),
|
||||
|
||||
@@ -8,8 +8,7 @@ export const trainingApi = {
|
||||
getOne: (id: any) => request.get(`/system/data-training/${id}`),
|
||||
enable: (id: any, enabled: any) => request.get(`/system/data-training/${id}/enable/${enabled}`),
|
||||
export2Excel: (params: any) =>
|
||||
request.get(`/system/data-training/export`, {
|
||||
params,
|
||||
request.get(`/system/data-training/export${params}`, {
|
||||
responseType: 'blob',
|
||||
requestOptions: { customError: true },
|
||||
}),
|
||||
|
||||
@@ -98,7 +98,7 @@ const exportExcel = () => {
|
||||
}).then(() => {
|
||||
searchLoading.value = true
|
||||
professionalApi
|
||||
.export2Excel(keywords.value ? { word: keywords.value } : {})
|
||||
.export2Excel(configParams())
|
||||
.then((res) => {
|
||||
const blob = new Blob([res], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
|
||||
@@ -135,7 +135,7 @@ const exportExcel = () => {
|
||||
}).then(() => {
|
||||
searchLoading.value = true
|
||||
promptApi
|
||||
.export2Excel(currentType.value, keywords.value ? { name: keywords.value } : {})
|
||||
.export2Excel(currentType.value, configParams())
|
||||
.then((res) => {
|
||||
const blob = new Blob([res], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
|
||||
@@ -99,7 +99,7 @@ const exportExcel = () => {
|
||||
}).then(() => {
|
||||
searchLoading.value = true
|
||||
trainingApi
|
||||
.export2Excel(keywords.value ? { question: keywords.value } : {})
|
||||
.export2Excel(configParams())
|
||||
.then((res) => {
|
||||
const blob = new Blob([res], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
|
||||
Reference in New Issue
Block a user