35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""认知冲突模型"""
|
||
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)
|