- 添加 .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 全局异常处理中间件
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""
|
|
App A Models - Database models using SQLModel.
|
|
"""
|
|
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from sqlmodel import SQLModel, Field
|
|
|
|
|
|
class UserBase(SQLModel):
|
|
"""Base user model with shared fields."""
|
|
|
|
username: str = Field(index=True, max_length=50)
|
|
email: str = Field(index=True, max_length=100)
|
|
full_name: Optional[str] = Field(default=None, max_length=100)
|
|
is_active: bool = Field(default=True)
|
|
|
|
|
|
class User(UserBase, table=True):
|
|
"""
|
|
User table model.
|
|
|
|
Represents users in the system.
|
|
"""
|
|
|
|
__tablename__ = "users"
|
|
|
|
id: Optional[int] = Field(default=None, primary_key=True)
|
|
hashed_password: str = Field(max_length=255)
|
|
created_at: datetime = Field(default_factory=datetime.utcnow)
|
|
updated_at: datetime = Field(default_factory=datetime.utcnow)
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"username": "john_doe",
|
|
"email": "john@example.com",
|
|
"full_name": "John Doe",
|
|
"is_active": True,
|
|
}
|
|
}
|