企業內部新聞彙整與分析系統 - 自動新聞抓取 (Digitimes, 經濟日報, 工商時報) - AI 智慧摘要 (OpenAI/Claude/Ollama) - 群組管理與訂閱通知 - 已清理 Python 快取檔案 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
71 lines
1.6 KiB
Python
71 lines
1.6 KiB
Python
"""
|
|
群組與關鍵字 Pydantic Schema
|
|
"""
|
|
from datetime import datetime
|
|
from typing import Optional, Literal
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.schemas.user import PaginationResponse
|
|
|
|
|
|
# ===== Keyword =====
|
|
class KeywordBase(BaseModel):
|
|
keyword: str = Field(..., max_length=100)
|
|
|
|
|
|
class KeywordCreate(KeywordBase):
|
|
pass
|
|
|
|
|
|
class KeywordResponse(KeywordBase):
|
|
id: int
|
|
is_active: bool
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# ===== Group =====
|
|
class GroupBase(BaseModel):
|
|
name: str = Field(..., max_length=100)
|
|
description: Optional[str] = None
|
|
category: Literal["industry", "topic"]
|
|
|
|
|
|
class GroupCreate(GroupBase):
|
|
ai_background: Optional[str] = None
|
|
ai_prompt: Optional[str] = None
|
|
keywords: Optional[list[str]] = None
|
|
|
|
|
|
class GroupUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, max_length=100)
|
|
description: Optional[str] = None
|
|
category: Optional[Literal["industry", "topic"]] = None
|
|
ai_background: Optional[str] = None
|
|
ai_prompt: Optional[str] = None
|
|
is_active: Optional[bool] = None
|
|
|
|
|
|
class GroupResponse(GroupBase):
|
|
id: int
|
|
is_active: bool
|
|
keyword_count: Optional[int] = 0
|
|
subscriber_count: Optional[int] = 0
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class GroupDetailResponse(GroupResponse):
|
|
ai_background: Optional[str] = None
|
|
ai_prompt: Optional[str] = None
|
|
keywords: list[KeywordResponse] = []
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class GroupListResponse(BaseModel):
|
|
data: list[GroupResponse]
|
|
pagination: PaginationResponse
|