Files
rssWorkFlow/backend/app/schemas/article.py
T
congsh ba6e7669e8 Initial commit: RSS platform phase 1 skeleton with code review fixes
Features:
- FastAPI + SQLAlchemy 2.0 async + PostgreSQL/pgvector + Redis backend
- Vue 3 + TypeScript + Element Plus frontend
- JWT auth with access/refresh tokens and revocation
- Admin/member RBAC
- RSS feed CRUD and article listing
- Settings management with Fernet encryption for sensitive values
- Redis distributed lock service
- Alembic initial migration
- Docker Compose development environment

Fixes from code review:
- Fix DB session leak in dependency injection
- Restrict registration to admin only
- Add default admin password warning
- Implement JWT refresh tokens and jti blacklist
- Strengthen password policy
- Use func.count for pagination totals
- Replace NullPool with AsyncAdaptedQueuePool
- Remove init_db from lifespan to enforce alembic migrations
- Add request_id middleware and logging filter
- Fix vite.config.ts env loading
- Add frontend token refresh interceptor
- Add Vue error handler

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 17:01:57 +08:00

58 lines
1.6 KiB
Python

"""Article Pydantic schemas."""
from pydantic import BaseModel, ConfigDict, Field
class ArticleListParams(BaseModel):
"""Article list query parameters."""
feed_id: str | None = None
category: str | None = None
tag: str | None = None
search: str | None = None
is_read: bool | None = None
skip: int = 0
limit: int = Field(default=50, le=200)
class ArticleOut(BaseModel):
"""Cleaned article output schema."""
model_config = ConfigDict(from_attributes=True)
id: str
raw_article_id: str | None = None
feed_id: str
title: str | None = None
link: str
author: str | None = None
feed_title: str | None = None
feed_category: str | None = None
published_at: str | None = None
fetched_at: str
content: str | None = None
original_summary: str | None = None
ai_summary: str | None = None
category: str | None = None
tags: list[str] = []
heat_score: float = 0.0
importance_score: float = 0.0
duplication_score: float = 0.0
composite_score: float = 0.0
is_representative: bool = True
reference_links: list[dict] = []
processing_status: str = "pending"
created_at: str
updated_at: str
@classmethod
def model_validate(cls, obj):
"""Format datetime fields."""
data = {}
for key in obj.__dict__:
value = getattr(obj, key)
if key in ("created_at", "updated_at", "published_at", "fetched_at") and value is not None:
data[key] = value.isoformat()
else:
data[key] = value
return cls.model_construct(**data)