Files
site11/services/news-engine-console/backend/app/schemas/user.py
jungwoo choi 07088e60e9 feat: Implement backend core functionality for news-engine-console
Phase 1 Backend Implementation:
-  MongoDB data models (Keyword, Pipeline, User, Application)
-  Pydantic schemas for all models with validation
-  KeywordService: Full CRUD, filtering, pagination, stats, toggle status
-  PipelineService: Full CRUD, start/stop/restart, logs, config management
-  Keywords API: 8 endpoints with complete functionality
-  Pipelines API: 11 endpoints with complete functionality
-  Updated TODO.md to reflect completion

Key Features:
- Async MongoDB operations with Motor
- Comprehensive filtering and pagination support
- Pipeline logging system
- Statistics tracking for keywords and pipelines
- Proper error handling with HTTP status codes
- Type-safe request/response models

Files Added:
- models/: 4 data models with PyObjectId support
- schemas/: 4 schema modules with Create/Update/Response patterns
- services/: KeywordService (234 lines) + PipelineService (332 lines)

Files Modified:
- api/keywords.py: 40 → 212 lines (complete implementation)
- api/pipelines.py: 25 → 300 lines (complete implementation)
- TODO.md: Updated checklist with completed items

Next Steps:
- UserService with authentication
- ApplicationService for OAuth2
- MonitoringService
- Redis integration
- Frontend implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 16:24:14 +09:00

56 lines
1.5 KiB
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, EmailStr
class UserBase(BaseModel):
"""Base user schema"""
username: str = Field(..., min_length=3, max_length=50)
email: EmailStr
full_name: str = Field(..., min_length=1, max_length=100)
role: str = Field(default="viewer", description="Role: admin, editor, viewer")
class UserCreate(UserBase):
"""Schema for creating a new user"""
password: str = Field(..., min_length=8, max_length=100)
class UserUpdate(BaseModel):
"""Schema for updating a user (all fields optional)"""
email: Optional[EmailStr] = None
full_name: Optional[str] = Field(None, min_length=1, max_length=100)
role: Optional[str] = None
disabled: Optional[bool] = None
password: Optional[str] = Field(None, min_length=8, max_length=100)
class UserResponse(UserBase):
"""Schema for user response (without password)"""
id: str = Field(..., alias="_id")
disabled: bool
created_at: datetime
last_login: Optional[datetime] = None
class Config:
populate_by_name = True
from_attributes = True
class UserLogin(BaseModel):
"""Schema for user login"""
username: str
password: str
class Token(BaseModel):
"""Schema for JWT token response"""
access_token: str
token_type: str = "bearer"
expires_in: int
class TokenData(BaseModel):
"""Schema for decoded token data"""
username: Optional[str] = None