2828from ..crud .table import get_tables_by_ds_id
2929from ..models .datasource import CoreDatasource , CreateDatasource , TableObj , CoreTable , CoreField , FieldObj , \
3030 TableSchemaResponse , ColumnSchemaResponse , PreviewResponse
31- from sqlbot_xpack .audit .models .log_model import OperationType , OperationModules
32- from sqlbot_xpack .audit .schemas .logger_decorator import LogConfig , system_log
31+ from sqlbot_xpack .audit .models .log_model import OperationType , OperationDetails , OperationModules
32+ from sqlbot_xpack .audit .schemas .logger_decorator import system_log , LogConfig
3333
3434router = APIRouter (tags = ["Datasource" ], prefix = "/datasource" )
3535path = settings .EXCEL_PATH
@@ -72,7 +72,8 @@ def inner():
7272
7373@router .post ("/add" , response_model = CoreDatasource , summary = f"{ PLACEHOLDER_PREFIX } ds_add" )
7474@system_log (LogConfig (
75- operation_type = OperationType .CREATE ,
75+ operation_type = OperationType .CREATE_DATASOURCE ,
76+ operation_detail = OperationDetails .CREATE_DATASOURCE_DETAILS ,
7677 module = OperationModules .DATASOURCE ,
7778 result_id_expr = "id"
7879))
@@ -95,7 +96,8 @@ def inner():
9596@router .post ("/update" , response_model = CoreDatasource , summary = f"{ PLACEHOLDER_PREFIX } ds_update" )
9697@require_permissions (permission = SqlbotPermission (type = 'ds' , keyExpression = "ds.id" ))
9798@system_log (LogConfig (
98- operation_type = OperationType .UPDATE ,
99+ operation_type = OperationType .UPDATE_DATASOURCE ,
100+ operation_detail = OperationDetails .UPDATE_DATASOURCE_DETAILS ,
99101 module = OperationModules .DATASOURCE ,
100102 resource_id_expr = "ds.id"
101103))
@@ -109,7 +111,8 @@ def inner():
109111@router .post ("/delete/{id}/{name}" , response_model = None , summary = f"{ PLACEHOLDER_PREFIX } ds_delete" )
110112@require_permissions (permission = SqlbotPermission (type = 'ds' , keyExpression = "id" ))
111113@system_log (LogConfig (
112- operation_type = OperationType .DELETE ,
114+ operation_type = OperationType .DELETE_DATASOURCE ,
115+ operation_detail = OperationDetails .DELETE_DATASOURCE_DETAILS ,
113116 module = OperationModules .DATASOURCE ,
114117 resource_id_expr = "id" ,
115118 remark_expr = "name"
@@ -509,7 +512,7 @@ async def upload_ds_schema(session: SessionDep, id: int = Path(..., description=
509512 for fields in field_sheets :
510513 if len (fields ['data' ]) > 0 :
511514 # get table id
512- table_name = sheet_table_map [ fields ['sheet_name' ]]
515+ table_name = sheet_table_map . get ( fields ['sheet_name' ])
513516 table = session .query (CoreTable ).filter (
514517 and_ (CoreTable .ds_id == id , CoreTable .table_name == table_name )).first ()
515518 if table :
0 commit comments