44from sqlalchemy import Column , String , Boolean , TIMESTAMP , Text , Integer , JSON , ForeignKey
55from sqlalchemy .sql import func
66
7- from app .db .session import Base
7+ from app .db .models . base_entity import BaseEntity
88
9- class AnnotationTemplate (Base ):
9+ class AnnotationTemplate (BaseEntity ):
1010 """标注配置模板模型"""
11-
11+
1212 __tablename__ = "t_dm_annotation_templates"
13-
13+ __ignore_data_scope__ = True
14+
1415 id = Column (String (36 ), primary_key = True , default = lambda : str (uuid .uuid4 ()), comment = "UUID" )
1516 name = Column (String (100 ), nullable = False , comment = "模板名称" )
1617 description = Column (String (500 ), nullable = True , comment = "模板描述" )
@@ -21,44 +22,40 @@ class AnnotationTemplate(Base):
2122 category = Column (String (50 ), default = 'custom' , comment = "模板分类: medical/general/custom/system" )
2223 built_in = Column (Boolean , default = False , comment = "是否系统内置模板" )
2324 version = Column (String (20 ), default = '1.0' , comment = "模板版本" )
24- created_at = Column (TIMESTAMP , server_default = func .current_timestamp (), comment = "创建时间" )
25- updated_at = Column (TIMESTAMP , server_default = func .current_timestamp (), onupdate = func .current_timestamp (), comment = "更新时间" )
2625 deleted_at = Column (TIMESTAMP , nullable = True , comment = "删除时间(软删除)" )
27-
26+
2827 def __repr__ (self ):
2928 return f"<AnnotationTemplate(id={ self .id } , name={ self .name } , data_type={ self .data_type } )>"
30-
29+
3130 @property
3231 def is_deleted (self ) -> bool :
3332 """检查是否已被软删除"""
3433 return self .deleted_at is not None
35-
36- class LabelingProject (Base ):
34+
35+ class LabelingProject (BaseEntity ):
3736 """标注项目模型"""
38-
37+
3938 __tablename__ = "t_dm_labeling_projects"
40-
39+
4140 id = Column (String (36 ), primary_key = True , default = lambda : str (uuid .uuid4 ()), comment = "UUID" )
4241 dataset_id = Column (String (36 ), nullable = False , comment = "数据集ID" )
4342 name = Column (String (100 ), nullable = False , comment = "项目名称" )
4443 labeling_project_id = Column (String (8 ), nullable = False , comment = "Label Studio项目ID" )
4544 template_id = Column (String (36 ), ForeignKey ('t_dm_annotation_templates.id' , ondelete = 'SET NULL' ), nullable = True , comment = "使用的模板ID" )
4645 configuration = Column (JSON , nullable = True , comment = "项目配置(可能包含对模板的自定义修改)" )
4746 progress = Column (JSON , nullable = True , comment = "项目进度信息" )
48- created_at = Column (TIMESTAMP , server_default = func .current_timestamp (), comment = "创建时间" )
49- updated_at = Column (TIMESTAMP , server_default = func .current_timestamp (), onupdate = func .current_timestamp (), comment = "更新时间" )
5047 deleted_at = Column (TIMESTAMP , nullable = True , comment = "删除时间(软删除)" )
51-
48+
5249 def __repr__ (self ):
5350 return f"<LabelingProject(id={ self .id } , name={ self .name } , dataset_id={ self .dataset_id } )>"
54-
51+
5552 @property
5653 def is_deleted (self ) -> bool :
5754 """检查是否已被软删除"""
5855 return self .deleted_at is not None
5956
6057
61- class AutoAnnotationTask (Base ):
58+ class AutoAnnotationTask (BaseEntity ):
6259 """自动标注任务模型,对应表 t_dm_auto_annotation_tasks"""
6360
6461 __tablename__ = "t_dm_auto_annotation_tasks"
@@ -76,13 +73,6 @@ class AutoAnnotationTask(Base):
7673 detected_objects = Column (Integer , default = 0 , comment = "检测到的对象总数" )
7774 output_path = Column (String (500 ), nullable = True , comment = "输出路径" )
7875 error_message = Column (Text , nullable = True , comment = "错误信息" )
79- created_at = Column (TIMESTAMP , server_default = func .current_timestamp (), comment = "创建时间" )
80- updated_at = Column (
81- TIMESTAMP ,
82- server_default = func .current_timestamp (),
83- onupdate = func .current_timestamp (),
84- comment = "更新时间" ,
85- )
8676 completed_at = Column (TIMESTAMP , nullable = True , comment = "完成时间" )
8777 deleted_at = Column (TIMESTAMP , nullable = True , comment = "删除时间(软删除)" )
8878
@@ -92,4 +82,4 @@ def __repr__(self) -> str: # pragma: no cover - repr 简单返回
9282 @property
9383 def is_deleted (self ) -> bool :
9484 """检查是否已被软删除"""
95- return self .deleted_at is not None
85+ return self .deleted_at is not None
0 commit comments