PMFlow/backend/app/models/cognitive_conflict.py

35 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""认知冲突模型"""
from .base import BaseNoTenant
from .types import ARRAY
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import BigInteger, Integer, VARCHAR, Text, TIMESTAMP, ForeignKey, func
from typing import Optional, List
from datetime import datetime
class BaseNoUpdatedAt(BaseNoTenant):
"""仅有 tenant_id 和 created_at,无 updated_at"""
__abstract__ = True
tenant_id: Mapped[int] = mapped_column(
BigInteger, nullable=False, default=1, index=True
)
created_at: Mapped[datetime] = mapped_column(
TIMESTAMP, nullable=False, server_default=func.now()
)
class CognitiveConflict(BaseNoUpdatedAt):
__tablename__ = "cognitive_conflicts"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
truth_node_id: Mapped[int] = mapped_column(
BigInteger, ForeignKey("truth_nodes.id"), nullable=False
)
conflict_type: Mapped[str] = mapped_column(VARCHAR(100), nullable=False)
description: Mapped[str] = mapped_column(Text, nullable=False)
involved_user_ids: Mapped[List[int]] = mapped_column(
ARRAY(BigInteger), nullable=False
)
status: Mapped[str] = mapped_column(VARCHAR(50), nullable=False)
resolved_at: Mapped[Optional[datetime]] = mapped_column(TIMESTAMP, nullable=True)