mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 20:55:14 +00:00
chore: 批量整理代码格式与优化细节
- 修复多处代码缩进、换行不规范问题 - 调整部分配置注释与字符串格式对齐 - 优化导入语句与多行表达式的排版 - 统一枚举、模型字段的注释风格 - 调整部分校验逻辑与提示文案 - 重构部分长函数参数与查询语句格式
This commit is contained in:
@@ -9,11 +9,11 @@ from app.core.validator import DateTimeStr
|
||||
class ParamsCreateSchema(BaseModel):
|
||||
"""配置创建模型"""
|
||||
|
||||
config_name: str = Field(..., max_length=64, description="参数名称")
|
||||
config_key: str = Field(..., max_length=500, description="参数键名")
|
||||
config_value: str | None = Field(default=None, description="参数键值")
|
||||
config_type: bool = Field(default=False, description="系统内置(True:是 False:否)")
|
||||
status: str = Field(default="0", description="状态(True:正常 False:停用)")
|
||||
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, max_length=500, description="参数键值")
|
||||
config_type: bool = Field(default=False, description="是否系统内置")
|
||||
status: str = Field(default="0", max_length=1, description="状态(0:正常 1:停用)")
|
||||
description: str | None = Field(default=None, max_length=500, description="描述")
|
||||
|
||||
@field_validator("config_key")
|
||||
@@ -21,9 +21,15 @@ class ParamsCreateSchema(BaseModel):
|
||||
def _validate_config_key(cls, v: str) -> str:
|
||||
v = v.strip().lower()
|
||||
import re
|
||||
|
||||
if not re.match(r"^[a-z][a-z0-9_.-]*$", v):
|
||||
raise ValueError("参数键名必须以小写字母开头,仅包含小写字母/数字/_.-")
|
||||
raise ValueError("参数键名必须以小写字母开头,仅允许小写字母、数字、_ . -")
|
||||
return v
|
||||
|
||||
@field_validator("status")
|
||||
@classmethod
|
||||
def _validate_status(cls, v: str) -> str:
|
||||
if v not in {"0", "1"}:
|
||||
raise ValueError("状态仅支持 0(正常) 或 1(停用)")
|
||||
return v
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user