from sqlalchemy import Column, String, Text, Boolean, Integer, Float, DateTime, JSON from .base import BaseModel class Event(BaseModel): __tablename__ = "events" event_type = Column(String(50), nullable=False, comment="事件类型: person_detection, vehicle_detection, intrusion, etc") device_id = Column(Integer, nullable=False, comment="关联设备ID") algorithm_id = Column(Integer, comment="关联算法ID") severity = Column(String(20), default="medium", comment="严重程度: low, medium, high, critical") status = Column(String(20), default="pending", comment="事件状态: pending, processing, resolved, ignored") confidence = Column(Float, comment="置信度") bbox = Column(Text, comment="边界框坐标,JSON格式: [x, y, width, height]") image_path = Column(String(500), comment="事件图片路径") video_path = Column(String(500), comment="事件视频路径") description = Column(Text, comment="事件描述") location = Column(String(200), comment="事件发生位置") detected_objects = Column(Text, comment="检测到的对象,JSON格式") processing_time = Column(Float, comment="处理时间(ms)") is_alert = Column(Boolean, default=False, comment="是否触发告警") alert_sent = Column(Boolean, default=False, comment="是否已发送告警") operator_id = Column(Integer, comment="处理人员ID") resolution_notes = Column(Text, comment="处理备注") resolved_at = Column(DateTime, comment="解决时间")