diff --git a/runtime/datamate-python/app/module/annotation/interface/project.py b/runtime/datamate-python/app/module/annotation/interface/project.py index 95eaa1f..4ad3779 100644 --- a/runtime/datamate-python/app/module/annotation/interface/project.py +++ b/runtime/datamate-python/app/module/annotation/interface/project.py @@ -406,10 +406,16 @@ async def update_mapping( service = DatasetMappingService(db) - # 使用 mapping UUID 查询映射记录 - mapping = await service.get_mapping_by_uuid(project_id) + # 直接查询 ORM 模型获取原始数据 + result = await db.execute( + select(LabelingProject).where( + LabelingProject.id == project_id, + LabelingProject.deleted_at.is_(None) + ) + ) + mapping_orm = result.scalar_one_or_none() - if not mapping: + if not mapping_orm: raise HTTPException( status_code=404, detail=f"Mapping not found: {project_id}" @@ -422,8 +428,8 @@ async def update_mapping( # 从 configuration 字段中读取和更新 description 和 label_config configuration = {} - if mapping.configuration: - configuration = mapping.configuration.copy() if isinstance(mapping.configuration, dict) else {} + if mapping_orm.configuration: + configuration = mapping_orm.configuration.copy() if isinstance(mapping_orm.configuration, dict) else {} if request.description is not None: configuration["description"] = request.description @@ -438,10 +444,11 @@ async def update_mapping( if not update_values: # 没有要更新的字段,直接返回当前数据 + response_data = await service.get_mapping_by_uuid(project_id) return StandardResponse( code=200, message="success", - data=mapping + data=response_data ) # 执行更新