179 lines
6.4 KiB
Python
179 lines
6.4 KiB
Python
|
# _*_ coding : UTF-8 _*_
|
|||
|
# @Time : 2025/01/19 02:19
|
|||
|
# @UpdateTime : 2025/01/19 02:19
|
|||
|
# @Author : sonder
|
|||
|
# @File : department.py
|
|||
|
# @Software : PyCharm
|
|||
|
# @Comment : 本程序
|
|||
|
from datetime import datetime
|
|||
|
from typing import Optional, List
|
|||
|
|
|||
|
from pydantic import BaseModel, Field
|
|||
|
|
|||
|
from schemas.common import BaseResponse, ListQueryResult
|
|||
|
|
|||
|
|
|||
|
class DepartmentInfo(BaseModel):
|
|||
|
"""
|
|||
|
部门表基础模型。
|
|||
|
"""
|
|||
|
id: str = Field(..., description="主键")
|
|||
|
create_by: str = Field(default="", description="创建者")
|
|||
|
create_time: Optional[datetime] = Field(default=None, description="创建时间")
|
|||
|
update_by: str = Field(default="", description="更新者")
|
|||
|
update_time: Optional[datetime] = Field(default=None, description="更新时间")
|
|||
|
name: str = Field(..., max_length=100, description="部门名称")
|
|||
|
parent_id: Optional[str] = Field(default=None, max_length=36, description="父部门ID")
|
|||
|
sort: int = Field(default=0, description="排序权重(0最高)")
|
|||
|
phone: Optional[str] = Field(default=None, max_length=30, description="部门电话")
|
|||
|
principal: str = Field(..., max_length=64, description="部门负责人")
|
|||
|
email: Optional[str] = Field(default=None, max_length=128, description="部门邮箱")
|
|||
|
remark: Optional[str] = Field(default=None, max_length=255, description="备注信息")
|
|||
|
status: Optional[int] = Field(default=None, description="状态")
|
|||
|
|
|||
|
class Config:
|
|||
|
json_schema_extra = {
|
|||
|
"example": {
|
|||
|
"id": "550e8400-e29b-41d4-a716-446655440000",
|
|||
|
"create_by": "admin",
|
|||
|
"create_time": "2023-10-01T12:00:00",
|
|||
|
"update_by": "admin",
|
|||
|
"update_time": "2023-10-01T12:00:00",
|
|||
|
"name": "研发部",
|
|||
|
"parent_id": "",
|
|||
|
"sort": 0,
|
|||
|
"phone": "1234567890",
|
|||
|
"principal": "张三",
|
|||
|
"email": "dev@example.com",
|
|||
|
"remark": "研发部门",
|
|||
|
"status": 1
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
class GetDepartmentInfoResponse(BaseResponse):
|
|||
|
"""
|
|||
|
获取部门信息响应模型。
|
|||
|
"""
|
|||
|
data: DepartmentInfo = Field(default=None, description="响应数据")
|
|||
|
|
|||
|
|
|||
|
class AddDepartmentParams(BaseModel):
|
|||
|
"""
|
|||
|
添加部门参数模型。
|
|||
|
"""
|
|||
|
name: str = Field(..., max_length=100, description="部门名称")
|
|||
|
parent_id: Optional[str] = Field(default=None, max_length=36, description="父部门ID")
|
|||
|
sort: int = Field(default=0, description="排序权重(0最高)")
|
|||
|
phone: Optional[str] = Field(default=None, max_length=30, description="部门电话")
|
|||
|
principal: str = Field(..., max_length=64, description="部门负责人")
|
|||
|
email: Optional[str] = Field(default=None, max_length=128, description="部门邮箱")
|
|||
|
remark: Optional[str] = Field(default=None, max_length=255, description="备注信息")
|
|||
|
status: Optional[int] = Field(default=None, description="状态")
|
|||
|
|
|||
|
class Config:
|
|||
|
json_schema_extra = {
|
|||
|
"example": {
|
|||
|
"name": "研发部",
|
|||
|
"parent_id": "",
|
|||
|
"sort": 0,
|
|||
|
"phone": "1234567890",
|
|||
|
"principal": "张三",
|
|||
|
"email": "dev@example.com",
|
|||
|
"remark": "研发部门",
|
|||
|
"status": 1
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
class DeleteDepartmentListParams(BaseModel):
|
|||
|
"""
|
|||
|
删除部门参数模型。
|
|||
|
"""
|
|||
|
ids: List[str] = Field(..., description="部门ID列表")
|
|||
|
|
|||
|
|
|||
|
class GetDepartmentListResult(ListQueryResult):
|
|||
|
"""
|
|||
|
获取部门列表结果模型。
|
|||
|
"""
|
|||
|
result: List[DepartmentInfo] = Field(default=[], description="部门列表")
|
|||
|
|
|||
|
|
|||
|
class GetDepartmentListResponse(BaseResponse):
|
|||
|
"""
|
|||
|
获取部门列表响应模型。
|
|||
|
"""
|
|||
|
data: GetDepartmentListResult = Field(default=None, description="响应数据")
|
|||
|
|
|||
|
|
|||
|
class AddDepartmentRoleParams(BaseModel):
|
|||
|
"""
|
|||
|
添加部门角色参数模型。
|
|||
|
"""
|
|||
|
department_id: str = Field(..., max_length=36, description="部门ID")
|
|||
|
role_id: str = Field(..., max_length=36, description="角色ID")
|
|||
|
|
|||
|
class Config:
|
|||
|
json_schema_extra = {
|
|||
|
"example": {
|
|||
|
"department_id": "550e8400-e29b-41d4-a716-446655440000",
|
|||
|
"role_id": "550e8400-e29b-41d4-a716-446655440000"
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
class DepartmentRoleInfo(BaseModel):
|
|||
|
"""
|
|||
|
部门角色信息模型。
|
|||
|
"""
|
|||
|
id: str = Field(..., max_length=36, description="主键ID")
|
|||
|
department_id: str = Field(..., max_length=36, description="部门ID")
|
|||
|
department_name: str = Field(..., max_length=100, description="部门名称")
|
|||
|
department_phone: str = Field(..., max_length=30, description="部门电话")
|
|||
|
department_principal: str = Field(..., max_length=64, description="部门负责人")
|
|||
|
department_email: str = Field(..., max_length=128, description="部门邮箱")
|
|||
|
role_name: str = Field(..., max_length=100, description="角色名称")
|
|||
|
role_code: str = Field(..., max_length=100, description="角色编码")
|
|||
|
role_id: str = Field(..., max_length=36, description="角色ID")
|
|||
|
create_time: datetime = Field(..., description="创建时间")
|
|||
|
update_time: datetime = Field(..., description="更新时间")
|
|||
|
|
|||
|
class Config:
|
|||
|
json_schema_extra = {
|
|||
|
"example": {
|
|||
|
"id": "550e8400-e29b-41d4-a716-446655440000",
|
|||
|
"department_id": "550e8400-e29b-41d4-a716-446655440000",
|
|||
|
"department_name": "研发部",
|
|||
|
"department_phone": "1234567890",
|
|||
|
"department_principal": "张三",
|
|||
|
"department_email": "dev@example.com",
|
|||
|
"role_name": "管理员",
|
|||
|
"role_code": "admin",
|
|||
|
"role_id": "550e8400-e29b-41d4-a716-446655440000",
|
|||
|
"create_time": "2023-10-01T12:00:00",
|
|||
|
"update_time": "2023-10-01T12:00:00"
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
class GetDepartmentRoleInfoResponse(BaseResponse):
|
|||
|
"""
|
|||
|
获取部门角色信息响应模型。
|
|||
|
"""
|
|||
|
data: DepartmentRoleInfo = Field(default=None, description="响应数据")
|
|||
|
|
|||
|
|
|||
|
class GetDepartmentRoleListResult(ListQueryResult):
|
|||
|
"""
|
|||
|
获取部门角色列表结果模型。
|
|||
|
"""
|
|||
|
result: List[DepartmentRoleInfo] = Field(default=[], description="部门角色列表")
|
|||
|
|
|||
|
|
|||
|
class GetDepartmentRoleListResponse(BaseResponse):
|
|||
|
"""
|
|||
|
获取部门角色列表响应模型。
|
|||
|
"""
|
|||
|
data: GetDepartmentRoleListResult = Field(default=None, description="响应数据")
|