661b85ce62
- Updated main.py to include authentication for brand, model, and OTA routers. - Added new OTA schemas in schemas.py for version management. - Enhanced model retrieval with sorting options in models.py. - Improved model update functionality to support multipart/form-data uploads. - Updated frontend layout and styles for a more modern look, including new font integration. - Implemented login route and authentication checks in router/index.js. - Added sorting capabilities in model table and improved file handling in model view. - Updated requirements.txt to include PyJWT for token management.
107 lines
4.7 KiB
Python
107 lines
4.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
|
|
|
|
|
|
# OTA Schemas
|
|
class OtaBase(BaseModel):
|
|
verCode: int = Field(..., description="版本号(整数)")
|
|
verName: str = Field(..., min_length=1, max_length=20, description="版本名称")
|
|
url: str = Field(..., max_length=255, description="升级包 URL")
|
|
md5: str = Field(..., min_length=32, max_length=32, description="升级包 MD5")
|
|
force: Optional[int] = Field(0, ge=0, le=1, description="是否强升;0-否")
|
|
desc: Optional[str] = Field(None, max_length=255, description="描述")
|
|
model: Optional[str] = Field(None, max_length=100, description="对应的设备型号")
|
|
hw: Optional[int] = Field(0, description="硬件版本号")
|
|
target: Optional[int] = Field(0, ge=0, le=1, description="是否定向,1-是,0-否")
|
|
beta: Optional[int] = Field(0, ge=0, le=1, description="是否灰度,1-是,0-否")
|
|
pawVerCode: Optional[int] = Field(0, description="配对版本号")
|
|
pawVerName: Optional[str] = Field("", max_length=20, description="配对版本名称")
|
|
pawUrl: Optional[str] = Field("", max_length=255, description="配对版本 URL")
|
|
pawMd5: Optional[str] = Field("", min_length=32, max_length=32, description="配对版本 MD5")
|
|
startTime: Optional[datetime] = Field(None, description="升级开始时间")
|
|
endTime: Optional[datetime] = Field(None, description="升级结束时间")
|
|
status: Optional[int] = Field(1, ge=0, le=1, description="是否可用")
|
|
|
|
|
|
class OtaCreate(OtaBase):
|
|
pass
|
|
|
|
|
|
class OtaUpdate(BaseModel):
|
|
verCode: Optional[int] = Field(None, description="版本号(整数)")
|
|
verName: Optional[str] = Field(None, min_length=1, max_length=20, description="版本名称")
|
|
url: Optional[str] = Field(None, max_length=255, description="升级包 URL")
|
|
md5: Optional[str] = Field(None, min_length=32, max_length=32, description="升级包 MD5")
|
|
force: Optional[int] = Field(None, ge=0, le=1, description="是否强升;0-否")
|
|
desc: Optional[str] = Field(None, max_length=255, description="描述")
|
|
model: Optional[str] = Field(None, max_length=100, description="对应的设备型号")
|
|
hw: Optional[int] = Field(None, description="硬件版本号")
|
|
target: Optional[int] = Field(None, ge=0, le=1, description="是否定向,1-是,0-否")
|
|
beta: Optional[int] = Field(None, ge=0, le=1, description="是否灰度,1-是,0-否")
|
|
pawVerCode: Optional[int] = Field(None, description="配对版本号")
|
|
pawVerName: Optional[str] = Field(None, max_length=20, description="配对版本名称")
|
|
pawUrl: Optional[str] = Field(None, max_length=255, description="配对版本 URL")
|
|
pawMd5: Optional[str] = Field(None, min_length=32, max_length=32, description="配对版本 MD5")
|
|
startTime: Optional[datetime] = Field(None, description="升级开始时间")
|
|
endTime: Optional[datetime] = Field(None, description="升级结束时间")
|
|
status: Optional[int] = Field(None, ge=0, le=1, description="是否可用")
|
|
|
|
|
|
class OtaResponse(OtaBase):
|
|
id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|