feat: Support for batch uploading data table notes #557

This commit is contained in:
junjun
2025-12-25 11:52:38 +08:00
committed by Junjun
parent af99f105e2
commit 074e0f12c4
+9 -6
View File
@@ -28,8 +28,8 @@ from ..crud.field import get_fields_by_table_id
from ..crud.table import get_tables_by_ds_id
from ..models.datasource import CoreDatasource, CreateDatasource, TableObj, CoreTable, CoreField, FieldObj, \
TableSchemaResponse, ColumnSchemaResponse, PreviewResponse
from sqlbot_xpack.audit.models.log_model import OperationType, OperationModules
from sqlbot_xpack.audit.schemas.logger_decorator import LogConfig, system_log
from sqlbot_xpack.audit.models.log_model import OperationType, OperationDetails, OperationModules
from sqlbot_xpack.audit.schemas.logger_decorator import system_log, LogConfig
router = APIRouter(tags=["Datasource"], prefix="/datasource")
path = settings.EXCEL_PATH
@@ -72,7 +72,8 @@ async def check_by_id(session: SessionDep, trans: Trans,
@router.post("/add", response_model=CoreDatasource, summary=f"{PLACEHOLDER_PREFIX}ds_add")
@system_log(LogConfig(
operation_type=OperationType.CREATE,
operation_type=OperationType.CREATE_DATASOURCE,
operation_detail=OperationDetails.CREATE_DATASOURCE_DETAILS,
module=OperationModules.DATASOURCE,
result_id_expr="id"
))
@@ -95,7 +96,8 @@ async def choose_tables(session: SessionDep, trans: Trans, tables: List[CoreTabl
@router.post("/update", response_model=CoreDatasource, summary=f"{PLACEHOLDER_PREFIX}ds_update")
@require_permissions(permission=SqlbotPermission(type='ds', keyExpression="ds.id"))
@system_log(LogConfig(
operation_type=OperationType.UPDATE,
operation_type=OperationType.UPDATE_DATASOURCE,
operation_detail=OperationDetails.UPDATE_DATASOURCE_DETAILS,
module=OperationModules.DATASOURCE,
resource_id_expr="ds.id"
))
@@ -109,7 +111,8 @@ async def update(session: SessionDep, trans: Trans, user: CurrentUser, ds: CoreD
@router.post("/delete/{id}/{name}", response_model=None, summary=f"{PLACEHOLDER_PREFIX}ds_delete")
@require_permissions(permission=SqlbotPermission(type='ds', keyExpression="id"))
@system_log(LogConfig(
operation_type=OperationType.DELETE,
operation_type=OperationType.DELETE_DATASOURCE,
operation_detail=OperationDetails.DELETE_DATASOURCE_DETAILS,
module=OperationModules.DATASOURCE,
resource_id_expr="id",
remark_expr="name"
@@ -509,7 +512,7 @@ async def upload_ds_schema(session: SessionDep, id: int = Path(..., description=
for fields in field_sheets:
if len(fields['data']) > 0:
# get table id
table_name = sheet_table_map[fields['sheet_name']]
table_name = sheet_table_map.get(fields['sheet_name'])
table = session.query(CoreTable).filter(
and_(CoreTable.ds_id == id, CoreTable.table_name == table_name)).first()
if table: