from sqlalchemy import Column, Integer, String, Text, BigInteger from database import Base class Scene(Base): """总场景表""" __tablename__ = "scene" id = Column(BigInteger, primary_key=True, autoincrement=True) scene_name = Column(String(255), nullable=False, comment="场景名称") scene_en_name = Column(String(255), default="", comment="场景英文名") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否") class FirstScene(Base): """一级场景表""" __tablename__ = "first_scene" id = Column(BigInteger, primary_key=True, autoincrement=True) first_scene_name = Column(String(255), nullable=False, comment="一级场景名称") scene_id = Column(BigInteger, nullable=False, comment="场景ID") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否") class SecondScene(Base): """二级场景表""" __tablename__ = "second_scene" id = Column(BigInteger, primary_key=True, autoincrement=True) second_scene_name = Column(String(255), nullable=False, comment="二级场景名称") first_scene_id = Column(BigInteger, nullable=False, comment="一级场景ID") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否") class ThirdScene(Base): """三级场景表""" __tablename__ = "third_scene" id = Column(BigInteger, primary_key=True, autoincrement=True) third_scene_name = Column(String(255), nullable=False, comment="三级场景名称") second_scene_id = Column(BigInteger, nullable=False, comment="二级场景ID") correct_example_image = Column(String(255), default="", comment="正确示例图") wrong_example_image = Column(String(255), default="", comment="错误示例图") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否") class SceneTemplate(Base): """场景模板表""" __tablename__ = "scene_template" id = Column(BigInteger, primary_key=True, autoincrement=True) scene_name = Column(String(255), nullable=False, comment="场景名称") scene_type = Column(String(100), nullable=False, comment="场景类型") scene_desc = Column(Text, comment="场景描述") model_name = Column(String(255), nullable=False, comment="YOLO模型名称") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否") class RecognitionRecord(Base): """识别记录表""" __tablename__ = "recognition_record" id = Column(BigInteger, primary_key=True, autoincrement=True) original_image_url = Column(Text, nullable=False, comment="原图地址") recognition_image_url = Column(Text, nullable=False, comment="识别结果图地址") user_id = Column(BigInteger, nullable=False, comment="用户ID") scene_type = Column(String(100), default="", comment="场景类型") hazard_count = Column(Integer, default=0, comment="隐患数量") current_step = Column(Integer, default=1, comment="当前步骤") hazard_details = Column(Text, comment="隐患详情JSON") title = Column(String(255), default="", comment="标题") description = Column(Text, default="", comment="描述") labels = Column(String(255), default="", comment="标签") tag_type = Column(String(255), default="", comment="标签类型") second_scene = Column(String(1000), default="", comment="详情页的二级场景") third_scene = Column(String(1000), default="", comment="详情页的三级场景") scene_match = Column(BigInteger, default=0, comment="场景匹配(0、否,1、是)") tip_accuracy = Column(BigInteger, default=0, comment="提示准确(0、否,1、是)") effect_evaluation = Column(BigInteger, default=0, comment="效果评价(1-5)") user_remark = Column(String(200), default="", comment="用户备注") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否") class RecognitionRecordSecondScene(Base): """识别记录对应的二级场景表""" __tablename__ = "recognition_record_second_scene" id = Column(BigInteger, primary_key=True, autoincrement=True) recognition_record_id = Column(BigInteger, nullable=False, comment="识别记录ID") second_scene_id = Column(BigInteger, nullable=False, comment="二级场景ID") created_at = Column(BigInteger, comment="创建时间") updated_at = Column(BigInteger, comment="更新时间") deleted_at = Column(BigInteger, comment="删除时间") is_deleted = Column(BigInteger, default=0, comment="是否删除 1:是 0:否")