75b1d16453
Made-with: Cursor
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from pydantic import BaseModel, Field
|
|
from typing import Optional
|
|
from datetime import datetime
|
|
|
|
|
|
# Brand Schemas
|
|
class BrandBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=100, description="品牌名称")
|
|
|
|
|
|
class BrandCreate(BrandBase):
|
|
pass
|
|
|
|
|
|
class BrandUpdate(BaseModel):
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100, description="品牌名称")
|
|
|
|
|
|
class BrandResponse(BrandBase):
|
|
id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Model Schemas
|
|
class ModelBase(BaseModel):
|
|
brand_name: str = Field(..., min_length=1, max_length=100, description="品牌名称")
|
|
name: str = Field(..., min_length=1, max_length=100, description="型号名称")
|
|
form: Optional[str] = Field(None, max_length=100, description="形式")
|
|
rig: Optional[str] = Field(None, max_length=100, description="阻抗")
|
|
source: Optional[str] = Field(None, max_length=100, description="来源")
|
|
eq_key: Optional[str] = Field(None, max_length=255, description="EQ 键")
|
|
|
|
|
|
class ModelCreate(ModelBase):
|
|
pass
|
|
|
|
|
|
class ModelUpdate(BaseModel):
|
|
brand_name: Optional[str] = Field(None, min_length=1, max_length=100, description="品牌名称")
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100, description="型号名称")
|
|
form: Optional[str] = Field(None, max_length=100, description="形式")
|
|
rig: Optional[str] = Field(None, max_length=100, description="阻抗")
|
|
source: Optional[str] = Field(None, max_length=100, description="来源")
|
|
eq_key: Optional[str] = Field(None, max_length=255, description="EQ 键")
|
|
|
|
|
|
class ModelResponse(ModelBase):
|
|
id: int
|
|
create_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|