mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-23 05:10:57 +00:00
refactor(application): 重构应用模块为门户应用,支持租户隔离 feat(portal): 添加门户应用管理功能 perf(health): 新增就绪探针检查,优化健康检查接口 fix(middleware): 修复请求日志中间件的异常处理 style(menu): 调整菜单表格列顺序,优化展示效果 style(table): 优化表格内操作按钮的焦点样式 docs: 更新README文档,修正智能体框架描述 chore(deps): 移除langchain相关依赖,更新项目依赖 test: 添加多租户相关测试用例 ci: 更新CI配置,支持多租户测试环境 build: 更新构建配置,支持租户插件
107 lines
3.1 KiB
Python
107 lines
3.1 KiB
Python
from collections.abc import Sequence
|
|
from typing import Any
|
|
|
|
from app.api.v1.module_system.auth.schema import AuthSchema
|
|
from app.core.base_crud import CRUDBase
|
|
|
|
from .model import ApplicationModel
|
|
from .schema import ApplicationCreateSchema, ApplicationUpdateSchema
|
|
|
|
|
|
class ApplicationCRUD(CRUDBase[ApplicationModel, ApplicationCreateSchema, ApplicationUpdateSchema]):
|
|
"""应用系统数据层"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
"""
|
|
初始化应用CRUD
|
|
|
|
参数:
|
|
- auth (AuthSchema): 认证信息模型
|
|
"""
|
|
self.auth = auth
|
|
super().__init__(model=ApplicationModel, auth=auth)
|
|
|
|
async def get_by_id_crud(
|
|
self, id: int, preload: list[str | Any] | None = None
|
|
) -> ApplicationModel | None:
|
|
"""
|
|
根据id获取应用详情
|
|
|
|
参数:
|
|
- id (int): 应用ID
|
|
- preload (list[str | Any] | None): 预加载关系,未提供时使用模型默认项
|
|
|
|
返回:
|
|
- ApplicationModel | None: 应用详情,如果不存在则为None
|
|
"""
|
|
return await self.get(id=id, preload=preload)
|
|
|
|
async def list_crud(
|
|
self,
|
|
search: dict[str, Any] | None = None,
|
|
order_by: list[dict[str, str]] | None = None,
|
|
preload: list[str | Any] | None = None,
|
|
) -> Sequence[ApplicationModel]:
|
|
"""
|
|
列表查询应用
|
|
|
|
参数:
|
|
- search (dict[str, Any] | None): 查询参数,默认None
|
|
- order_by (list[dict[str, str]] | None): 排序参数,默认None
|
|
- preload (list[str | Any] | None): 预加载关系,未提供时使用模型默认项
|
|
|
|
返回:
|
|
- Sequence[ApplicationModel]: 应用列表
|
|
"""
|
|
return await self.list(search=search, order_by=order_by, preload=preload)
|
|
|
|
async def create_crud(self, data: ApplicationCreateSchema) -> ApplicationModel | None:
|
|
"""
|
|
创建应用
|
|
|
|
参数:
|
|
- data (ApplicationCreateSchema): 应用创建模型
|
|
|
|
返回:
|
|
- ApplicationModel | None: 创建的应用详情,如果创建失败则为None
|
|
"""
|
|
return await self.create(data=data)
|
|
|
|
async def update_crud(self, id: int, data: ApplicationUpdateSchema) -> ApplicationModel | None:
|
|
"""
|
|
更新应用
|
|
|
|
参数:
|
|
- id (int): 应用ID
|
|
- data (ApplicationUpdateSchema): 应用更新模型
|
|
|
|
返回:
|
|
- ApplicationModel | None: 更新后的应用详情,如果更新失败则为None
|
|
"""
|
|
return await self.update(id=id, data=data)
|
|
|
|
async def delete_crud(self, ids: list[int]) -> None:
|
|
"""
|
|
批量删除应用
|
|
|
|
参数:
|
|
- ids (list[int]): 应用ID列表
|
|
|
|
返回:
|
|
- None
|
|
"""
|
|
return await self.delete(ids=ids)
|
|
|
|
async def set_available_crud(self, ids: list[int], status: str) -> None:
|
|
"""
|
|
批量设置可用状态
|
|
|
|
参数:
|
|
- ids (list[int]): 应用ID列表
|
|
- status (str): 可用状态,True为可用,False为不可用
|
|
|
|
返回:
|
|
- None
|
|
"""
|
|
return await self.set(ids=ids, status=status)
|