mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
此次提交进行了大规模的架构重构: 1. 移除所有平台租户相关模块和代码,包括租户管理、套餐、订单、发票等功能 2. 将菜单模块从platform迁移到system模块,统一系统功能入口 3. 移除租户隔离相关的模型混入、中间件和配置 4. 简化文件上传、SSE事件总线、定时任务等模块的租户逻辑 5. 重构所有业务schema和模型,移除租户相关字段和关联 6. 清理初始化脚本、模板和常量中的租户相关代码 7. 简化认证和权限控制逻辑,移除数据范围检查相关代码
57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
import re
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
from app.core.base_schema import BaseQueryParam, BaseSchema, UserByQueryParam, UserBySchema
|
|
|
|
|
|
class ParamsCreateSchema(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(ParamsCreateSchema):
|
|
"""参数更新模型
|
|
"""
|
|
|
|
|
|
class ParamsOutSchema(ParamsCreateSchema, BaseSchema, UserBySchema):
|
|
"""参数响应模型
|
|
"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ParamsQueryParam(BaseQueryParam, UserByQueryParam):
|
|
"""参数管理查询参数
|
|
"""
|
|
|
|
config_name: str | None = Field(None, description="参数名称")
|
|
config_key: str | None = Field(None, description="参数键名", json_schema_extra={"q": "eq"})
|
|
config_type: bool | None = Field(None, description="是否系统内置(True:是 False:否)")
|
|
status: int | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")
|