Files
FastapiAdmin/backend/app/api/v1/module_system/dept/schema.py
T
zhangtao e159b31e62 feat: Add role code to system_role.json and update system_users.json creator_id to null
fix: Refactor initialize.py to handle nested children data during initialization

feat: Implement tree structure traversal functions in common_util.py

chore: Update requirements.txt to specify sqlalchemy-crud-plus version and add rich

refactor: Change API endpoints in dept.ts and menu.ts to return tree structure

feat: Add code field to role, dept, and menu interfaces in respective TypeScript files

fix: Update dept and role Vue components to display and handle code field

docs: Add comprehensive project documentation for FastAPI Vue3 Admin
2025-09-15 00:19:11 +08:00

37 lines
1.3 KiB
Python

# -*- coding: utf-8 -*-
from typing import Optional, List
from pydantic import BaseModel, ConfigDict, Field, field_validator
from app.core.base_schema import BaseSchema
class DeptCreateSchema(BaseModel):
"""部门创建模型"""
name: str = Field(..., max_length=40, description="部门名称")
order: int = Field(default=1, ge=0, description="显示顺序")
code: Optional[str] = Field(default=None, max_length=60, description="部门编码")
status: bool = Field(default=True, description="是否启用(True:启用 False:禁用)")
parent_id: Optional[int] = Field(default=None, ge=0, description="父部门ID")
description: Optional[str] = Field(default=None, max_length=255, description="备注说明")
@field_validator('name')
@classmethod
def validate_name(cls, value: str):
if not value or len(value.strip()) == 0:
raise ValueError("部门名称不能为空")
value = value.replace(" ", "")
return value
class DeptUpdateSchema(DeptCreateSchema):
"""部门更新模型"""
...
class DeptOutSchema(DeptCreateSchema, BaseSchema):
"""部门响应模型"""
model_config = ConfigDict(from_attributes=True)
parent_name: Optional[str] = Field(default=None, max_length=40, description="父部门名称")