mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 12:52:26 +00:00
refactor(api): 统一更新接口使用路径参数传递ID
refactor(backend): 重构CRUD基类查询方法去除重复结果 feat(application): 新增应用系统模块基础结构 fix(backend): 修复多处日志记录ID变量名错误 style(backend): 清理无用代码和注释 fix(frontend): 修复用户导入功能参数错误 docs(backend): 更新环境配置示例注释 perf(backend): 优化导出功能数据处理逻辑 test(frontend): 添加任务日志功能开发中提示 chore: 更新角色菜单权限数据
This commit is contained in:
@@ -51,15 +51,14 @@ class CRUDBase(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
||||
try:
|
||||
conditions = await self.__build_conditions(**kwargs)
|
||||
sql = (select(self.model)
|
||||
.where(*conditions)
|
||||
.distinct())
|
||||
.where(*conditions))
|
||||
if hasattr(self.model, "creator"):
|
||||
sql = sql.options(selectinload(self.model.creator))
|
||||
|
||||
# sql = await self.__filter_permissions(sql)
|
||||
|
||||
result: Result = await self.db.execute(sql)
|
||||
obj = result.scalars().unique().first()
|
||||
obj = result.scalars().first()
|
||||
# if not obj:
|
||||
# raise CustomException(msg="该信息不存在")
|
||||
|
||||
@@ -86,14 +85,13 @@ class CRUDBase(Generic[ModelType, CreateSchemaType, UpdateSchemaType]):
|
||||
order = order_by or [{'id': 'asc'}]
|
||||
sql = (select(self.model)
|
||||
.where(*conditions)
|
||||
.order_by(*self.__order_by(order))
|
||||
.distinct())
|
||||
.order_by(*self.__order_by(order)))
|
||||
# 预加载creator关系
|
||||
if hasattr(self.model, "creator"):
|
||||
sql = sql.options(selectinload(self.model.creator))
|
||||
sql = await self.__filter_permissions(sql)
|
||||
result: Result = await self.db.execute(sql)
|
||||
return result.scalars().unique().all()
|
||||
return result.scalars().all()
|
||||
except Exception as e:
|
||||
raise CustomException(msg=f"列表查询失败: {str(e)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user