mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02:57 +00:00
style: 移除Python文件中的编码声明并优化代码格式
refactor: 重构前端组件和样式,添加AI助手功能 docs: 更新README文档,添加ruff代码检查说明 feat: 新增AI助手相关API和前端组件 chore: 更新.gitignore文件,添加ruff缓存配置 fix: 修复前端布局和设置相关的问题 perf: 优化代码结构和性能,移除冗余代码 test: 更新测试文件,移除编码声明 build: 更新依赖版本,调整requirements.txt
This commit is contained in:
@@ -1,2 +1 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
@@ -1,44 +1,38 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, Path
|
||||
from fastapi.responses import JSONResponse, StreamingResponse
|
||||
|
||||
from app.common.response import StreamResponse, SuccessResponse
|
||||
from app.api.v1.module_system.auth.schema import AuthSchema
|
||||
from app.common.request import PaginationService
|
||||
from app.common.response import StreamResponse, SuccessResponse
|
||||
from app.core.base_params import PaginationQueryParam
|
||||
from app.core.base_schema import BatchSetAvailable
|
||||
from app.core.dependencies import AuthPermission
|
||||
from app.core.logger import log
|
||||
from app.core.router_class import OperationLogRoute
|
||||
from app.utils.common_util import bytes2file_response
|
||||
from app.core.base_params import PaginationQueryParam
|
||||
from app.core.dependencies import AuthPermission
|
||||
from app.core.base_schema import BatchSetAvailable
|
||||
from app.core.logger import log
|
||||
|
||||
from ..auth.schema import AuthSchema
|
||||
from .schema import RoleCreateSchema, RolePermissionSettingSchema, RoleQueryParam, RoleUpdateSchema
|
||||
from .service import RoleService
|
||||
from .schema import (
|
||||
RoleCreateSchema,
|
||||
RoleUpdateSchema,
|
||||
RolePermissionSettingSchema,
|
||||
RoleQueryParam
|
||||
)
|
||||
|
||||
|
||||
RoleRouter = APIRouter(route_class=OperationLogRoute, prefix="/role", tags=["角色管理"])
|
||||
|
||||
|
||||
@RoleRouter.get("/list", summary="查询角色", description="查询角色")
|
||||
async def get_obj_list_controller(
|
||||
page: PaginationQueryParam = Depends(),
|
||||
search: RoleQueryParam = Depends(),
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:query"])),
|
||||
page: Annotated[PaginationQueryParam, Depends()],
|
||||
search: Annotated[RoleQueryParam, Depends()],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:query"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
查询角色
|
||||
|
||||
|
||||
参数:
|
||||
- page (PaginationQueryParam): 分页查询参数模型
|
||||
- search (RoleQueryParam): 查询参数模型
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 分页查询结果JSON响应
|
||||
"""
|
||||
@@ -46,23 +40,23 @@ async def get_obj_list_controller(
|
||||
if page.order_by:
|
||||
order_by = page.order_by
|
||||
result_dict_list = await RoleService.get_role_list_service(search=search, auth=auth, order_by=order_by)
|
||||
result_dict = await PaginationService.paginate(data_list= result_dict_list, page_no= page.page_no, page_size = page.page_size)
|
||||
log.info(f"查询角色成功")
|
||||
result_dict = await PaginationService.paginate(data_list=result_dict_list, page_no=page.page_no, page_size=page.page_size)
|
||||
log.info("查询角色成功")
|
||||
return SuccessResponse(data=result_dict, msg="查询角色成功")
|
||||
|
||||
|
||||
@RoleRouter.get("/detail/{id}", summary="查询角色详情", description="查询角色详情")
|
||||
async def get_obj_detail_controller(
|
||||
id: int = Path(..., description="角色ID"),
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:detail"])),
|
||||
id: Annotated[int, Path(description="角色ID")],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:detail"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
查询角色详情
|
||||
|
||||
|
||||
参数:
|
||||
- id (int): 角色ID
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 角色详情JSON响应
|
||||
"""
|
||||
@@ -74,15 +68,15 @@ async def get_obj_detail_controller(
|
||||
@RoleRouter.post("/create", summary="创建角色", description="创建角色")
|
||||
async def create_obj_controller(
|
||||
data: RoleCreateSchema,
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:create"])),
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:create"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
创建角色
|
||||
|
||||
|
||||
参数:
|
||||
- data (RoleCreateSchema): 创建角色模型
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 创建角色JSON响应
|
||||
"""
|
||||
@@ -94,17 +88,17 @@ async def create_obj_controller(
|
||||
@RoleRouter.put("/update/{id}", summary="修改角色", description="修改角色")
|
||||
async def update_obj_controller(
|
||||
data: RoleUpdateSchema,
|
||||
id: int = Path(..., description="角色ID"),
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:update"])),
|
||||
id: Annotated[int, Path(description="角色ID")],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:update"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
修改角色
|
||||
|
||||
|
||||
参数:
|
||||
- data (RoleUpdateSchema): 修改角色模型
|
||||
- id (int): 角色ID
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 修改角色JSON响应
|
||||
"""
|
||||
@@ -115,16 +109,16 @@ async def update_obj_controller(
|
||||
|
||||
@RoleRouter.delete("/delete", summary="删除角色", description="删除角色")
|
||||
async def delete_obj_controller(
|
||||
ids: list[int] = Body(..., description="ID列表"),
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:delete"])),
|
||||
ids: Annotated[list[int], Body(description="ID列表")],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:delete"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
删除角色
|
||||
|
||||
|
||||
参数:
|
||||
- ids (list[int]): ID列表
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 删除角色JSON响应
|
||||
"""
|
||||
@@ -136,15 +130,15 @@ async def delete_obj_controller(
|
||||
@RoleRouter.patch("/available/setting", summary="批量修改角色状态", description="批量修改角色状态")
|
||||
async def batch_set_available_obj_controller(
|
||||
data: BatchSetAvailable,
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:patch"])),
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:patch"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
批量修改角色状态
|
||||
|
||||
|
||||
参数:
|
||||
- data (BatchSetAvailable): 批量修改角色状态模型
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 批量修改角色状态JSON响应
|
||||
"""
|
||||
@@ -156,15 +150,15 @@ async def batch_set_available_obj_controller(
|
||||
@RoleRouter.patch("/permission/setting", summary="角色授权", description="角色授权")
|
||||
async def set_role_permission_controller(
|
||||
data: RolePermissionSettingSchema,
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:permission"])),
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:permission"]))],
|
||||
) -> JSONResponse:
|
||||
"""
|
||||
角色授权
|
||||
|
||||
|
||||
参数:
|
||||
- data (RolePermissionSettingSchema): 角色授权模型
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- JSONResponse: 角色授权JSON响应
|
||||
"""
|
||||
@@ -175,16 +169,16 @@ async def set_role_permission_controller(
|
||||
|
||||
@RoleRouter.post('/export', summary="导出角色", description="导出角色")
|
||||
async def export_obj_list_controller(
|
||||
search: RoleQueryParam = Depends(),
|
||||
auth: AuthSchema = Depends(AuthPermission(["module_system:role:export"])),
|
||||
search: Annotated[RoleQueryParam, Depends()],
|
||||
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:role:export"]))],
|
||||
) -> StreamingResponse:
|
||||
"""
|
||||
导出角色
|
||||
|
||||
|
||||
参数:
|
||||
- search (RoleQueryParam): 查询参数模型
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
|
||||
|
||||
返回:
|
||||
- StreamingResponse: 导出角色流响应
|
||||
"""
|
||||
@@ -195,7 +189,7 @@ async def export_obj_list_controller(
|
||||
return StreamResponse(
|
||||
data=bytes2file_response(role_export_result),
|
||||
media_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
headers = {
|
||||
headers={
|
||||
'Content-Disposition': 'attachment; filename=role.xlsx'
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Sequence
|
||||
from collections.abc import Sequence
|
||||
|
||||
from app.api.v1.module_system.auth.schema import AuthSchema
|
||||
from app.api.v1.module_system.dept.crud import DeptCRUD
|
||||
from app.api.v1.module_system.menu.crud import MenuCRUD
|
||||
from app.core.base_crud import CRUDBase
|
||||
|
||||
from .model import RoleModel
|
||||
from .schema import RoleCreateSchema, RoleUpdateSchema
|
||||
from ..auth.schema import AuthSchema
|
||||
from ..menu.crud import MenuCRUD
|
||||
from ..dept.crud import DeptCRUD
|
||||
|
||||
|
||||
class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
@@ -17,7 +15,7 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
def __init__(self, auth: AuthSchema) -> None:
|
||||
"""
|
||||
初始化角色模块数据层
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
"""
|
||||
@@ -27,11 +25,11 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
async def get_by_id_crud(self, id: int, preload: list | None = None) -> RoleModel | None:
|
||||
"""
|
||||
根据id获取角色信息
|
||||
|
||||
|
||||
参数:
|
||||
- id (int): 角色ID
|
||||
- preload (list | None): 预加载选项
|
||||
|
||||
|
||||
返回:
|
||||
- RoleModel | None: 角色模型对象
|
||||
"""
|
||||
@@ -40,12 +38,12 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
async def get_list_crud(self, search: dict | None = None, order_by: list | None = None, preload: list | None = None) -> Sequence[RoleModel]:
|
||||
"""
|
||||
获取角色列表
|
||||
|
||||
|
||||
参数:
|
||||
- search (dict | None): 查询参数
|
||||
- order_by (list | None): 排序参数
|
||||
- preload (list | None): 预加载选项
|
||||
|
||||
|
||||
返回:
|
||||
- Sequence[RoleModel]: 角色模型对象列表
|
||||
"""
|
||||
@@ -54,7 +52,7 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
async def set_role_menus_crud(self, role_ids: list[int], menu_ids: list[int]) -> None:
|
||||
"""
|
||||
设置角色的菜单权限
|
||||
|
||||
|
||||
参数:
|
||||
- role_ids (List[int]): 角色ID列表
|
||||
- menu_ids (List[int]): 菜单ID列表
|
||||
@@ -74,11 +72,11 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
async def set_role_data_scope_crud(self, role_ids: list[int], data_scope: int) -> None:
|
||||
"""
|
||||
设置角色的数据范围
|
||||
|
||||
|
||||
参数:
|
||||
- role_ids (list[int]): 角色ID列表
|
||||
- data_scope (int): 数据范围
|
||||
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
@@ -87,11 +85,11 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
async def set_role_depts_crud(self, role_ids: list[int], dept_ids: list[int]) -> None:
|
||||
"""
|
||||
设置角色的部门权限
|
||||
|
||||
|
||||
参数:
|
||||
- role_ids (list[int]): 角色ID列表
|
||||
- dept_ids (list[int]): 部门ID列表
|
||||
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
@@ -107,12 +105,12 @@ class RoleCRUD(CRUDBase[RoleModel, RoleCreateSchema, RoleUpdateSchema]):
|
||||
async def set_available_crud(self, ids: list[int], status: str) -> None:
|
||||
"""
|
||||
设置角色的可用状态
|
||||
|
||||
|
||||
参数:
|
||||
- ids (list[int]): 角色ID列表
|
||||
- status (str): 可用状态
|
||||
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
await self.set(ids=ids, status=status)
|
||||
await self.set(ids=ids, status=status)
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import String, Integer, ForeignKey
|
||||
from sqlalchemy.orm import relationship, Mapped, mapped_column
|
||||
|
||||
from sqlalchemy import ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.core.base_model import MappedBase, ModelMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from app.api.v1.module_system.menu.model import MenuModel
|
||||
from app.api.v1.module_system.dept.model import DeptModel
|
||||
from app.api.v1.module_system.menu.model import MenuModel
|
||||
from app.api.v1.module_system.user.model import UserModel
|
||||
|
||||
|
||||
class RoleMenusModel(MappedBase):
|
||||
"""
|
||||
角色菜单关联表
|
||||
|
||||
|
||||
定义角色与菜单的多对多关系,用于权限控制
|
||||
"""
|
||||
__tablename__: str = "sys_role_menus"
|
||||
@@ -38,7 +37,7 @@ class RoleMenusModel(MappedBase):
|
||||
class RoleDeptsModel(MappedBase):
|
||||
"""
|
||||
角色部门关联表
|
||||
|
||||
|
||||
定义角色与部门的多对多关系,用于数据权限控制
|
||||
仅当角色的data_scope=5(自定义数据权限)时使用此表
|
||||
"""
|
||||
@@ -71,21 +70,21 @@ class RoleModel(ModelMixin):
|
||||
code: Mapped[str | None] = mapped_column(String(16), nullable=True, index=True, comment="角色编码")
|
||||
order: Mapped[int] = mapped_column(Integer, nullable=False, default=999, comment="显示排序")
|
||||
data_scope: Mapped[int] = mapped_column(Integer, default=1, nullable=False, comment="数据权限范围(1:仅本人 2:本部门 3:本部门及以下 4:全部 5:自定义)")
|
||||
|
||||
|
||||
# 关联关系 (继承自UserMixin)
|
||||
menus: Mapped[list["MenuModel"]] = relationship(
|
||||
secondary="sys_role_menus",
|
||||
back_populates="roles",
|
||||
lazy="selectin",
|
||||
secondary="sys_role_menus",
|
||||
back_populates="roles",
|
||||
lazy="selectin",
|
||||
order_by="MenuModel.order"
|
||||
)
|
||||
depts: Mapped[list["DeptModel"]] = relationship(
|
||||
secondary="sys_role_depts",
|
||||
back_populates="roles",
|
||||
secondary="sys_role_depts",
|
||||
back_populates="roles",
|
||||
lazy="selectin"
|
||||
)
|
||||
users: Mapped[list["UserModel"]] = relationship(
|
||||
secondary="sys_user_roles",
|
||||
back_populates="roles",
|
||||
secondary="sys_user_roles",
|
||||
back_populates="roles",
|
||||
lazy="selectin"
|
||||
)
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from fastapi import Query
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_validator, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||
|
||||
from app.api.v1.module_system.dept.schema import DeptOutSchema
|
||||
from app.api.v1.module_system.menu.schema import MenuOutSchema
|
||||
from app.core.base_schema import BaseSchema
|
||||
from app.core.validator import DateTimeStr, code_validator, role_permission_request_validator
|
||||
|
||||
from ..dept.schema import DeptOutSchema
|
||||
from ..menu.schema import MenuOutSchema
|
||||
|
||||
|
||||
class RoleCreateSchema(BaseModel):
|
||||
"""角色创建模型"""
|
||||
@@ -31,7 +28,7 @@ class RolePermissionSettingSchema(BaseModel):
|
||||
role_ids: list[int] = Field(default_factory=list, description='角色ID列表')
|
||||
menu_ids: list[int] = Field(default_factory=list, description='菜单ID列表')
|
||||
dept_ids: list[int] = Field(default_factory=list, description='部门ID列表')
|
||||
|
||||
|
||||
@model_validator(mode='after')
|
||||
def validate_fields(self):
|
||||
"""验证权限配置字段"""
|
||||
@@ -40,13 +37,12 @@ class RolePermissionSettingSchema(BaseModel):
|
||||
|
||||
class RoleUpdateSchema(RoleCreateSchema):
|
||||
"""角色更新模型"""
|
||||
...
|
||||
|
||||
|
||||
class RoleOutSchema(RoleCreateSchema, BaseSchema):
|
||||
"""角色信息响应模型"""
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
menus: list[MenuOutSchema] = Field(default_factory=list, description='角色菜单列表')
|
||||
depts: list[DeptOutSchema] = Field(default_factory=list, description='角色部门列表')
|
||||
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Any
|
||||
|
||||
from app.api.v1.module_system.auth.schema import AuthSchema
|
||||
from app.core.base_schema import BatchSetAvailable
|
||||
from app.core.exceptions import CustomException
|
||||
from app.utils.excel_util import ExcelUtil
|
||||
|
||||
from ..auth.schema import AuthSchema
|
||||
from .crud import RoleCRUD
|
||||
from .schema import (
|
||||
RoleCreateSchema,
|
||||
RoleUpdateSchema,
|
||||
RolePermissionSettingSchema,
|
||||
RoleOutSchema,
|
||||
RoleQueryParam
|
||||
)
|
||||
from .schema import RoleCreateSchema, RoleOutSchema, RolePermissionSettingSchema, RoleQueryParam, RoleUpdateSchema
|
||||
|
||||
|
||||
class RoleService:
|
||||
@@ -23,11 +16,11 @@ class RoleService:
|
||||
async def get_role_detail_service(cls, auth: AuthSchema, id: int) -> dict:
|
||||
"""
|
||||
获取角色详情
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- id (int): 角色ID
|
||||
|
||||
|
||||
返回:
|
||||
- dict: 角色详情字典
|
||||
"""
|
||||
@@ -38,12 +31,12 @@ class RoleService:
|
||||
async def get_role_list_service(cls, auth: AuthSchema, search: RoleQueryParam | None = None, order_by: list[dict[str, str]] | None = None) -> list[dict]:
|
||||
"""
|
||||
获取角色列表
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- search (RoleQueryParam | None): 查询参数模型
|
||||
- order_by (list[dict[str, str]] | None): 排序参数列表
|
||||
|
||||
|
||||
返回:
|
||||
- list[dict]: 角色详情字典列表
|
||||
"""
|
||||
@@ -54,11 +47,11 @@ class RoleService:
|
||||
async def create_role_service(cls, auth: AuthSchema, data: RoleCreateSchema) -> dict:
|
||||
"""
|
||||
创建角色
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- data (RoleCreateSchema): 创建角色模型
|
||||
|
||||
|
||||
返回:
|
||||
- dict: 新创建的角色详情字典
|
||||
"""
|
||||
@@ -75,12 +68,12 @@ class RoleService:
|
||||
async def update_role_service(cls, auth: AuthSchema, id: int, data: RoleUpdateSchema) -> dict:
|
||||
"""
|
||||
更新角色
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- id (int): 角色ID
|
||||
- data (RoleUpdateSchema): 更新角色模型
|
||||
|
||||
|
||||
返回:
|
||||
- dict: 更新后的角色详情字典
|
||||
"""
|
||||
@@ -97,11 +90,11 @@ class RoleService:
|
||||
async def delete_role_service(cls, auth: AuthSchema, ids: list[int]) -> None:
|
||||
"""
|
||||
删除角色
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- ids (list[int]): 角色ID列表
|
||||
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
@@ -117,20 +110,20 @@ class RoleService:
|
||||
async def set_role_permission_service(cls, auth: AuthSchema, data: RolePermissionSettingSchema) -> None:
|
||||
"""
|
||||
设置角色权限
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- data (RolePermissionSettingSchema): 角色权限设置模型
|
||||
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
# 设置角色菜单权限
|
||||
await RoleCRUD(auth).set_role_menus_crud(role_ids=data.role_ids, menu_ids=data.menu_ids)
|
||||
|
||||
|
||||
# 设置数据权限范围
|
||||
await RoleCRUD(auth).set_role_data_scope_crud(role_ids=data.role_ids, data_scope=data.data_scope)
|
||||
|
||||
|
||||
# 设置自定义数据权限部门
|
||||
if data.data_scope == 5 and data.dept_ids:
|
||||
await RoleCRUD(auth).set_role_depts_crud(role_ids=data.role_ids, dept_ids=data.dept_ids)
|
||||
@@ -141,11 +134,11 @@ class RoleService:
|
||||
async def set_role_available_service(cls, auth: AuthSchema, data: BatchSetAvailable) -> None:
|
||||
"""
|
||||
设置角色可用状态
|
||||
|
||||
|
||||
参数:
|
||||
- auth (AuthSchema): 认证信息模型
|
||||
- data (BatchSetAvailable): 批量设置可用状态模型
|
||||
|
||||
|
||||
返回:
|
||||
- None
|
||||
"""
|
||||
@@ -155,10 +148,10 @@ class RoleService:
|
||||
async def export_role_list_service(cls, role_list: list[dict[str, Any]]) -> bytes:
|
||||
"""
|
||||
导出角色列表
|
||||
|
||||
|
||||
参数:
|
||||
- role_list (list[dict[str, Any]]): 角色详情字典列表
|
||||
|
||||
|
||||
返回:
|
||||
- bytes: Excel文件字节流
|
||||
"""
|
||||
@@ -166,7 +159,7 @@ class RoleService:
|
||||
mapping_dict = {
|
||||
'id': '角色编号',
|
||||
'name': '角色名称',
|
||||
'order': '显示顺序',
|
||||
'order': '显示顺序',
|
||||
'data_scope': '数据权限',
|
||||
'status': '状态',
|
||||
'description': '备注',
|
||||
@@ -193,4 +186,3 @@ class RoleService:
|
||||
item['creator'] = item.get('creator', {}).get('name', '未知') if isinstance(item.get('creator'), dict) else '未知'
|
||||
|
||||
return ExcelUtil.export_list2excel(list_data=data, mapping_dict=mapping_dict)
|
||||
|
||||
Reference in New Issue
Block a user