mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 12:52:26 +00:00
refactor: 完成系统架构升级与模块拆分
本次提交进行了大规模的系统重构: 1. 拆分租户相关模块到platform平台层,重构租户表名与关联关系 2. 迁移日志、工单、插件等模块到对应层级,统一代码结构 3. 重构批量操作接口路径,从/available/setting改为/status/batch 4. 新增批量删除基础模型,统一处理批量操作逻辑 5. 优化导入导出接口,修正路由方法与描述信息 6. 修复循环引用问题,重构依赖注入与类型导入 7. 更新初始化脚本与路由注册,新增平台管理路由 8. 重构岗位模型,新增岗位编码字段与校验 9. 完善部门删除逻辑,新增子部门删除限制 10. 更新初始化数据与配置文件,适配新架构
This commit is contained in:
@@ -162,7 +162,7 @@ async def delete_obj_controller(
|
||||
|
||||
|
||||
@DeptRouter.patch(
|
||||
"/available/setting",
|
||||
"/status/batch",
|
||||
summary="批量修改部门状态",
|
||||
description="批量修改部门状态",
|
||||
response_model=ResponseSchema[None],
|
||||
|
||||
@@ -93,7 +93,7 @@ class DeptService:
|
||||
raise CustomException(msg="创建失败,编码已存在")
|
||||
|
||||
# 检查租户配额
|
||||
from app.api.v1.module_system.tenant.service import TenantService
|
||||
from app.api.v1.module_platform.tenant.service import TenantService
|
||||
await TenantService.check_quota_service(auth, auth.tenant_id, "dept")
|
||||
|
||||
dept = await DeptCRUD(auth).create(data=data)
|
||||
@@ -141,6 +141,7 @@ class DeptService:
|
||||
|
||||
异常:
|
||||
- CustomException: 当删除对象为空时抛出。
|
||||
- CustomException: 当存在子部门时抛出。
|
||||
"""
|
||||
if len(ids) < 1:
|
||||
raise CustomException(msg="删除失败,删除对象不能为空")
|
||||
@@ -151,19 +152,13 @@ class DeptService:
|
||||
# 构建子部门ID映射
|
||||
child_id_map = get_child_id_map(model_list=all_depts)
|
||||
|
||||
# 收集所有需要删除的部门ID,包括直接指定的ID和它们的所有子部门ID
|
||||
delete_ids_set = set()
|
||||
|
||||
for id in ids:
|
||||
# 递归获取该ID的所有子部门ID
|
||||
all_descendants = get_child_recursion(id=id, id_map=child_id_map)
|
||||
delete_ids_set.update(all_descendants)
|
||||
|
||||
# 将集合转换为列表
|
||||
delete_ids = list(delete_ids_set)
|
||||
# 检查是否有子部门
|
||||
if id in child_id_map and child_id_map[id]:
|
||||
raise CustomException(msg="存在子部门,不允许删除父部门")
|
||||
|
||||
# 执行批量删除操作
|
||||
await DeptCRUD(auth).delete(ids=delete_ids)
|
||||
await DeptCRUD(auth).delete(ids=ids)
|
||||
|
||||
@classmethod
|
||||
async def batch_set_available_service(cls, auth: AuthSchema, data: BatchSetAvailable) -> None:
|
||||
|
||||
Reference in New Issue
Block a user