mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-23 05:10:57 +00:00
本次提交主要包含以下变更: 1. 新增任务管理模块,支持定时任务的创建、更新、删除和状态管理 2. 新增字典管理模块,用于维护系统中常用的固定数据 3. 优化系统配置,移除Celery,改用APScheduler进行任务调度 4. 修复部分前端组件的样式问题,统一输入框宽度 5. 更新文档和相关图片资源,完善系统功能描述 这些变更旨在增强系统的可维护性和功能性,提供更灵活的任务调度机制和更便捷的字典数据管理方式。
60 lines
2.1 KiB
Python
60 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Optional, Union
|
|
from datetime import datetime
|
|
from pydantic import ConfigDict, Field, BaseModel, model_validator
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api.v1.schemas.system.user_schema import UserOutSchema
|
|
|
|
|
|
class AuthSchema(BaseModel):
|
|
"""权限认证模型"""
|
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
|
|
user: Optional[UserOutSchema] = Field(default=None, description='用户信息')
|
|
check_data_scope: bool = Field(default=True, description='是否检查数据权限')
|
|
db: AsyncSession | Session = Field(default=None, description='数据库会话')
|
|
|
|
|
|
class JWTPayloadSchema(BaseModel):
|
|
"""JWT载荷模型"""
|
|
sub: str = Field(..., description='用户ID')
|
|
is_refresh: bool = Field(default=False, description='是否刷新token')
|
|
exp: Union[datetime, int] = Field(..., description='过期时间')
|
|
|
|
@model_validator(mode='after')
|
|
def validate_fields(cls, data):
|
|
if not data.sub or len(data.sub.strip()) == 0:
|
|
raise ValueError("用户ID不能为空")
|
|
return data
|
|
|
|
|
|
class JWTOutSchema(BaseModel):
|
|
"""JWT响应模型"""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
access_token: str = Field(..., min_length=1, description='访问token')
|
|
refresh_token: str = Field(..., min_length=1, description='刷新token')
|
|
token_type: str = Field(default='Bearer', description='token类型')
|
|
expires_in: int = Field(..., gt=0, description='过期时间(秒)')
|
|
|
|
|
|
class RefreshTokenPayloadSchema(BaseModel):
|
|
"""刷新Token载荷模型"""
|
|
refresh_token: str = Field(..., min_length=1, description='刷新token')
|
|
|
|
|
|
class LogoutPayloadSchema(BaseModel):
|
|
"""退出登录载荷模型"""
|
|
token: str = Field(..., min_length=1, description='token')
|
|
|
|
|
|
class CaptchaOutSchema(BaseModel):
|
|
"""验证码响应模型"""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
key: str = Field(..., min_length=1, description='验证码唯一标识')
|
|
img_base: str = Field(..., min_length=1, description='Base64编码的验证码图片')
|