mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 13:05:18 +00:00
这是一个大规模的类型对齐优化: 1. 将多处字符串类型的status字段统一改为数字类型,包括前后端接口定义、数据模型、页面组件 2. 重构编排节点相关的命名和注释,统一改为"节点类型"替代"编排节点类型" 3. 移除了过时的忘记密码相关接口和模板代码 4. 优化搜索栏组件,支持展开仅显示次要字段 5. 调整部分接口参数和路由逻辑,对齐前后端参数格式
89 lines
3.2 KiB
Python
89 lines
3.2 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
||
|
||
from app.core.base_schema import JWTOutSchema
|
||
|
||
|
||
class CaptchaOutSchema(BaseModel):
|
||
"""验证码响应模型"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
enable: bool = Field(default=True, description="是否启用验证码")
|
||
key: str = Field(..., min_length=1, description="验证码唯一标识")
|
||
img_base: str = Field(..., min_length=1, description="Base64编码的验证码图片")
|
||
|
||
|
||
class AutoLoginUserSchema(BaseModel):
|
||
"""免登录用户信息模型"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
id: int = Field(..., description="用户ID")
|
||
username: str = Field(..., description="用户名")
|
||
name: str = Field(..., description="用户姓名")
|
||
avatar: str | None = Field(default=None, description="头像")
|
||
|
||
|
||
class AutoLoginTokenSchema(BaseModel):
|
||
"""免登录Token响应模型"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
token: str = Field(..., description="免登录Token")
|
||
user: AutoLoginUserSchema = Field(..., description="用户信息")
|
||
|
||
|
||
class TenantOptionSchema(BaseModel):
|
||
"""租户选项(用于登录后选择租户)"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
id: int = Field(..., description="租户ID")
|
||
name: str = Field(..., description="租户名称")
|
||
code: str = Field(..., description="租户编码")
|
||
|
||
|
||
class SelectTenantSchema(BaseModel):
|
||
"""选择租户请求"""
|
||
|
||
tenant_id: int = Field(..., gt=0, description="租户ID")
|
||
|
||
|
||
class SelectTenantOutSchema(BaseModel):
|
||
"""选择租户响应"""
|
||
|
||
model_config = ConfigDict(from_attributes=True)
|
||
|
||
access_token: str = Field(..., description="访问token(含租户上下文)")
|
||
token_type: str = Field(default="Bearer", description="token类型(RFC 6750)")
|
||
expires_in: int = Field(..., gt=0, description="过期时间(秒)")
|
||
|
||
|
||
class LoginWithTenantsSchema(JWTOutSchema):
|
||
"""登录响应(含租户列表)"""
|
||
|
||
tenants: list[TenantOptionSchema] = Field(default_factory=list, description="可选租户列表")
|
||
user_info: dict = Field(default_factory=dict, description="用户信息")
|
||
|
||
|
||
class TenantRegisterSchema(BaseModel):
|
||
"""租户自助注册请求"""
|
||
|
||
username: str = Field(..., min_length=3, max_length=32, description="登录账号")
|
||
password: str = Field(..., min_length=6, max_length=128, description="登录密码")
|
||
email: str = Field(..., max_length=128, description="邮箱(用于接收通知)")
|
||
tenant_name: str | None = Field(default=None, max_length=100, description="企业/团队名称(可选,默认:{用户名}的租户)")
|
||
|
||
|
||
class TenantRegisterOutSchema(BaseModel):
|
||
"""租户自助注册响应"""
|
||
|
||
user_id: int = Field(..., description="用户ID")
|
||
username: str = Field(..., description="账号")
|
||
tenant_id: int = Field(..., description="租户ID")
|
||
tenant_name: str = Field(..., description="租户名称")
|
||
tenant_code: str = Field(..., description="租户编码")
|
||
package: str | None = Field(default=None, description="开通套餐")
|
||
trial_end: str = Field(..., description="试用到期日")
|
||
message: str = Field(default="注册成功", description="提示信息")
|