from sqlalchemy import Column, String, Integer, JSON, TIMESTAMP from sqlalchemy.sql import func from app.db.database import Base import uuid class LabelingProject(Base): """DM标注项目模型(原 DatasetMapping)""" __tablename__ = "t_dm_labeling_projects" id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="UUID主键ID") dataset_id = Column(String(36), nullable=False, comment="数据集ID") name = Column(String(32), nullable=False, comment="项目名称") labeling_project_id = Column(Integer, nullable=False, comment="Label Studio项目ID") configuration = Column(JSON, nullable=True, comment="标签配置") progress = Column(JSON, nullable=True, comment="标注进度统计") created_at = Column(TIMESTAMP, server_default=func.current_timestamp(), comment="创建时间") deleted_at = Column(TIMESTAMP, nullable=True, comment="删除时间(软删除)") def __repr__(self): return f"" @property def is_deleted(self) -> bool: """检查是否已被软删除""" return self.deleted_at is not None