Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions backend/apps/datasource/api/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
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
Expand Down Expand Up @@ -72,7 +72,8 @@ def inner():

@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"
))
Expand All @@ -95,7 +96,8 @@ def inner():
@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"
))
Expand All @@ -109,7 +111,8 @@ def inner():
@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"
Expand Down Expand Up @@ -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:
Expand Down