5c028d7952
包含 FastAPI 后端、React 前端、队列/OCR/标签/待办等完整功能。 Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""AI 抽取的待办(待看/待读/待办)。"""
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Index, Integer, String, Text, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.core.db import Base
|
|
|
|
|
|
class TodoStatus(str, Enum):
|
|
"""待办状态。"""
|
|
|
|
PENDING = "pending"
|
|
DOING = "doing"
|
|
DONE = "done"
|
|
DROPPED = "dropped"
|
|
|
|
|
|
class Todo(Base):
|
|
"""AI 从截图中抽取的待办项。"""
|
|
|
|
__tablename__ = "todos"
|
|
__table_args__ = (
|
|
Index("ix_todos_status", "status"),
|
|
Index("ix_todos_screenshot_id", "screenshot_id"),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
|
screenshot_id: Mapped[int] = mapped_column(
|
|
Integer,
|
|
ForeignKey("screenshots.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
)
|
|
title: Mapped[str] = mapped_column(String(512), nullable=False)
|
|
note: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
kind: Mapped[str | None] = mapped_column(String(32), nullable=True) # 待看/待读/待办等
|
|
status: Mapped[str] = mapped_column(String(16), default=TodoStatus.PENDING.value)
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime, server_default=func.now(), nullable=False
|
|
)
|
|
completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
|
|
screenshot = relationship("Screenshot", back_populates="todos")
|