mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-20 20:39:55 +00:00
1. 删除无用文件与废弃代码:移除locale枚举、element-plus插件、sse路由、api token模块等 2. 简化类型导入与依赖:移除大量未使用的类型导入,统一echarts导入方式 3. 优化配置与样式:调整gitignore、样式引入顺序,新增列表动画样式 4. 修复接口与模型:修正接口返回类型、查询参数配置,更新部门模型字段 5. 优化性能与体验:添加图片懒加载,优化加载逻辑与表格渲染 6. 调整环境配置:新增并更新开发/生产环境配置文件
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
import re
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
from app.core.base_schema import BaseSchema
|
|
|
|
|
|
class ParamsBaseSchema(BaseModel):
|
|
"""参数基础字段
|
|
"""
|
|
|
|
config_name: str = Field(..., min_length=1, max_length=64, description="参数名称")
|
|
config_key: str = Field(..., min_length=1, max_length=500, description="参数键名(小写字母开头,仅允许字母数字_.-)")
|
|
config_value: str | None = Field(default=None, description="参数键值")
|
|
config_type: bool = Field(default=False, description="是否系统内置(True:是 False:否)")
|
|
status: int = Field(default=0, ge=0, le=1, description="状态(0:正常 1:停用)")
|
|
description: str | None = Field(default=None, max_length=500, description="参数描述")
|
|
|
|
@field_validator("config_key")
|
|
@classmethod
|
|
def _validate_config_key(cls, v: str) -> str:
|
|
"""校验参数键名:小写字母开头,仅含字母/数字/_ . -"""
|
|
v = v.strip().lower()
|
|
if not re.match(r"^[a-z][a-z0-9_.-]*$", v):
|
|
raise ValueError("参数键名必须以小写字母开头,仅允许小写字母、数字、_ . -")
|
|
return v
|
|
|
|
@field_validator("status")
|
|
@classmethod
|
|
def _validate_status(cls, v: int) -> int:
|
|
"""校验状态:仅支持 0(正常) 或 1(停用)"""
|
|
if v not in {0, 1}:
|
|
raise ValueError("状态仅支持 0(正常) 或 1(停用)")
|
|
return v
|
|
|
|
|
|
class ParamsUpdateSchema(ParamsBaseSchema):
|
|
"""参数更新模型
|
|
"""
|
|
|
|
|
|
class ParamsOutSchema(ParamsBaseSchema, BaseSchema):
|
|
"""参数响应模型
|
|
"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|