- 添加 .env.example 环境变量配置示例 - 添加 .gitignore 忽略文件配置 - 添加 core/config.py 配置管理模块 - 添加 deployments/k8s/configmap.yaml Kubernetes 配置 - 添加 core/database.py 数据库连接管理模块 - 添加 core/dependencies.py 全局依赖模块 - 添加 DEPENDENCIES_UPDATED.md 依赖更新记录 - 添加 deployments/k8s/deployment.yaml Kubernetes 部署配置- 添加 deployments/swarm/docker-compose.swarm.yml Docker Swarm 部署配置 - 添加 deployments/docker/docker-compose.yml Docker 部署配置 - 添加 deployments/docker/Dockerfile 应用镜像构建文件 - 添加 middleware/error_handler.py 全局异常处理中间件
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
"""
|
|
App A Schemas - Pydantic schemas for request/response validation.
|
|
"""
|
|
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from pydantic import BaseModel, Field, EmailStr
|
|
|
|
|
|
class UserCreate(BaseModel):
|
|
"""Schema for creating a new user."""
|
|
|
|
username: str = Field(..., min_length=3, max_length=50)
|
|
email: EmailStr
|
|
password: str = Field(..., min_length=6)
|
|
full_name: Optional[str] = Field(None, max_length=100)
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"username": "john_doe",
|
|
"email": "john@example.com",
|
|
"password": "secret123",
|
|
"full_name": "John Doe",
|
|
}
|
|
}
|
|
|
|
|
|
class UserUpdate(BaseModel):
|
|
"""Schema for updating a user."""
|
|
|
|
email: Optional[EmailStr] = None
|
|
full_name: Optional[str] = Field(None, max_length=100)
|
|
is_active: Optional[bool] = None
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"email": "newemail@example.com",
|
|
"full_name": "John Smith",
|
|
"is_active": True,
|
|
}
|
|
}
|
|
|
|
|
|
class UserResponse(BaseModel):
|
|
"""Schema for user response."""
|
|
|
|
id: int
|
|
username: str
|
|
email: str
|
|
full_name: Optional[str]
|
|
is_active: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
json_schema_extra = {
|
|
"example": {
|
|
"id": 1,
|
|
"username": "john_doe",
|
|
"email": "john@example.com",
|
|
"full_name": "John Doe",
|
|
"is_active": True,
|
|
"created_at": "2024-01-15T10:30:00Z",
|
|
"updated_at": "2024-01-15T10:30:00Z",
|
|
}
|
|
}
|