Files
kami_spider_monorepo/apps/app_b/models.py
danial 0e41e7acce feat(core): 初始化核心配置和部署文件
- 添加 .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 全局异常处理中间件
2025-11-01 14:32:29 +08:00

46 lines
1.2 KiB
Python

"""
App B Models - Database models for products.
"""
from typing import Optional
from datetime import datetime
from decimal import Decimal
from sqlmodel import SQLModel, Field
class ProductBase(SQLModel):
"""Base product model with shared fields."""
name: str = Field(index=True, max_length=100)
description: Optional[str] = Field(default=None, max_length=500)
price: Decimal = Field(decimal_places=2)
stock: int = Field(default=0, ge=0)
is_available: bool = Field(default=True)
class Product(ProductBase, table=True):
"""
Product table model.
Represents products in the system.
"""
__tablename__ = "products"
id: Optional[int] = Field(default=None, primary_key=True)
sku: str = Field(unique=True, index=True, max_length=50)
created_at: datetime = Field(default_factory=datetime.utcnow)
updated_at: datetime = Field(default_factory=datetime.utcnow)
class Config:
json_schema_extra = {
"example": {
"name": "Laptop",
"description": "High-performance laptop",
"price": "999.99",
"stock": 10,
"sku": "LAP-001",
"is_available": True,
}
}