"""重大事项模型。 AI 从月报/弱信号中自动识别重大事项。 """ import uuid from datetime import datetime, timezone from sqlalchemy import DateTime, ForeignKey, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.core.database import Base from app.core.types import JSONBType class MajorEvent(Base): """重大事项。""" __tablename__ = "major_events" id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4())) company_id: Mapped[str] = mapped_column(String(36), ForeignKey("companies.id"), nullable=False, index=True) event_type: Mapped[str] = mapped_column(String(50), nullable=False, comment="funding/personnel/product/legal/market/org") title: Mapped[str] = mapped_column(String(200), nullable=False) description: Mapped[str | None] = mapped_column(Text, nullable=True) severity: Mapped[str] = mapped_column(String(20), nullable=False, default="medium", comment="low/medium/high/critical") source: Mapped[str | None] = mapped_column(String(100), nullable=True, comment="来源:monthly_report/weak_signal/manual") source_ref: Mapped[str | None] = mapped_column(String(36), nullable=True, comment="来源记录 ID") evidence: Mapped[dict | None] = mapped_column(JSONBType, nullable=True, comment="证据链") status: Mapped[str] = mapped_column(String(20), nullable=False, default="identified", comment="identified/confirmed/addressed") occurred_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) )