mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
refactor: 重构服务层方法命名规范
fix: 修复文件下载和删除功能 fix: 修复Redis哈希获取方法返回值类型 fix: 修复权限检查逻辑 perf: 优化部门和服务详情查询性能 perf: 优化角色数据范围显示 style: 清理无用导入和注释 style: 统一CRUD方法命名 docs: 更新main.py中的命令说明 chore: 移动IP定位工具类位置 chore: 更新.gitignore忽略迁移版本文件
This commit is contained in:
@@ -284,27 +284,6 @@ class CRUDBase(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
||||
except Exception as e:
|
||||
raise CustomException(msg=f"批量更新失败: {str(e)}")
|
||||
|
||||
async def update_relationships(self, objs_to_update: List[ModelType], relationship_field: str, related_objs: List[ModelType]) -> None:
|
||||
"""
|
||||
更新对象关系
|
||||
|
||||
Args:
|
||||
objs_to_update: 需要更新关系的对象列表
|
||||
relationship_field: 关系字段名称
|
||||
related_objs: 关联对象列表
|
||||
|
||||
Raises:
|
||||
CustomException: 更新关系失败时抛出异常
|
||||
"""
|
||||
try:
|
||||
for obj in objs_to_update:
|
||||
relationship = getattr(obj, relationship_field)
|
||||
relationship.clear()
|
||||
relationship.extend(related_objs)
|
||||
await self.db.flush()
|
||||
except Exception as e:
|
||||
raise CustomException(msg=f"更新关系失败: {str(e)}")
|
||||
|
||||
async def __filter_permissions(self, sql: Select) -> Select:
|
||||
"""过滤数据权限"""
|
||||
# 如果不需要检查数据权限,则直接返回
|
||||
|
||||
Reference in New Issue
Block a user