mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02:57 +00:00
refactor: 重构数据库连接模块,提高可维护性 docs: 更新README.md项目描述 style: 调整日志输出格式和内容 refactor: 优化中间件日志记录逻辑 style: 统一代码中的空行和导入顺序 refactor: 分离数据库引擎和会话创建逻辑 style: 清理未使用的导入和代码 refactor: 重命名数据库会话变量 style: 调整jinja2模板变量命名 refactor: 优化异常处理和日志记录 style: 统一字符串格式化方式 refactor: 优化redis连接错误处理 style: 调整注释格式和位置 refactor: 优化数据库连接配置 style: 清理多余空行和注释
34 lines
1017 B
Python
34 lines
1017 B
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Optional
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
from app.core.base_schema import BaseSchema
|
|
|
|
|
|
class PositionCreateSchema(BaseModel):
|
|
"""岗位创建模型"""
|
|
name: str = Field(..., max_length=40, description="岗位名称")
|
|
order: Optional[int] = Field(default=1, ge=1, description='显示排序')
|
|
status: bool = Field(default=True, description="是否启用(True:启用 False:禁用)")
|
|
description: Optional[str] = Field(default=None, max_length=255, description="描述")
|
|
|
|
@field_validator('name')
|
|
@classmethod
|
|
def _validate_name(cls, v: str) -> str:
|
|
v = v.strip()
|
|
if not v:
|
|
raise ValueError('岗位名称不能为空')
|
|
return v
|
|
|
|
|
|
class PositionUpdateSchema(PositionCreateSchema):
|
|
"""岗位更新模型"""
|
|
...
|
|
|
|
|
|
class PositionOutSchema(PositionCreateSchema, BaseSchema):
|
|
"""岗位信息响应模型"""
|
|
model_config = ConfigDict(from_attributes=True)
|
|
...
|