- 重命名apps/app_b为apps/apple,调整项目结构 - 新增apps.apple.clients.itunes模块,实现iTunes API客户端功能 - 实现iTunes登录、兑换和查询接口,支持错误重试和状态处理 - 设计解析Apple XML响应的工具函数,提升数据处理能力 - 定义iTunes登录和兑换相关数据模型,基于Pydantic提升数据校验 - 新增apps.apple.clients.june模块,实现June API客户端功能 - 实现六月客户端登录、状态检测、签名获取及远程账户登录 - 设计June客户端请求加密与签名机制,保障接口安全通信 - 增加六月客户端配置、加密工具和辅助函数支持 - 完善模块__init__.py文件,明确导出API客户端类
81 lines
2.2 KiB
Python
81 lines
2.2 KiB
Python
"""
|
|
App B Schemas - Pydantic schemas for products.
|
|
"""
|
|
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ProductCreate(BaseModel):
|
|
"""Schema for creating a new product."""
|
|
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
description: Optional[str] = Field(None, max_length=500)
|
|
price: Decimal = Field(..., gt=0, decimal_places=2)
|
|
stock: int = Field(default=0, ge=0)
|
|
sku: str = Field(..., min_length=1, max_length=50)
|
|
is_available: bool = Field(default=True)
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"name": "Laptop",
|
|
"description": "High-performance laptop",
|
|
"price": "999.99",
|
|
"stock": 10,
|
|
"sku": "LAP-001",
|
|
"is_available": True,
|
|
}
|
|
}
|
|
|
|
|
|
class ProductUpdate(BaseModel):
|
|
"""Schema for updating a product."""
|
|
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
description: Optional[str] = Field(None, max_length=500)
|
|
price: Optional[Decimal] = Field(None, gt=0, decimal_places=2)
|
|
stock: Optional[int] = Field(None, ge=0)
|
|
is_available: Optional[bool] = None
|
|
|
|
class Config:
|
|
json_schema_extra = {
|
|
"example": {
|
|
"name": "Updated Laptop",
|
|
"price": "899.99",
|
|
"stock": 15,
|
|
}
|
|
}
|
|
|
|
|
|
class ProductResponse(BaseModel):
|
|
"""Schema for product response."""
|
|
|
|
id: int
|
|
name: str
|
|
description: Optional[str]
|
|
price: Decimal
|
|
stock: int
|
|
sku: str
|
|
is_available: bool
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
json_schema_extra = {
|
|
"example": {
|
|
"id": 1,
|
|
"name": "Laptop",
|
|
"description": "High-performance laptop",
|
|
"price": "999.99",
|
|
"stock": 10,
|
|
"sku": "LAP-001",
|
|
"is_available": True,
|
|
"created_at": "2024-01-15T10:30:00Z",
|
|
"updated_at": "2024-01-15T10:30:00Z",
|
|
}
|
|
}
|