mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-23 13:13:09 +00:00
1. 删除无用文件与废弃代码:移除locale枚举、element-plus插件、sse路由、api token模块等 2. 简化类型导入与依赖:移除大量未使用的类型导入,统一echarts导入方式 3. 优化配置与样式:调整gitignore、样式引入顺序,新增列表动画样式 4. 修复接口与模型:修正接口返回类型、查询参数配置,更新部门模型字段 5. 优化性能与体验:添加图片懒加载,优化加载逻辑与表格渲染 6. 调整环境配置:新增并更新开发/生产环境配置文件
54 lines
1.8 KiB
Python
54 lines
1.8 KiB
Python
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
|
|
from app.core.base_schema import BaseQueryParam, BaseSchema, UserByQueryParam, UserBySchema
|
|
|
|
|
|
class PositionCreateSchema(BaseModel):
|
|
"""岗位创建模型"""
|
|
|
|
name: str = Field(..., min_length=1, max_length=64, description="岗位名称")
|
|
code: str = Field(..., min_length=1, max_length=64, description="岗位编码")
|
|
order: int = Field(default=1, ge=0, description="显示排序")
|
|
status: int = Field(default=0, ge=0, le=1, description="状态(0:启动 1:停用)")
|
|
description: str | None = 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
|
|
|
|
@field_validator("code")
|
|
@classmethod
|
|
def _validate_code(cls, v: str) -> str:
|
|
v = v.strip()
|
|
if not v:
|
|
raise ValueError("岗位编码不能为空")
|
|
return v
|
|
|
|
@field_validator("status")
|
|
@classmethod
|
|
def _validate_status(cls, v: int) -> int:
|
|
if v not in {0, 1}:
|
|
raise ValueError("状态仅支持 0(正常) 或 1(禁用)")
|
|
return v
|
|
|
|
|
|
class PositionUpdateSchema(PositionCreateSchema):
|
|
"""岗位更新模型"""
|
|
|
|
|
|
class PositionOutSchema(PositionCreateSchema, BaseSchema, UserBySchema):
|
|
"""岗位信息响应模型"""
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class PositionQueryParam(BaseQueryParam, UserByQueryParam):
|
|
"""岗位管理查询参数"""
|
|
|
|
name: str | None = Field(None, description="岗位名称", json_schema_extra={"q": "like"})
|
|
status: int | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)", json_schema_extra={"q": "eq"})
|