mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 20:55:14 +00:00
refactor: 移除多租户和客户相关代码及功能
refactor: 统一状态字段为字符串类型并更新相关组件 refactor: 更新模型基类移除租户和客户相关字段 refactor: 简化数据权限控制逻辑 refactor: 优化类型注解使用Python 3.10+语法 refactor: 清理无用导入和注释 docs: 更新文档移除多租户相关内容
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Dict, List, Optional, Sequence, Union, Any
|
||||
from typing import Sequence
|
||||
|
||||
from app.core.base_crud import CRUDBase
|
||||
from app.api.v1.module_system.dict.model import DictDataModel, DictTypeModel
|
||||
@@ -21,30 +21,30 @@ class DictTypeCRUD(CRUDBase[DictTypeModel, DictTypeCreateSchema, DictTypeUpdateS
|
||||
self.auth = auth
|
||||
super().__init__(model=DictTypeModel, auth=auth)
|
||||
|
||||
async def get_obj_by_id_crud(self, id: int, preload: Optional[List[Union[str, Any]]] = None) -> Optional[DictTypeModel]:
|
||||
async def get_obj_by_id_crud(self, id: int, preload: list | None = None) -> DictTypeModel | None:
|
||||
"""
|
||||
获取数据字典类型详情
|
||||
|
||||
参数:
|
||||
- id (int): 数据字典类型ID
|
||||
- preload (Optional[List[Union[str, Any]]]): 预加载关系,未提供时使用模型默认项
|
||||
- preload (list | None): 预加载关系,未提供时使用模型默认项
|
||||
|
||||
返回:
|
||||
- Optional[DictTypeModel]: 数据字典类型模型,如果不存在则为None
|
||||
- DictTypeModel | None: 数据字典类型模型,如果不存在则为None
|
||||
"""
|
||||
# 添加默认预加载字典数据关系
|
||||
if preload is None:
|
||||
preload = []
|
||||
return await self.get(id=id, preload=preload)
|
||||
|
||||
async def get_obj_list_crud(self, search: Optional[Dict] = None, order_by: Optional[List[Dict[str, str]]] = None, preload: Optional[List[Union[str, Any]]] = None) -> Sequence[DictTypeModel]:
|
||||
async def get_obj_list_crud(self, search: dict | None = None, order_by: list[dict] | None = None, preload: list | None = None) -> Sequence[DictTypeModel]:
|
||||
"""
|
||||
获取数据字典类型列表
|
||||
|
||||
参数:
|
||||
- search (Optional[Dict]): 查询参数,默认值为None
|
||||
- order_by (Optional[List[Dict[str, str]]]): 排序参数,默认值为None
|
||||
- preload (Optional[List[Union[str, Any]]]): 预加载关系,未提供时使用模型默认项
|
||||
- search (dict | None): 查询参数,默认值为None
|
||||
- order_by (list[dict] | None): 排序参数,默认值为None
|
||||
- preload (list | None): 预加载关系,未提供时使用模型默认项
|
||||
|
||||
返回:
|
||||
- Sequence[DictTypeModel]: 数据字典类型模型序列
|
||||
@@ -54,7 +54,7 @@ class DictTypeCRUD(CRUDBase[DictTypeModel, DictTypeCreateSchema, DictTypeUpdateS
|
||||
preload = []
|
||||
return await self.list(search=search, order_by=order_by, preload=preload)
|
||||
|
||||
async def create_obj_crud(self, data: DictTypeCreateSchema) -> Optional[DictTypeModel]:
|
||||
async def create_obj_crud(self, data: DictTypeCreateSchema) -> DictTypeModel | None:
|
||||
"""
|
||||
创建数据字典类型
|
||||
|
||||
@@ -62,11 +62,11 @@ class DictTypeCRUD(CRUDBase[DictTypeModel, DictTypeCreateSchema, DictTypeUpdateS
|
||||
- data (DictTypeCreateSchema): 数据字典类型创建模型
|
||||
|
||||
返回:
|
||||
- Optional[DictTypeModel]: 创建的数据字典类型模型,如果创建失败则为None
|
||||
- DictTypeModel | None: 创建的数据字典类型模型,如果创建失败则为None
|
||||
"""
|
||||
return await self.create(data=data)
|
||||
|
||||
async def update_obj_crud(self, id: int, data: DictTypeUpdateSchema) -> Optional[DictTypeModel]:
|
||||
async def update_obj_crud(self, id: int, data: DictTypeUpdateSchema) -> DictTypeModel | None:
|
||||
"""
|
||||
更新数据字典类型
|
||||
|
||||
@@ -75,36 +75,36 @@ class DictTypeCRUD(CRUDBase[DictTypeModel, DictTypeCreateSchema, DictTypeUpdateS
|
||||
- data (DictTypeUpdateSchema): 数据字典类型更新模型
|
||||
|
||||
返回:
|
||||
- Optional[DictTypeModel]: 更新的数据字典类型模型,如果更新失败则为None
|
||||
- DictTypeModel | None: 更新的数据字典类型模型,如果更新失败则为None
|
||||
"""
|
||||
return await self.update(id=id, data=data)
|
||||
|
||||
async def delete_obj_crud(self, ids: List[int]) -> None:
|
||||
async def delete_obj_crud(self, ids: list[int]) -> None:
|
||||
"""
|
||||
删除数据字典类型
|
||||
|
||||
参数:
|
||||
- ids (List[int]): 数据字典类型ID列表
|
||||
- ids (list[int]): 数据字典类型ID列表
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
return await self.delete(ids=ids)
|
||||
|
||||
async def set_obj_available_crud(self, ids: List[int], status: str) -> None:
|
||||
async def set_obj_available_crud(self, ids: list[int], status: str) -> None:
|
||||
"""
|
||||
设置数据字典类型的可用状态
|
||||
|
||||
参数:
|
||||
- ids (List[int]): 数据字典类型ID列表
|
||||
- status (bool): 可用状态,True表示可用,False表示不可用
|
||||
- ids (list[int]): 数据字典类型ID列表
|
||||
- status (str): 可用状态,0表示正常,1表示停用
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
return await self.set(ids=ids, status=status)
|
||||
|
||||
async def batch_delete_obj_crud(self, ids: List[int]) -> int:
|
||||
async def batch_delete_obj_crud(self, ids: list[int]) -> int:
|
||||
"""
|
||||
批量删除数据字典类型
|
||||
|
||||
@@ -131,30 +131,30 @@ class DictDataCRUD(CRUDBase[DictDataModel, DictDataCreateSchema, DictDataUpdateS
|
||||
self.auth = auth
|
||||
super().__init__(model=DictDataModel, auth=auth)
|
||||
|
||||
async def get_obj_by_id_crud(self, id: int, preload: Optional[List[Union[str, Any]]] = None) -> Optional[DictDataModel]:
|
||||
async def get_obj_by_id_crud(self, id: int, preload: list | None = None) -> DictDataModel | None:
|
||||
"""
|
||||
获取数据字典数据详情
|
||||
|
||||
参数:
|
||||
- id (int): 数据字典数据ID
|
||||
- preload (Optional[List[Union[str, Any]]]): 预加载关系,未提供时使用模型默认项
|
||||
- preload (list | None): 预加载关系,未提供时使用模型默认项
|
||||
|
||||
返回:
|
||||
- Optional[DictDataModel]: 数据字典数据模型,如果不存在则为None
|
||||
- DictDataModel | None: 数据字典数据模型,如果不存在则为None
|
||||
"""
|
||||
# 添加默认预加载字典类型关系
|
||||
if preload is None:
|
||||
preload = []
|
||||
return await self.get(id=id, preload=preload)
|
||||
|
||||
async def get_obj_list_crud(self, search: Optional[Dict] = None, order_by: Optional[List[Dict[str, str]]] = None, preload: Optional[List[Union[str, Any]]] = None) -> Sequence[DictDataModel]:
|
||||
async def get_obj_list_crud(self, search: dict | None = None, order_by: list[dict] | None = None, preload: list | None = None) -> Sequence[DictDataModel]:
|
||||
"""
|
||||
获取数据字典数据列表
|
||||
|
||||
参数:
|
||||
- search (Optional[Dict]): 查询参数,默认值为None
|
||||
- order_by (Optional[List[Dict[str, str]]]): 排序参数,默认值为None
|
||||
- preload (Optional[List[Union[str, Any]]]): 预加载关系,未提供时使用模型默认项
|
||||
- search (dict | None): 查询参数,默认值为None
|
||||
- order_by (list[dict] | None): 排序参数,默认值为None
|
||||
- preload (list | None): 预加载关系,未提供时使用模型默认项
|
||||
|
||||
返回:
|
||||
- Sequence[DictDataModel]: 数据字典数据模型序列
|
||||
@@ -164,7 +164,7 @@ class DictDataCRUD(CRUDBase[DictDataModel, DictDataCreateSchema, DictDataUpdateS
|
||||
preload = []
|
||||
return await self.list(search=search, order_by=order_by, preload=preload)
|
||||
|
||||
async def create_obj_crud(self, data: DictDataCreateSchema) -> Optional[DictDataModel]:
|
||||
async def create_obj_crud(self, data: DictDataCreateSchema) -> DictDataModel | None:
|
||||
"""
|
||||
创建数据字典数据
|
||||
|
||||
@@ -172,11 +172,11 @@ class DictDataCRUD(CRUDBase[DictDataModel, DictDataCreateSchema, DictDataUpdateS
|
||||
- data (DictDataCreateSchema): 数据字典数据创建模型
|
||||
|
||||
返回:
|
||||
- Optional[DictDataModel]: 创建的数据字典数据模型,如果创建失败则为None
|
||||
- DictDataModel | None: 创建的数据字典数据模型,如果创建失败则为None
|
||||
"""
|
||||
return await self.create(data=data)
|
||||
|
||||
async def update_obj_crud(self, id: int, data: DictDataUpdateSchema) -> Optional[DictDataModel]:
|
||||
async def update_obj_crud(self, id: int, data: DictDataUpdateSchema) -> DictDataModel | None:
|
||||
"""
|
||||
更新数据字典数据
|
||||
|
||||
@@ -185,36 +185,36 @@ class DictDataCRUD(CRUDBase[DictDataModel, DictDataCreateSchema, DictDataUpdateS
|
||||
- data (DictDataUpdateSchema): 数据字典数据更新模型
|
||||
|
||||
返回:
|
||||
- Optional[DictDataModel]: 更新的数据字典数据模型,如果更新失败则为None
|
||||
- DictDataModel | None: 更新的数据字典数据模型,如果更新失败则为None
|
||||
"""
|
||||
return await self.update(id=id, data=data)
|
||||
|
||||
async def delete_obj_crud(self, ids: List[int]) -> None:
|
||||
async def delete_obj_crud(self, ids: list[int]) -> None:
|
||||
"""
|
||||
删除数据字典数据
|
||||
|
||||
参数:
|
||||
- ids (List[int]): 数据字典数据ID列表
|
||||
- ids (list[int]): 数据字典数据ID列表
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
return await self.delete(ids=ids)
|
||||
|
||||
async def set_obj_available_crud(self, ids: List[int], status: str) -> None:
|
||||
async def set_obj_available_crud(self, ids: list[int], status: str) -> None:
|
||||
"""
|
||||
设置数据字典数据的可用状态
|
||||
|
||||
参数:
|
||||
- ids (List[int]): 数据字典数据ID列表
|
||||
- status (bool): 可用状态,True表示可用,False表示不可用
|
||||
- ids (list[int]): 数据字典数据ID列表
|
||||
- status (str): 可用状态,0表示正常,1表示停用
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
return await self.set(ids=ids, status=status)
|
||||
|
||||
async def batch_delete_obj_crud(self, ids: List[int], exclude_system: bool = True) -> int:
|
||||
async def batch_delete_obj_crud(self, ids: list[int], exclude_system: bool = True) -> int:
|
||||
"""
|
||||
批量删除数据字典数据
|
||||
|
||||
@@ -239,13 +239,13 @@ class DictDataCRUD(CRUDBase[DictDataModel, DictDataCreateSchema, DictDataUpdateS
|
||||
await self.delete(ids=ids)
|
||||
return len(ids)
|
||||
|
||||
async def get_obj_list_by_dict_type_crud(self, dict_type: str, status: Optional[str] = "0") -> Sequence[DictDataModel]:
|
||||
async def get_obj_list_by_dict_type_crud(self, dict_type: str, status: str | None = "0") -> Sequence[DictDataModel]:
|
||||
"""
|
||||
根据字典类型获取字典数据列表
|
||||
|
||||
参数:
|
||||
- dict_type (str): 字典类型
|
||||
- status (Optional[str]): 状态过滤,None表示不过滤
|
||||
- status (str | None): 状态过滤,None表示不过滤
|
||||
|
||||
返回:
|
||||
- Sequence[DictDataModel]: 数据字典数据模型序列
|
||||
|
||||
Reference in New Issue
Block a user