mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-27 14:52:56 +00:00
refactor(backend): 重构CRUD基类查询方法去除重复结果 feat(application): 新增应用系统模块基础结构 fix(backend): 修复多处日志记录ID变量名错误 style(backend): 清理无用代码和注释 fix(frontend): 修复用户导入功能参数错误 docs(backend): 更新环境配置示例注释 perf(backend): 优化导出功能数据处理逻辑 test(frontend): 添加任务日志功能开发中提示 chore: 更新角色菜单权限数据
41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Dict, List, Optional, Sequence
|
|
|
|
from app.core.base_crud import CRUDBase
|
|
from app.api.v1.module_system.auth.schema import AuthSchema
|
|
from .model import ApplicationModel
|
|
from .schema import ApplicationCreateSchema, ApplicationUpdateSchema
|
|
|
|
|
|
class ApplicationCRUD(CRUDBase[ApplicationModel, ApplicationCreateSchema, ApplicationUpdateSchema]):
|
|
"""应用系统数据层"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
"""初始化CRUD"""
|
|
self.auth = auth
|
|
super().__init__(model=ApplicationModel, auth=auth)
|
|
|
|
async def get_by_id_crud(self, id: int) -> Optional[ApplicationModel]:
|
|
"""获取应用详情"""
|
|
return await self.get(id=id)
|
|
|
|
async def get_list_crud(self, search: Dict = None, order_by: List[Dict[str, str]] = None) -> Sequence[ApplicationModel]:
|
|
"""列表查询"""
|
|
return await self.list(search=search, order_by=order_by)
|
|
|
|
async def create_crud(self, data: ApplicationCreateSchema) -> Optional[ApplicationModel]:
|
|
"""创建应用"""
|
|
return await self.create(data=data)
|
|
|
|
async def update_crud(self, id: int, data: ApplicationUpdateSchema) -> Optional[ApplicationModel]:
|
|
"""更新应用"""
|
|
return await self.update(id=id, data=data)
|
|
|
|
async def delete_crud(self, ids: List[int]) -> None:
|
|
"""批量删除应用"""
|
|
return await self.delete(ids=ids)
|
|
|
|
async def set_available_crud(self, ids: List[int], status: bool) -> None:
|
|
"""批量设置可用状态"""
|
|
return await self.set(ids=ids, status=status) |