refactor: 移除多租户相关代码,重构为单租户架构

此次提交进行了大规模的架构重构:
1.  移除所有平台租户相关模块和代码,包括租户管理、套餐、订单、发票等功能
2.  将菜单模块从platform迁移到system模块,统一系统功能入口
3.  移除租户隔离相关的模型混入、中间件和配置
4.  简化文件上传、SSE事件总线、定时任务等模块的租户逻辑
5.  重构所有业务schema和模型,移除租户相关字段和关联
6.  清理初始化脚本、模板和常量中的租户相关代码
7.  简化认证和权限控制逻辑,移除数据范围检查相关代码
This commit is contained in:
zhangtao
2026-07-16 23:22:45 +08:00
parent f74b5f277e
commit a222cd9e43
119 changed files with 421 additions and 7145 deletions
+5 -13
View File
@@ -1,31 +1,23 @@
from typing import TYPE_CHECKING
from sqlalchemy import ForeignKey, Integer, String, Text, UniqueConstraint
from sqlalchemy import ForeignKey, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.common.enums import PermissionFilterStrategy
from app.core.base_model import ModelMixin, TenantMixin, UserMixin
from app.core.base_model import ModelMixin, UserMixin
if TYPE_CHECKING:
from app.api.v1.module_system.role.model import RoleModel
from app.api.v1.module_system.user.model import UserModel
class DeptModel(ModelMixin, TenantMixin, UserMixin):
class DeptModel(ModelMixin, UserMixin):
"""部门模型
"""
__tablename__: str = "sys_dept"
__table_args__ = (UniqueConstraint("tenant_id", "code"), {"comment": "部门表"})
__table_args__: dict[str, str] = {"comment": "部门表"}
__tree_children_attr__: str = "children"
__loader_options__: list[str] = [
"children",
"created_by",
"updated_by",
"deleted_by",
"tenant_by",
]
__permission_strategy__: PermissionFilterStrategy = PermissionFilterStrategy.DEPT_RELATION
__loader_options__: list[str] = ["children", "created_by", "updated_by", "deleted_by"]
name: Mapped[str] = mapped_column(String(64), nullable=False, comment="部门名称")
status: Mapped[int] = mapped_column(Integer, default=0, nullable=False, comment="状态(0:启动 1:停用)", index=True)
@@ -1,6 +1,6 @@
from pydantic import BaseModel, ConfigDict, Field, field_validator
from app.core.base_schema import BaseQueryParam, BaseSchema, TenantByQueryParam, TenantBySchema, UserByQueryParam, UserBySchema
from app.core.base_schema import BaseQueryParam, BaseSchema, UserByQueryParam, UserBySchema
from app.core.validator import validate_required_code
@@ -44,7 +44,7 @@ class DeptUpdateSchema(DeptCreateSchema):
"""部门更新模型"""
class DeptOutSchema(DeptCreateSchema, BaseSchema, UserBySchema, TenantBySchema):
class DeptOutSchema(DeptCreateSchema, BaseSchema, UserBySchema):
"""部门详情响应模型(不含 children,用于详情和更新)"""
model_config = ConfigDict(from_attributes=True)
@@ -58,7 +58,7 @@ class DeptTreeOutSchema(DeptOutSchema):
children: list["DeptTreeOutSchema"] | None = Field(default=None, description="子部门列表")
class DeptQueryParam(BaseQueryParam, UserByQueryParam, TenantByQueryParam):
class DeptQueryParam(BaseQueryParam, UserByQueryParam):
"""部门管理查询参数"""
name: str | None = Field(None, description="部门名称")
@@ -1,6 +1,5 @@
from sqlalchemy.ext.asyncio import AsyncSession
from app.api.v1.module_platform.tenant.service import TenantService
from app.core.base_schema import AuthSchema, BatchSetAvailable
from app.core.exceptions import CustomException
from app.utils.common_util import (
@@ -24,7 +23,7 @@ from .schema import (
class DeptService:
"""部门管理服务
提供部门 CRUD、树形结构查询、级联启/禁用、租户配额检查等业务能力。
提供部门 CRUD、树形结构查询、级联启/禁用等业务能力。
"""
def __init__(self, auth: AuthSchema, db: AsyncSession) -> None:
@@ -57,12 +56,6 @@ class DeptService:
if obj:
raise CustomException(msg="创建失败,编码已存在")
# 检查租户配额
user = self.auth.user
if not user:
raise CustomException(msg="未登录")
await TenantService(self.auth, self.db).check_quota(user.tenant_id, "dept")
dept = await DeptCRUD(self.auth, self.db).create(data=data)
return DeptOutSchema.model_validate(dept)